summaryrefslogtreecommitdiff
path: root/jet.c
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-14 00:39:04 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-14 00:39:04 -0300
commite10c32d01e8416923226f211dd855824a8123dcd (patch)
treecb0ddf43d9fc33053f57b83701a6274091e0cb5d /jet.c
parenta01452b92b38f51ddcde14e7fa8d238e4d57dbb0 (diff)
downloadjet-e10c32d01e8416923226f211dd855824a8123dcd.tar.gz
jet-e10c32d01e8416923226f211dd855824a8123dcd.zip
Refactor jet.c
Diffstat (limited to 'jet.c')
-rw-r--r--jet.c8
1 files 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++;
}