|
|
|
@ -82,6 +82,26 @@ void buffer_left(Buffer* buffer) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void page_down_handler(Buffer* buffer) {
|
|
|
|
|
buffer_right(buffer); /* I must advance the cursor at least
|
|
|
|
|
once, so this hardcoded statement is fine. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (*(buffer->start - 1) != '\n') {
|
|
|
|
|
buffer_right(buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* You would think that I need to call 'buffer_right' once
|
|
|
|
|
more, to advance the cursor onto the next line. In fact, if
|
|
|
|
|
you think about it, the place where the cursor (the rectangle)
|
|
|
|
|
is, is actually the character _after_ the gap. Therefore, by
|
|
|
|
|
advancing the start to the newline character, the character
|
|
|
|
|
after the gap (i.e. the cursor) will automatically be moved to
|
|
|
|
|
the next line. */
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init_curses() {
|
|
|
|
|
initscr();
|
|
|
|
|
noecho();
|
|
|
|
@ -123,8 +143,6 @@ int main(int argc, char** argv) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_curses();
|
|
|
|
|
int ch;
|
|
|
|
|
|
|
|
|
@ -184,8 +202,8 @@ int main(int argc, char** argv) {
|
|
|
|
|
exception here), but that's a problem for another day. */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case KEY_DOWN:
|
|
|
|
|
|
|
|
|
|
case KEY_NPAGE:
|
|
|
|
|
page_down_handler(buffer);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|