diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-09 01:31:44 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2020-04-09 01:31:44 -0300 |
commit | 3a057c037f3a8f28e27c520db041f8025eba53c2 (patch) | |
tree | e932e90ef276b3e7774838956d35e7c2315618ba | |
parent | 1caf059c2cdffd3162fe030f824ded2bd5b03997 (diff) | |
download | jet-3a057c037f3a8f28e27c520db041f8025eba53c2.tar.gz jet-3a057c037f3a8f28e27c520db041f8025eba53c2.zip |
Redraw only if line changed
-rw-r--r-- | jet.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -37,15 +37,19 @@ int main(int argc, char *argv[]) { for (int i = 0; i < file_size; i++) { if (buffer[i] == '\n') number_of_lines++; } + int old_line = -1; while (1) { - int iter_line = 0; - for (int i = 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++; + if (old_line != current_line) { + clear(); + int iter_line = 0; + for (int i = 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++; + } } + old_line = current_line; int input = getch(); - clear(); switch (input) { case KEY_UP: |