From a7af9d85819f1b2b3ff70e40594351abd1a3ae77 Mon Sep 17 00:00:00 2001 From: ElectricAlchemist Date: Wed, 30 Oct 2019 23:11:28 +0100 Subject: [PATCH] solved bug f75a58f --- .gitignore | 6 +++++- Makefile | 9 ++++++++- ste | Bin 22504 -> 0 bytes ste.c | 18 +++++++++--------- 4 files changed, 22 insertions(+), 11 deletions(-) delete mode 100755 ste diff --git a/.gitignore b/.gitignore index 73ceaf2..c7180d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -ste \ No newline at end of file +ste +dbg +hello +ste.c.* +*.bak \ No newline at end of file diff --git a/Makefile b/Makefile index 2341577..bdc42ca 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,15 @@ CC=gcc -CFLAGS=-Wall -Wextra -pedantic -Werror +CFLAGS=-Wall -Wextra -pedantic -Werror -Warray-bounds OFLAGS=-O3 LFLAGS=-lncursesw #-ltcmalloc +DFLAGS=-g -O0 -v -da -Q ste: ste.c $(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^ + +dbg: ste.c + $(CC) $(CFLAGS) $(DFLAGS) $(LFLAGS) -o dbg $^ + +clean: + rm ste ste.c.* dbg diff --git a/ste b/ste deleted file mode 100755 index 6f21cd0abefdc8b9f387cb46fdd63be242697945..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22504 zcmeHP4|G)3nSYbXgW*qRf)E-}$`peQQeuJz6JazDCh$fFi5O6^I)=#vQu5Da!XHHl zPC|M6c$l_ot!`V^wpQD1#cgX{*Ode`5l*`Tu8QkFv})f#ML-SskJ;aM-@TJJL#Eq3 zXV0EJdved2_ucPzzwh4fe)sRYGjlgp1{Y*G9Fho5=?aOsol`8Nf+wu1;t`MvsZ1J! z=U1i4(g^U`471WJEP_-ktjbEIE{;1vN$(M!o=zumIYEVmL`g4GxM8f7BB+#W@uVkH zl=JD-$g|`G73s5J2!h)6$Tx?4ELl3VD3z9Ry+TnLZWpzh zb4Lg&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UiQA zxt^eh(;S|by+rTrcKzgLo^R@fy;K$j!3#=%Sg`AheWIYZjc01fhbUhFKS|RU=fZ-D z^HCw6-v1xv`l9`k=Qzcd#+^cu({%mE)AYr8kD#^xh5oKIeQ_=%s5fbtm67n9$aXIx zbe6)0S@Qfy++&$8FL*&;g09D=FV4vi`v4*cIg1$J*2VHe*&*=b};|| diff --git a/ste.c b/ste.c index b053481..33b24fa 100644 --- a/ste.c +++ b/ste.c @@ -18,8 +18,8 @@ struct term { struct { int x; int y; - int off_x; - int off_y; + unsigned int off_x; + unsigned int off_y; int r_x; int r_y; int xx; @@ -42,7 +42,7 @@ struct term { typedef struct row { int size; char *chars; - int r_size; + unsigned int r_size; char *render; int delta; } row; @@ -249,12 +249,12 @@ void drawScreen () /* Draw all the appropriate lines (following cursor) to the screen */ void drawLines (void) { - static int line = 0, ln, i; + static int ln, i; /* move to the beginning of the screen */ //lnMove(0, 0); - for (i = 0; i < t.dim.y; i++) { - if (i >= rows.rownum) break; + for (i = 0, ln = 0; i < t.dim.y; i++) { + if (i >= rows.rownum - 1) break; ln = i + t.cur.off_y; /* Draw the line number */ @@ -272,7 +272,7 @@ void drawLines (void) //attroff(COLOR_PAIR(2)); - lnMove(++line, 0); + lnMove(i + 1, 0); } lnMove(t.cur.y, t.cur.x); } @@ -576,7 +576,7 @@ void rowAddRow (int pos) // WIP; TO DOCUMENT char *s = NULL; // Move away other lines //copy old last line to new space - rowAddLast(rows.rw[rows.rownum].chars, rows.rw[rows.rownum].size); + rowAddLast(rows.rw[rows.rownum - 1].chars, rows.rw[rows.rownum - 1].size); for (int last = rows.rownum - 1; last > pos; last--) { rowCpy(&rows.rw[last], &rows.rw[last - 1]); @@ -635,7 +635,7 @@ void updateInfo (void) { getmaxyx(stdscr, t.dim.y, t.dim.x); t.dim.y -= 1; - t.pad = decimalSize(rows.rownum); + t.pad = decimalSize(rows.rownum - 1); t.dim.x -= t.pad + 1; }