feat: Guard cursor movement.

This commit is contained in:
jmug
2026-10-26 12:32:04 -07:00
parent ef1f3c69ac
commit 6b59986fca
+8
View File
@@ -236,16 +236,24 @@ void editorRefreshScreen() {
void editorMoveCursor(int key) { void editorMoveCursor(int key) {
switch (key) { switch (key) {
case ARROW_LEFT: case ARROW_LEFT:
if (E.cx != 0) {
E.cx--; E.cx--;
}
break; break;
case ARROW_RIGHT: case ARROW_RIGHT:
if (E.cx != E.screencols - 1) {
E.cx++; E.cx++;
}
break; break;
case ARROW_UP: case ARROW_UP:
if (E.cy != 0) {
E.cy--; E.cy--;
}
break; break;
case ARROW_DOWN: case ARROW_DOWN:
if (E.cy != E.screenrows - 1) {
E.cy++; E.cy++;
}
break; break;
} }
} }