diff --git a/editor.c b/editor.c index af10d04..755e6bd 100644 --- a/editor.c +++ b/editor.c @@ -96,6 +96,8 @@ 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); FILE* logfile = fopen("logfile.txt","w"); @@ -130,7 +132,7 @@ int main(int argc, char** argv) { while (true) { clear(); - int i=0; + int i=index_to_start; if ((buffer->start != buffer->text) || (buffer->gap_size != buffer->size)) { /* We don't want to print the string, if the gap starts at the first index of the string, and continues till the end */ @@ -147,7 +149,7 @@ int main(int argc, char** argv) { i++; fprintf(logfile,"At line %d of %d\n",getcury(stdscr),getmaxy(stdscr)); - if (*(buffer->text + i) == '\n' && (getcury(stdscr) == getmaxy(stdscr))) { + if (*(buffer->text + i) == '\n' && ((getcury(stdscr) + 1) == getmaxy(stdscr))) { fprintf(logfile,"Read newline\n"); break; } @@ -182,7 +184,8 @@ int main(int argc, char** argv) { exception here), but that's a problem for another day. */ break; - + case KEY_DOWN: + break; default: