summaryrefslogtreecommitdiff
path: root/jet.c
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-08 23:16:29 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-08 23:16:29 -0300
commitf93182ebb5ca8fe765d138675d469a57e1601792 (patch)
tree7517cb322ce10b3e05e54785c4174d7b94f1832d /jet.c
parent352c3394a7189f01f455bcbf83d2bf2a8641292d (diff)
downloadjet-f93182ebb5ca8fe765d138675d469a57e1601792.tar.gz
jet-f93182ebb5ca8fe765d138675d469a57e1601792.zip
Print file until end of window or end of file
Diffstat (limited to 'jet.c')
-rw-r--r--jet.c5
1 files changed, 4 insertions, 1 deletions
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();