From e10c32d01e8416923226f211dd855824a8123dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Tue, 14 Apr 2020 00:39:04 -0300 Subject: Refactor jet.c --- jet.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jet.c b/jet.c index 1ec215c..d7edeb0 100644 --- a/jet.c +++ b/jet.c @@ -33,16 +33,18 @@ int main(int argc, char *argv[]) { int window_height = getmaxy(stdscr); int current_line = 0; + int old_line = -1; + int number_of_lines = 0; for (int i = 0; i < file_size; i++) { if (buffer[i] == '\n') number_of_lines++; } - int old_line = -1; + while (1) { if (old_line != current_line) { clear(); - int iter_line = 0; - for (int i = 0; i < file_size && iter_line < window_height + current_line; i++) { + + for (int i = 0, iter_line = 0; i < file_size && iter_line < window_height + current_line; i++) { if (iter_line >= current_line) addch(buffer[i]); if (buffer[i] == '\n') iter_line++; } -- cgit v1.2.3