mirror of https://github.com/Sam1301/Lite.git
Prevent cursor going out of bounds
This commit is contained in:
parent
650fdc7ddb
commit
7cdfcb3c4a
14
editor.c
14
editor.c
|
@ -206,16 +206,24 @@ void editorRefreshTerminal() {
|
|||
void editorMoveCursor(int c) {
|
||||
switch(c) {
|
||||
case ARROW_LEFT:
|
||||
E.cursorX--;
|
||||
if (E.cursorX != 0) {
|
||||
E.cursorX--;
|
||||
}
|
||||
break;
|
||||
case ARROW_DOWN:
|
||||
if (E.cursorY != E.screenrows - 1) {
|
||||
E.cursorY++;
|
||||
}
|
||||
break;
|
||||
case ARROW_RIGHT:
|
||||
E.cursorX++;
|
||||
if (E.cursorX != E.screencols - 1) {
|
||||
E.cursorX++;
|
||||
}
|
||||
break;
|
||||
case ARROW_UP:
|
||||
E.cursorY--;
|
||||
if (E.cursorY != 0) {
|
||||
E.cursorY--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue