diff --git a/config.h b/config.h index 4480b36..ac1e25a 100644 --- a/config.h +++ b/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 diff --git a/vip.c b/vip.c index c8655f4..ca2311a 100644 --- a/vip.c +++ b/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; @@ -827,6 +832,26 @@ void update_highlight(row_t *row) continue; } } + + 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;