diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-08 23:16:29 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-08 23:16:29 -0300 |
commit | f93182ebb5ca8fe765d138675d469a57e1601792 (patch) | |
tree | 7517cb322ce10b3e05e54785c4174d7b94f1832d | |
parent | 352c3394a7189f01f455bcbf83d2bf2a8641292d (diff) | |
download | jet-f93182ebb5ca8fe765d138675d469a57e1601792.tar.gz jet-f93182ebb5ca8fe765d138675d469a57e1601792.zip |
Print file until end of window or end of file
-rw-r--r-- | jet.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -31,9 +31,12 @@ int main(int argc, char *argv[]) { intrflush(stdscr, FALSE); keypad(stdscr, TRUE); + int window_height = getmaxy(stdscr); while (1) { - for (int i = 0; i < file_size; i++) { + int current_line = 0; + for (int i = 0; i < file_size && current_line < window_height; i++) { addch(buffer[i]); + if (buffer[i] == '\n') current_line++; } getch(); clear(); |