feat: Move with page up and down.
This commit is contained in:
@@ -310,6 +310,7 @@ void abFree(struct abuf *ab) {
|
|||||||
/*** output ***/
|
/*** output ***/
|
||||||
|
|
||||||
void editorScroll() {
|
void editorScroll() {
|
||||||
|
// TODO: I _think_ this conversion should live in editorMoveCursor?
|
||||||
E.rx = 0;
|
E.rx = 0;
|
||||||
// Last line (emtpy) is always at 0.
|
// Last line (emtpy) is always at 0.
|
||||||
if (E.cy < E.numrows)
|
if (E.cy < E.numrows)
|
||||||
@@ -466,6 +467,16 @@ void editorProcessKeypress() {
|
|||||||
|
|
||||||
case PAGE_UP:
|
case PAGE_UP:
|
||||||
case PAGE_DOWN: {
|
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;
|
int times = E.screenrows;
|
||||||
while (times--) {
|
while (times--) {
|
||||||
editorMoveCursor(c == PAGE_UP ? ARROW_UP : ARROW_DOWN);
|
editorMoveCursor(c == PAGE_UP ? ARROW_UP : ARROW_DOWN);
|
||||||
|
|||||||
Reference in New Issue
Block a user