More cursor logic
This commit is contained in:
parent
a76ba3ccb7
commit
8bb88afa6b
@ -269,9 +269,23 @@ void EditorState::OnKeyPressed(int key) {
|
|||||||
m_cursorX--;
|
m_cursorX--;
|
||||||
m_lastFurthestColumn = m_cursorX;
|
m_lastFurthestColumn = m_cursorX;
|
||||||
} else {
|
} else {
|
||||||
|
if( m_cursorY > 0)
|
||||||
|
{
|
||||||
m_cursorY--;
|
m_cursorY--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_scrollY--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_scrollY < 0){
|
||||||
|
m_scrollY = 0;
|
||||||
|
}else{
|
||||||
|
|
||||||
m_cursorX = (int)m_text[m_scrollY + m_cursorY].size();
|
m_cursorX = (int)m_text[m_scrollY + m_cursorY].size();
|
||||||
m_lastFurthestColumn = m_cursorX;
|
m_lastFurthestColumn = m_cursorX;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -282,8 +296,23 @@ void EditorState::OnKeyPressed(int key) {
|
|||||||
} else {
|
} else {
|
||||||
m_cursorX = 0;
|
m_cursorX = 0;
|
||||||
m_lastFurthestColumn = m_cursorX;
|
m_lastFurthestColumn = m_cursorX;
|
||||||
|
|
||||||
|
if(m_cursorY < std::min(m_height - 1, static_cast<int>(m_text.size()) - 1))
|
||||||
|
{
|
||||||
m_cursorY++;
|
m_cursorY++;
|
||||||
// TODO: Implement scroll handling as it's own function so this can scroll and/or move the cursor as well. Behavior should be identical to using the down/up arrow.
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_scrollY++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_scrollY + m_height > m_text.size() - 1){
|
||||||
|
m_scrollY = m_text.size() - 1 - m_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_scrollY < 0){
|
||||||
|
m_scrollY = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,10 +362,6 @@ void EditorState::OnKeyPressed(int key) {
|
|||||||
if(m_scrollY < 0){
|
if(m_scrollY < 0){
|
||||||
m_scrollY = 0;
|
m_scrollY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentLineLength = (int)m_text[m_scrollY + m_cursorY].size();
|
int currentLineLength = (int)m_text[m_scrollY + m_cursorY].size();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user