improved
This commit is contained in:
parent
1c7d2a7621
commit
d337d0dd18
BIN
.sconsign.dblite
BIN
.sconsign.dblite
Binary file not shown.
25
src/ste.c
25
src/ste.c
@ -84,7 +84,6 @@ static void updateInfo (void);
|
|||||||
static int whatsThat (void);
|
static int whatsThat (void);
|
||||||
static void insert (sbuf *buf, int c);
|
static void insert (sbuf *buf, int c);
|
||||||
static inline void flush (sbuf *buf);
|
static inline void flush (sbuf *buf);
|
||||||
static void toString (sbuf *buf, char *s);
|
|
||||||
|
|
||||||
/* --------------------------------- main ------------------------------------ */
|
/* --------------------------------- main ------------------------------------ */
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
@ -141,10 +140,7 @@ int main (int argc, char *argv[])
|
|||||||
t.cur.y++;
|
t.cur.y++;
|
||||||
t.cur.x = 0;
|
t.cur.x = 0;
|
||||||
} else {
|
} else {
|
||||||
char *query = malloc(t.search_buffer.num + 1);
|
editorFind(t.search_buffer.c, &t.cur.y, &t.cur.x);
|
||||||
if (query == NULL) termDie("maloc in query allocation");
|
|
||||||
toString(&t.search_buffer, query);
|
|
||||||
editorFind(query, &t.cur.y, &t.cur.x);
|
|
||||||
// Toggle mode
|
// Toggle mode
|
||||||
t.mode_b ^= 0x1;
|
t.mode_b ^= 0x1;
|
||||||
flush (&t.search_buffer);
|
flush (&t.search_buffer);
|
||||||
@ -160,11 +156,6 @@ int main (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case (CTRL('f')):
|
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
|
// Toggle mode
|
||||||
t.mode_b ^= 0x1;
|
t.mode_b ^= 0x1;
|
||||||
flush (&t.search_buffer);
|
flush (&t.search_buffer);
|
||||||
@ -267,7 +258,10 @@ void drawScreen ()
|
|||||||
/* draw the lines */
|
/* draw the lines */
|
||||||
drawLines();
|
drawLines();
|
||||||
/* draw the bar */
|
/* draw the bar */
|
||||||
drawBar(t.statusbar);
|
drawBar(
|
||||||
|
((t.mode_b & 0x1) == 0) ? t.statusbar :
|
||||||
|
t.search_buffer.c
|
||||||
|
);
|
||||||
/* move back to the cursor position */
|
/* move back to the cursor position */
|
||||||
lnMove(t.cur.r_y, t.cur.r_x);
|
lnMove(t.cur.r_y, t.cur.r_x);
|
||||||
/* refresh the screen */
|
/* refresh the screen */
|
||||||
@ -592,8 +586,9 @@ int editorFind (const char* needle, int *y, int *x)
|
|||||||
|
|
||||||
void insert (sbuf *buf, int c)
|
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++] = c;
|
||||||
|
buf->c[buf->num] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush (sbuf *buf)
|
void flush (sbuf *buf)
|
||||||
@ -601,10 +596,4 @@ void flush (sbuf *buf)
|
|||||||
buf->num = 0;
|
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 ------------------------------------*/
|
/*--------------------------------- testing ------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user