From 0430e878fafea181249a2954d769daba054dc145 Mon Sep 17 00:00:00 2001 From: gunboy001 Date: Fri, 15 Nov 2019 21:41:27 +0100 Subject: [PATCH] Revert "WIP on master: d6ab158 basic find" This reverts commit 22e8e3e7dc4f1f83bbb3b8292205e0f73ddc85a8, reversing changes made to d6ab1586fff4bd8ddca240cccd52a5b30fe21186. possible bug fixes --- ste.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ste.c b/ste.c index cd9d177..ca967ed 100644 --- a/ste.c +++ b/ste.c @@ -126,7 +126,7 @@ int main (int argc, char *argv[]) snprintf(t.statusbar, STAT_SIZE, "%s %d lines %dx%d", argv[1], rows.rownum, t.dim.y, t.dim.x); /* remember the initial row number */ - int irow = decimalSize(rows.rownum); +// int irow = decimalSize(rows.rownum); /* Main event loop */ int c; @@ -140,18 +140,22 @@ int main (int argc, char *argv[]) case (CTRL('q')): termExit(); break; + case (KEY_LEFT): case (KEY_RIGHT): case (KEY_UP): case (KEY_DOWN): cursorMove(c); break; + case (KEY_BACKSPACE): handleDel(0); break; + case (KEY_DC): handleDel(1); break; + case (KEY_ENTER): case (10): case ('\r'): @@ -159,25 +163,29 @@ int main (int argc, char *argv[]) t.cur.y++; t.cur.x = 0; break; + case (KEY_END): t.cur.y = rows.rownum - 1; break; + case (KEY_HOME): t.cur.y = 0; break; + case (CTRL('f')): if (!editorFind("for", &t.cur.y, &t.cur.x)) { t.cur.y = 0; editorFind("for", &t.cur.y, &t.cur.x); } break; + default: if (c == KEY_STAB) c = '\t'; rowAddChar(&rows.rw[t.cur.y], c, t.cur.x); t.cur.x++; break; } - if (decimalSize(rows.rownum) - irow) updateInfo(); + //if (decimalSize(rows.rownum) - irow) updateInfo(); } /* If by chance i find myself here be sure @@ -650,6 +658,10 @@ void curUpdateRender () the right bound. */ + /* Adjust x and y if they are out of bounds */ + if (t.cur.y < 0 || t.cur.y >= rows.rownum) t.cur.y = 0; + if (t.cur.x < 0) t.cur.x = 0; + if (t.cur.y >= t.cur.off_y && t.cur.y < t.cur.off_y + t.dim.y) { t.cur.r_y = t.cur.y - t.cur.off_y;