From f93182ebb5ca8fe765d138675d469a57e1601792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Wed, 8 Apr 2020 23:16:29 -0300 Subject: Print file until end of window or end of file --- jet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jet.c b/jet.c index f71ffae..9a42328 100644 --- a/jet.c +++ b/jet.c @@ -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(); -- cgit v1.2.3