From d337d0dd18133a31846bb990a6822e7d9e875e9f Mon Sep 17 00:00:00 2001 From: gunboy001 Date: Wed, 27 Nov 2019 12:39:26 +0100 Subject: [PATCH] improved --- .sconsign.dblite | Bin 3124 -> 3124 bytes src/ste.c | 25 +++++++------------------ src/ste.o | Bin 13248 -> 12952 bytes 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.sconsign.dblite b/.sconsign.dblite index 36752fa24ba3d3841c0d0260ca49aff2ddcbb27d..5c29a0d6e5450cfab05389c405d9b4569af38b6c 100644 GIT binary patch delta 253 zcmajZF$%&!5I|AXq|hK(rqsq#$^ZZW delta 253 zcmdlYu|;CTG8SX8n0v7qtlmr++@T7INvS4=CYFiD#wiBIX(^T_CTT|ImT8HG$*HD^ ziAiaNQ5n3x2aG4*WN9@LLDFZCmS|~cV47-aoM>U0lA2^_45UmFlZ}&26DHH-jJE=mXh diff --git a/src/ste.c b/src/ste.c index 3a14fa1..87770b7 100644 --- a/src/ste.c +++ b/src/ste.c @@ -84,7 +84,6 @@ static void updateInfo (void); static int whatsThat (void); static void insert (sbuf *buf, int c); static inline void flush (sbuf *buf); -static void toString (sbuf *buf, char *s); /* --------------------------------- main ------------------------------------ */ int main (int argc, char *argv[]) @@ -141,10 +140,7 @@ int main (int argc, char *argv[]) t.cur.y++; t.cur.x = 0; } else { - char *query = malloc(t.search_buffer.num + 1); - if (query == NULL) termDie("maloc in query allocation"); - toString(&t.search_buffer, query); - editorFind(query, &t.cur.y, &t.cur.x); + editorFind(t.search_buffer.c, &t.cur.y, &t.cur.x); // Toggle mode t.mode_b ^= 0x1; flush (&t.search_buffer); @@ -160,11 +156,6 @@ int main (int argc, char *argv[]) break; case (CTRL('f')): - /*if (!editorFind("for", &t.cur.y, &t.cur.x)) { - t.cur.y = 0; - editorFind("for", &t.cur.y, &t.cur.x); - }*/ - // Toggle mode t.mode_b ^= 0x1; flush (&t.search_buffer); @@ -267,7 +258,10 @@ void drawScreen () /* draw the lines */ drawLines(); /* draw the bar */ - drawBar(t.statusbar); + drawBar( + ((t.mode_b & 0x1) == 0) ? t.statusbar : + t.search_buffer.c + ); /* move back to the cursor position */ lnMove(t.cur.r_y, t.cur.r_x); /* refresh the screen */ @@ -592,8 +586,9 @@ int editorFind (const char* needle, int *y, int *x) void insert (sbuf *buf, int c) { - if (buf->num < SBUF_SIZE - 1) + if (buf->num < SBUF_SIZE - 2) buf->c[buf->num++] = c; + buf->c[buf->num] = '\0'; } void flush (sbuf *buf) @@ -601,10 +596,4 @@ void flush (sbuf *buf) buf->num = 0; } -void toString (sbuf *buf, char *s) -{ - for (int i = 0; i < buf->num; i++) - s[i] = buf->c[i]; - s[buf->num] = '\0'; -} /*--------------------------------- testing ------------------------------------*/ diff --git a/src/ste.o b/src/ste.o index e57b5f7c2056d2aebe5034163e71c1b1a2f93ba9..f9c714b404e26f253ca10697ebb629fc5a44d15b 100644 GIT binary patch literal 12952 zcmbW7eRLF6mcU=7lMp~s&4-90OQXagD!nuy&_FarI#3x}L9O_8YRT)Rj6 zPL**{+n`l%SZ{o(n>;jn;^QT?dNRLc4v6VSVD=neipL`HrK0xCAJ14-az~MF-iBIu zg>LNEyHje{GZUb}!NBZkSQ9jBXM1$>{@K$Ic`P&+vpN}3-8daIKGcmr3oZS6VkjH; z>d81X>Q1#!I5SP1833J$(@K1T`a)o8cKNvYh2<0CXM#o*F>vZcu0Cju4D_5x!AxEds3O0LsQ zUeeYDEX3UoBulXR-i_G5SQmPCR_!`524;5OszSBzo_teRG&3+eYqiTc17qJac`SId z7v0FM7$fx}x)d<_b>jfIGEixjE8LwcW7|Klw3sWDM1P*aEjJF89<@r=0EId2PPG*+ zKBMyr z=85Ck#FeoDQ+H`UdUk)OaM$BmUY^j#Da#yAf#H}6s`bzG5XYn(IJW;sT~CMEei6?GhovQVq5 zeede&lLeL{YP4{#%Jq*-?OF{pO1Gwfzan4lnUT%Hc&whLn+qZOQ#(IMf#aQ*JK)|j zLpK8oESLj2MB7#wKb5Q~8WEfHP@Y+x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