bug fixes
This commit is contained in:
parent
c526f81dfe
commit
b2af13cdff
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-Wall -Wextra -pedantic -Werror
|
CFLAGS=-Wall -Wextra -pedantic -Werror
|
||||||
OFLAGS=-O3
|
OFLAGS=-O3
|
||||||
LFLAGS=-lncursesw
|
LFLAGS=-lncursesw -ltcmalloc
|
||||||
|
|
||||||
ste: ste.c
|
ste: ste.c
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^
|
$(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^
|
||||||
|
24
ste.c
24
ste.c
@ -131,6 +131,7 @@ int main (int argc, char *argv[])
|
|||||||
rowDeleteChar(&rows.rw[t.cur.y + t.cur.off_y], 1);
|
rowDeleteChar(&rows.rw[t.cur.y + t.cur.off_y], 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (c == KEY_STAB) c = '\t';
|
||||||
rowAddChar(&rows.rw[t.cur.y + t.cur.off_y], c);
|
rowAddChar(&rows.rw[t.cur.y + t.cur.off_y], c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +280,7 @@ void drawBar (char *s)
|
|||||||
mvaddch(t.dim.y, i, ' ');
|
mvaddch(t.dim.y, i, ' ');
|
||||||
|
|
||||||
char m[10];
|
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);
|
mvaddstr(t.dim.y, t.dim.x + t.pad - strlen(m), m);
|
||||||
|
|
||||||
/* Return to normal contrast mode */
|
/* Return to normal contrast mode */
|
||||||
@ -381,8 +382,8 @@ void rowInit (void)
|
|||||||
|
|
||||||
void rowAddChar (row *rw, char c) // WIP
|
void rowAddChar (row *rw, char c) // WIP
|
||||||
{
|
{
|
||||||
// Error checking
|
// Error checking (allow tab)
|
||||||
if (!c || iscntrl(c)) return;
|
if (!c || (iscntrl(c) && c != '\t')) return;
|
||||||
|
|
||||||
int cur = t.cur.x + t.cur.off_x, i = 0;
|
int cur = t.cur.x + t.cur.off_x, i = 0;
|
||||||
char *s = rw->chars;
|
char *s = rw->chars;
|
||||||
@ -415,7 +416,9 @@ void rowDeleteChar (row *rw, int m) // WIP
|
|||||||
int cur = t.cur.x + t.cur.off_x;
|
int cur = t.cur.x + t.cur.off_x;
|
||||||
char *s = rw->chars;
|
char *s = rw->chars;
|
||||||
//Do not delete NULL char
|
//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->chars = malloc(rw->size);
|
||||||
rw->size--;
|
rw->size--;
|
||||||
@ -427,18 +430,21 @@ void rowDeleteChar (row *rw, int m) // WIP
|
|||||||
|
|
||||||
for (int i = cur; i < rw->size + 1; i++)
|
for (int i = cur; i < rw->size + 1; i++)
|
||||||
rw->chars[i - 1] = s[i];
|
rw->chars[i - 1] = s[i];
|
||||||
|
|
||||||
|
t.cur.x--;
|
||||||
// Delete
|
// Delete
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < cur; i++)
|
if(cur) {
|
||||||
rw->chars[i] = s[i];
|
for (int i = 0; i < cur; i++)
|
||||||
|
rw->chars[i] = s[i];
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = cur + 1; i < rw->size + 1; i++)
|
for (int i = cur; i < rw->size + 1; i++)
|
||||||
rw->chars[i - 1] = s[i];
|
rw->chars[i] = s[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
free(s);
|
free(s);
|
||||||
updateRender(rw);
|
updateRender(rw);
|
||||||
t.cur.x--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------- file operations --------------------------- */
|
/* ----------------------------- file operations --------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user