Prevent cursor going out of bounds

This commit is contained in:
Saumya Bhatnagar 2018-05-28 12:08:34 +05:30
parent 650fdc7ddb
commit 7cdfcb3c4a
2 changed files with 11 additions and 3 deletions

BIN
editor

Binary file not shown.

View File

@ -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;
}
}