summaryrefslogtreecommitdiff
path: root/jet.c
diff options
context:
space:
mode:
Diffstat (limited to 'jet.c')
-rw-r--r--jet.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/jet.c b/jet.c
index 0d1181a..b65ef81 100644
--- a/jet.c
+++ b/jet.c
@@ -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: