Adds color changes by mode to the bottom bar
This commit is contained in:
parent
5e1444cf36
commit
b05044b215
8
config.h
8
config.h
|
@ -21,3 +21,11 @@ static const int HL_COMMENT_COLOR = 243;
|
|||
static const int HL_KEYWORD1_COLOR = 69;
|
||||
static const int HL_KEYWORD2_COLOR = 167;
|
||||
static const int HL_DEFAULT_COLOR = 229;
|
||||
|
||||
static const int BAR_BG_COMMAND = 229;
|
||||
static const int BAR_FG_COMMAND = 235;
|
||||
static const int BAR_BG_INPUT = 121;
|
||||
static const int BAR_FG_INPUT = 235;
|
||||
static const int BAR_BG_VISUAL = 171;
|
||||
static const int BAR_FG_VISUAL = 235;
|
||||
|
||||
|
|
19
hermes.c
19
hermes.c
|
@ -784,26 +784,32 @@ void editorDrawRows(struct abuf *ab) {
|
|||
|
||||
void editorDrawStatusBar(struct abuf *ab) {
|
||||
char bgcolor[16];
|
||||
int bglen = sprintf(bgcolor, "\033[48;5;%dm", EDITOR_BG_COLOR);
|
||||
int bglen;
|
||||
char fgcolor[16];
|
||||
int fglen = snprintf(fgcolor, sizeof(fgcolor), "\033[38;5;%dm", HL_DEFAULT_COLOR);
|
||||
abAppend(ab, fgcolor, fglen);
|
||||
abAppend(ab, bgcolor, bglen);
|
||||
abAppend(ab, "\033[7m", 4);
|
||||
int fglen;
|
||||
char status[80], rstatus[80];
|
||||
|
||||
char *editorMode;
|
||||
switch (E.mode) {
|
||||
case CommandMode:
|
||||
editorMode = "Command";
|
||||
bglen = sprintf(bgcolor, "\033[48;5;%dm", BAR_BG_COMMAND);
|
||||
fglen = snprintf(fgcolor, sizeof(fgcolor), "\033[38;5;%dm", BAR_FG_COMMAND);
|
||||
break;
|
||||
case InputMode:
|
||||
editorMode = "Input";
|
||||
bglen = sprintf(bgcolor, "\033[48;5;%dm", BAR_BG_INPUT);
|
||||
fglen = snprintf(fgcolor, sizeof(fgcolor), "\033[38;5;%dm", BAR_FG_INPUT);
|
||||
break;
|
||||
case VisualMode:
|
||||
editorMode = "Visual";
|
||||
bglen = sprintf(bgcolor, "\033[48;5;%dm", BAR_BG_VISUAL);
|
||||
fglen = snprintf(fgcolor, sizeof(fgcolor), "\033[38;5;%dm", BAR_FG_VISUAL);
|
||||
break;
|
||||
}
|
||||
|
||||
abAppend(ab, fgcolor, fglen);
|
||||
abAppend(ab, bgcolor, bglen);
|
||||
|
||||
int len = snprintf(status, sizeof(status), "%.20s - %d lines %s",
|
||||
E.filename ? E.filename : "[Unnamed]", E.numRows, E.unsaved ? "(modified)" : "");
|
||||
|
@ -821,7 +827,10 @@ void editorDrawStatusBar(struct abuf *ab) {
|
|||
}
|
||||
}
|
||||
abAppend(ab, "\033[m", 4);
|
||||
bglen = sprintf(bgcolor, "\033[48;5;%dm", EDITOR_BG_COLOR);
|
||||
fglen = snprintf(fgcolor, sizeof(fgcolor), "\033[38;5;%dm", HL_DEFAULT_COLOR);
|
||||
abAppend(ab, bgcolor, bglen);
|
||||
abAppend(ab, fgcolor, fglen);
|
||||
abAppend(ab, "\r\n", 2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue