From 051ff4ccde14825ce9716764d6e699761008e8b0 Mon Sep 17 00:00:00 2001 From: jmug Date: Thu, 19 Nov 2026 17:49:23 -0800 Subject: [PATCH] feat: Move with page up and down. --- kilo.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kilo.c b/kilo.c index 1f4fb23..b641060 100644 --- a/kilo.c +++ b/kilo.c @@ -310,6 +310,7 @@ void abFree(struct abuf *ab) { /*** output ***/ void editorScroll() { + // TODO: I _think_ this conversion should live in editorMoveCursor? E.rx = 0; // Last line (emtpy) is always at 0. if (E.cy < E.numrows) @@ -466,6 +467,16 @@ void editorProcessKeypress() { case PAGE_UP: case PAGE_DOWN: { + // Position either at the top or bottom of the page. + if (c == PAGE_UP) { + E.cy = E.rowoff; + } else { + E.cy = E.rowoff + E.screenrows - 1; + if (E.cy > E.numrows) + E.cy = E.numrows; + } + + // Then simulate an entire screen's worth of movement. int times = E.screenrows; while (times--) { editorMoveCursor(c == PAGE_UP ? ARROW_UP : ARROW_DOWN);