Highlight char
This commit is contained in:
parent
f520b71657
commit
a00669be81
2 changed files with 28 additions and 0 deletions
3
config.h
3
config.h
|
@ -24,6 +24,8 @@
|
|||
#define YELLOW_BG "\033[38;2;249;226;175m"
|
||||
#define RED_FG "\033[48;2;243;139;168m"
|
||||
#define RED_BG "\033[38;2;243;139;168m"
|
||||
#define TEAL_FG "\033[48;2;148;226;213m"
|
||||
#define TEAL_BG "\033[38;2;148;226;213m"
|
||||
|
||||
/* ERROR is red with bold and italic */
|
||||
#define ERROR "\033[38;2;243;139;168m\033[1m\033[3m"
|
||||
|
@ -58,6 +60,7 @@ enum highlight {
|
|||
KW_FN,
|
||||
KW_BRACKET,
|
||||
STRING,
|
||||
CHAR,
|
||||
NUMBER,
|
||||
MATCH,
|
||||
RESET
|
||||
|
|
25
vip.c
25
vip.c
|
@ -595,6 +595,10 @@ void draw_rows(void)
|
|||
bprintf(GREEN_BG);
|
||||
break;
|
||||
|
||||
case CHAR:
|
||||
bprintf(TEAL_BG);
|
||||
break;
|
||||
|
||||
case SYMBOL:
|
||||
bprintf(SKY_BG);
|
||||
break;
|
||||
|
@ -772,6 +776,7 @@ void update_highlight(row_t *row)
|
|||
|
||||
int prev_sep = 1;
|
||||
int in_string = 0;
|
||||
int in_char = 0;
|
||||
int in_include = 0;
|
||||
int in_comment = row->idx > 0 && cur_editor->row[row->idx - 1].opened_comment;
|
||||
|
||||
|
@ -828,6 +833,26 @@ void update_highlight(row_t *row)
|
|||
}
|
||||
}
|
||||
|
||||
if (in_char) {
|
||||
row->hl[i] = CHAR;
|
||||
if (c == '\\' && i + 1 < row->render_size) {
|
||||
row->hl[i + 1] = CHAR;
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if (c == in_char) in_char = 0;
|
||||
i++;
|
||||
prev_sep = 1;
|
||||
continue;
|
||||
} else {
|
||||
if (c == '\'') {
|
||||
in_char = c;
|
||||
row->hl[i] = CHAR;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_include) {
|
||||
row->hl[i] = STRING;
|
||||
if (c == '>') in_include = 0;
|
||||
|
|
Loading…
Reference in a new issue