From 6eb557fc487f2b8a38189db11c4303e7ac730f93 Mon Sep 17 00:00:00 2001 From: ElectricAlchemist Date: Fri, 1 Nov 2019 00:05:47 +0100 Subject: [PATCH] fixed some easy bugs --- ste.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ste.c b/ste.c index 56a62f1..e9d08a0 100644 --- a/ste.c +++ b/ste.c @@ -100,7 +100,7 @@ int main (int argc, char *argv[]) rowInit(); /* Try to open the file */ - if (argc != 2) { + if (argc < 2) { perror("File not found"); exit(1); } else fileOpen(argv[1]); @@ -110,7 +110,7 @@ int main (int argc, char *argv[]) termInit(); /* Set the statusbar left (static) message */ - sprintf(t.statusbar, "%s : %s %d lines %dx%d", argv[0], argv[1], rows.rownum, t.dim.y, t.dim.y); + sprintf(t.statusbar, "%s : %s %d lines %dx%d", argv[0], argv[1], rows.rownum, t.dim.y, t.dim.x); /* remember the initial row number */ int irow = decimalSize(rows.rownum); @@ -266,8 +266,8 @@ void drawLines (void) //if (ln == t.cur.y + t.cur.off_y) attron(COLOR_PAIR(2)); /* Draw the line matcing render memory */ - if (rows.rw[ln].r_size >= t.cur.off_x) { - addnstr(&rows.rw[ln].render[t.cur.off_x], t.dim.x + 1 - rows.rw[ln].delta); + if (rows.rw[ln].r_size > t.cur.off_x) { + addnstr(&rows.rw[ln].render[t.cur.off_x], t.dim.x + 1); } //attroff(COLOR_PAIR(2)); @@ -321,7 +321,7 @@ int curRealToRender (row *rw, int c_x) void fileOpen (char *filename) { FILE *fp = fopen(filename, "r"); - if (!fp) termDie("Cannot open file"); + if (fp == NULL) termDie("Cannot open file"); /* Init the linebuffer */ char *line = NULL; @@ -539,7 +539,7 @@ void updateScroll (void) t.cur.x = t.dim.x; - } else if (t.cur.x <= 0 && t.cur.off_x > 0) { + } else if (t.cur.x < 0 && t.cur.off_x > 0) { t.cur.off_x--; t.cur.x = 0; }