From b2af13cdff8ae5a7f0399970e0a14d8c0382781b Mon Sep 17 00:00:00 2001 From: ElectricAlchemist Date: Tue, 29 Oct 2019 11:16:27 +0100 Subject: [PATCH] bug fixes --- Makefile | 2 +- ste | Bin 22208 -> 22168 bytes ste.c | 24 +++++++++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 430d314..9672dff 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC=gcc CFLAGS=-Wall -Wextra -pedantic -Werror OFLAGS=-O3 -LFLAGS=-lncursesw +LFLAGS=-lncursesw -ltcmalloc ste: ste.c $(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^ diff --git a/ste b/ste index 1600ef6f1002138ed82b5fc5e1fc6cf0a291619a..460d0487b0fd993773aa572a955c45a30a0ad576 100755 GIT binary patch delta 5756 zcmZ`-3wTqjX5G zP3M+QKIw|GCo8^Li~1-(M4#hq^eHYYiRhvT(a|@#-v3u|UQBEr-LEUoth(`a(#+q! zcVzzAVsp>GzGo~x|I4?jqAM{C2HtHrJ7d>GD(JGf`)R-4#x>FBK_eRdj)s^tdPqYK zYIMGa%+%-shR|+(7WcH)Cupds(H$D{nnoYc5W7Yn)95Q2enF!*H5y`+7I+Nw1$`#B zSK~^IS@bD=7R^e?;{KpXH85>@*pNjPV-|OXVaBx_AyY7m3~oL3C%~VC)t36Yb;0Te ze|>#Zb$&}z{#^Q5LUu-!C$-Ii0BH_roz#$cAhRXdTpws84S|O0jax`>Uh@SB9%o1C(jJmoM0-aC{d*S&XCJ@L- zF}`&|otas90X!@5bTCC(axIougRwM;wGjzMkoC7|^{hsL0G`tLyhVO%n&(0;T` z$;sTL9&7S{>GxU^xeGle%Po#OP4($3lUI+b>QT0e%EzPBpPrF&1VFj;JF&Bm?`WmZ zr7z(2(BAar+&@x2qkvmOOERW}KE&dOjWZS^afTPFsw&D`bEhl+`L(KgrK?K)9aU8d zK}6Zrjq^fzlmR2?1rP$ztBv<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7bu{B9Vx8Fohteu-2d+u@8-d;OFTh^QC^!_ot?L(N#?H6c ZMe0p5^ve2^guG3wHY_9y=++HS{U0Y~k+J{) diff --git a/ste.c b/ste.c index 13736db..cff2d6a 100644 --- a/ste.c +++ b/ste.c @@ -131,6 +131,7 @@ int main (int argc, char *argv[]) rowDeleteChar(&rows.rw[t.cur.y + t.cur.off_y], 1); break; default: + if (c == KEY_STAB) c = '\t'; rowAddChar(&rows.rw[t.cur.y + t.cur.off_y], c); } } @@ -279,7 +280,7 @@ void drawBar (char *s) mvaddch(t.dim.y, i, ' '); char m[10]; - sprintf(m, "Zoom: %c", whatsThat()); + sprintf(m, "%d Zoom: %c", t.cur.x + t.cur.off_x, whatsThat()); mvaddstr(t.dim.y, t.dim.x + t.pad - strlen(m), m); /* Return to normal contrast mode */ @@ -381,8 +382,8 @@ void rowInit (void) void rowAddChar (row *rw, char c) // WIP { - // Error checking - if (!c || iscntrl(c)) return; + // Error checking (allow tab) + if (!c || (iscntrl(c) && c != '\t')) return; int cur = t.cur.x + t.cur.off_x, i = 0; char *s = rw->chars; @@ -415,7 +416,9 @@ void rowDeleteChar (row *rw, int m) // WIP int cur = t.cur.x + t.cur.off_x; char *s = rw->chars; //Do not delete NULL char - if(s[cur - 1] == '\0' || !cur) return; + if (s[cur - 1] == '\0' && cur) return; + if (!cur && !m) return; + if (s[cur] == '\0' && m) return; rw->chars = malloc(rw->size); rw->size--; @@ -427,18 +430,21 @@ void rowDeleteChar (row *rw, int m) // WIP for (int i = cur; i < rw->size + 1; i++) rw->chars[i - 1] = s[i]; + + t.cur.x--; // Delete } else { - for (int i = 0; i < cur; i++) - rw->chars[i] = s[i]; + if(cur) { + for (int i = 0; i < cur; i++) + rw->chars[i] = s[i]; + } - for (int i = cur + 1; i < rw->size + 1; i++) - rw->chars[i - 1] = s[i]; + for (int i = cur; i < rw->size + 1; i++) + rw->chars[i] = s[i + 1]; } free(s); updateRender(rw); - t.cur.x--; } /* ----------------------------- file operations --------------------------- */