|
|
@ -87,9 +87,10 @@ void buffer_left(Buffer* buffer) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void scroll_page_down_handler(Buffer* buffer) {
|
|
|
|
void scroll_page_down_handler(Buffer* buffer) {
|
|
|
|
while (*(buffer->start + index_to_start) != '\n') {
|
|
|
|
while (*(buffer->text + index_to_start) != '\n') {
|
|
|
|
index_to_start++;
|
|
|
|
index_to_start++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
index_to_start++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void page_down_handler(Buffer* buffer) {
|
|
|
|
void page_down_handler(Buffer* buffer) {
|
|
|
@ -115,6 +116,36 @@ void page_down_handler(Buffer* buffer) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void scroll_page_up_handler(Buffer* buffer) {
|
|
|
|
|
|
|
|
for (int i=0;i<2;i++) { /* we need to encounter two 'newlines' before we stop */
|
|
|
|
|
|
|
|
while((*(buffer->text + index_to_start) != '\n') && (index_to_start >= 0)) {
|
|
|
|
|
|
|
|
index_to_start--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index_to_start++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void page_up_handler(Buffer* buffer) {
|
|
|
|
|
|
|
|
while((*(buffer->start - 1) != '\n') && (buffer->text != buffer->start)) {
|
|
|
|
|
|
|
|
buffer_left(buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffer_left(buffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while((*(buffer->start - 1) != '\n') && (buffer->text != buffer->start)) {
|
|
|
|
|
|
|
|
buffer_left(buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((getcury(stdscr) == 0) && (index_to_start > 0)) {
|
|
|
|
|
|
|
|
scroll_page_up_handler(buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void init_curses() {
|
|
|
|
void init_curses() {
|
|
|
|
initscr();
|
|
|
|
initscr();
|
|
|
|
noecho();
|
|
|
|
noecho();
|
|
|
@ -218,6 +249,10 @@ int main(int argc, char** argv) {
|
|
|
|
page_down_handler(buffer);
|
|
|
|
page_down_handler(buffer);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case KEY_PPAGE:
|
|
|
|
|
|
|
|
page_up_handler(buffer);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
buffer_insert(ch,buffer);
|
|
|
|
buffer_insert(ch,buffer);
|
|
|
|
|
|
|
|
|
|
|
|