white theme and tab highlight

master
ElectricAlchemist 5 years ago
parent 51fe76b5e8
commit bf170a02ce
  1. 4
      Makefile
  2. 5
      hello
  3. BIN
      ste
  4. 31
      ste.c

@ -1,7 +1,7 @@
CC=gcc
CFLAGS=-Wall -Wextra -pedantic -Werror
OFLAGS=-O3
LFLAGS=-lncurses
LFLAGS=-lncursesw
ste: ste.c
$(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^
$(CC) $(CFLAGS) $(OFLAGS) $(LFLAGS) -o ste $^

@ -1 +1,6 @@
hello world
hello
hello
hello
hello
hello

BIN
ste

Binary file not shown.

31
ste.c

@ -4,7 +4,7 @@
/* defines */
#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:
* -cursor position
@ -154,7 +154,11 @@ void termInit (void)
/* Start color mode */
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 */
getmaxyx(stdscr, t.dim.y, t.dim.x);
@ -187,6 +191,7 @@ void termExit (void)
void termDie (char *s)
{
erase();
refresh();
endwin();
perror(s);
@ -223,15 +228,20 @@ void drawLines (void)
ln = i + t.cur.off_y;
/* Draw the line number */
attron(COLOR_PAIR(1));
attron(COLOR_PAIR(2));
mvprintw(i, 0, "%d", ln + 1);
attroff(COLOR_PAIR(1));
attroff(COLOR_PAIR(2));
lnMove(i, 0);
if (ln == t.cur.y + t.cur.off_y) attron(COLOR_PAIR(2));
/* Draw the line matcing render memory */
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);
}
attroff(COLOR_PAIR(2));
lnMove(++line, 0);
}
lnMove(t.cur.y, t.cur.x);
@ -258,7 +268,7 @@ void drawBar (char *s)
mvaddch(t.dim.y, i, ' ');
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);
/* Return to normal contrast mode */
@ -340,8 +350,10 @@ void updateRender (row *rw)
int off = 0;
for (i = 0; i < rw->size; i++) {
if (rw->chars[i] == '\t') {
for (int j = 0; j < TABSIZE; j++)
rw->render[off++] = ' ';
for (int j = 0; j < TABSIZE; j++){
if (!j) rw->render[off++] = '|';
else rw->render[off++] = ' ';
}
} else {
rw->render[off++] = rw->chars[i];
}
@ -457,6 +469,9 @@ int whatsThat (void) {
case (' '):
return '~';
break;
case ('\0'):
return '.';
break;
default:
return c;
break;
@ -473,4 +488,4 @@ void updateInfo (void)
t.dim.x -= t.pad + 1;
}
/*--------------------------------- testing ------------------------------------*/
/*--------------------------------- testing ------------------------------------*/

Loading…
Cancel
Save