white theme and tab highlight
This commit is contained in:
parent
51fe76b5e8
commit
bf170a02ce
4
Makefile
4
Makefile
@ -1,7 +1,7 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-Wall -Wextra -pedantic -Werror
|
CFLAGS=-Wall -Wextra -pedantic -Werror
|
||||||
OFLAGS=-O3
|
OFLAGS=-O3
|
||||||
LFLAGS=-lncurses
|
LFLAGS=-lncursesw
|
||||||
|
|
||||||
ste: ste.c
|
ste: ste.c
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^
|
$(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^
|
||||||
|
31
ste.c
31
ste.c
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
/* defines */
|
/* defines */
|
||||||
#define CTRL(k) ((k) & 0x1f) // Control mask modifier
|
#define CTRL(k) ((k) & 0x1f) // Control mask modifier
|
||||||
#define TABSIZE 4 // Tab size as used in render
|
#define TABSIZE 8 // Tab size as used in render
|
||||||
|
|
||||||
/* main data structure containing:
|
/* main data structure containing:
|
||||||
* -cursor position
|
* -cursor position
|
||||||
@ -154,7 +154,11 @@ void termInit (void)
|
|||||||
|
|
||||||
/* Start color mode */
|
/* Start color mode */
|
||||||
start_color();
|
start_color();
|
||||||
init_pair(1, COLOR_BLUE, COLOR_BLACK);
|
init_pair(2, COLOR_BLACK, COLOR_CYAN);
|
||||||
|
init_pair(1, COLOR_BLACK, COLOR_WHITE);
|
||||||
|
|
||||||
|
/* Set default color */
|
||||||
|
bkgd(COLOR_PAIR(1));
|
||||||
|
|
||||||
/* Populate the main data structure */
|
/* Populate the main data structure */
|
||||||
getmaxyx(stdscr, t.dim.y, t.dim.x);
|
getmaxyx(stdscr, t.dim.y, t.dim.x);
|
||||||
@ -187,6 +191,7 @@ void termExit (void)
|
|||||||
|
|
||||||
void termDie (char *s)
|
void termDie (char *s)
|
||||||
{
|
{
|
||||||
|
erase();
|
||||||
refresh();
|
refresh();
|
||||||
endwin();
|
endwin();
|
||||||
perror(s);
|
perror(s);
|
||||||
@ -223,15 +228,20 @@ void drawLines (void)
|
|||||||
ln = i + t.cur.off_y;
|
ln = i + t.cur.off_y;
|
||||||
|
|
||||||
/* Draw the line number */
|
/* Draw the line number */
|
||||||
attron(COLOR_PAIR(1));
|
attron(COLOR_PAIR(2));
|
||||||
mvprintw(i, 0, "%d", ln + 1);
|
mvprintw(i, 0, "%d", ln + 1);
|
||||||
attroff(COLOR_PAIR(1));
|
attroff(COLOR_PAIR(2));
|
||||||
lnMove(i, 0);
|
lnMove(i, 0);
|
||||||
|
|
||||||
|
if (ln == t.cur.y + t.cur.off_y) attron(COLOR_PAIR(2));
|
||||||
|
|
||||||
/* Draw the line matcing render memory */
|
/* Draw the line matcing render memory */
|
||||||
if (rows.rw[ln].r_size >= t.cur.off_x) {
|
if (rows.rw[ln].r_size >= t.cur.off_x) {
|
||||||
addnstr(&rows.rw[ln].render[t.cur.off_x], t.dim.x + 1 - rows.rw[ln].delta);
|
addnstr(&rows.rw[ln].render[t.cur.off_x], t.dim.x + 1 - rows.rw[ln].delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attroff(COLOR_PAIR(2));
|
||||||
|
|
||||||
lnMove(++line, 0);
|
lnMove(++line, 0);
|
||||||
}
|
}
|
||||||
lnMove(t.cur.y, t.cur.x);
|
lnMove(t.cur.y, t.cur.x);
|
||||||
@ -258,7 +268,7 @@ void drawBar (char *s)
|
|||||||
mvaddch(t.dim.y, i, ' ');
|
mvaddch(t.dim.y, i, ' ');
|
||||||
|
|
||||||
char m[10];
|
char m[10];
|
||||||
sprintf(m, "Zoom:\t%c", whatsThat());
|
sprintf(m, "Zoom: %c", 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 */
|
||||||
@ -340,8 +350,10 @@ void updateRender (row *rw)
|
|||||||
int off = 0;
|
int off = 0;
|
||||||
for (i = 0; i < rw->size; i++) {
|
for (i = 0; i < rw->size; i++) {
|
||||||
if (rw->chars[i] == '\t') {
|
if (rw->chars[i] == '\t') {
|
||||||
for (int j = 0; j < TABSIZE; j++)
|
for (int j = 0; j < TABSIZE; j++){
|
||||||
rw->render[off++] = ' ';
|
if (!j) rw->render[off++] = '|';
|
||||||
|
else rw->render[off++] = ' ';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rw->render[off++] = rw->chars[i];
|
rw->render[off++] = rw->chars[i];
|
||||||
}
|
}
|
||||||
@ -457,6 +469,9 @@ int whatsThat (void) {
|
|||||||
case (' '):
|
case (' '):
|
||||||
return '~';
|
return '~';
|
||||||
break;
|
break;
|
||||||
|
case ('\0'):
|
||||||
|
return '.';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return c;
|
return c;
|
||||||
break;
|
break;
|
||||||
@ -473,4 +488,4 @@ void updateInfo (void)
|
|||||||
t.dim.x -= t.pad + 1;
|
t.dim.x -= t.pad + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------- testing ------------------------------------*/
|
/*--------------------------------- testing ------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user