Coninued working on page overflow

master
Aadhavan Srinivasan 2 years ago
parent 9524ba4df9
commit 563271d1b2

@ -6,6 +6,8 @@
#include <stdbool.h>
#include <unistd.h>
int index_to_start = 0;
typedef struct Buffer_struct Buffer;
struct Buffer_struct {
char* text;
@ -83,6 +85,13 @@ void buffer_left(Buffer* buffer) {
}
void scroll_page_down_handler(Buffer* buffer) {
while (*(buffer->start + index_to_start) != '\n') {
index_to_start++;
}
}
void page_down_handler(Buffer* buffer) {
buffer_right(buffer); /* I must advance the cursor at least
once, so this hardcoded statement is fine. */
@ -92,6 +101,10 @@ void page_down_handler(Buffer* buffer) {
buffer_right(buffer);
}
if ((getcury(stdscr) + 1) == getmaxy(stdscr)) {
scroll_page_down_handler(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)
@ -116,7 +129,6 @@ void sigint_handler(int dummy) {
}
int main(int argc, char** argv) {
int index_to_start = 0;
signal(SIGINT,sigint_handler);
Buffer* buffer = new_buffer(10);

Loading…
Cancel
Save