From 071ddf5ac03ca8ebf226afba1666e58269d1a9be Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Thu, 20 Apr 2023 14:50:13 -0500 Subject: [PATCH] Started implementing overflow and scrolling for files --- editor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/editor.c b/editor.c index b7083eb..af10d04 100644 --- a/editor.c +++ b/editor.c @@ -87,6 +87,7 @@ void init_curses() { noecho(); keypad(stdscr,TRUE); cbreak(); +// scrollok(stdscr,TRUE); } void sigint_handler(int dummy) { @@ -97,6 +98,7 @@ void sigint_handler(int dummy) { int main(int argc, char** argv) { signal(SIGINT,sigint_handler); Buffer* buffer = new_buffer(10); + FILE* logfile = fopen("logfile.txt","w"); if (argc == 2) { int num_of_chars = 0; @@ -144,6 +146,11 @@ int main(int argc, char** argv) { addch(*(buffer->text + i)); i++; + fprintf(logfile,"At line %d of %d\n",getcury(stdscr),getmaxy(stdscr)); + if (*(buffer->text + i) == '\n' && (getcury(stdscr) == getmaxy(stdscr))) { + fprintf(logfile,"Read newline\n"); + break; + } } move(y,x); @@ -175,6 +182,9 @@ int main(int argc, char** argv) { exception here), but that's a problem for another day. */ break; + + break; + default: buffer_insert(ch,buffer);