Only accept c for highlight, more keywords and update readme for cat mode

This commit is contained in:
Night Kaly 2025-02-09 23:21:35 +00:00
parent 8541312ec0
commit 3fed4d81c8
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
3 changed files with 13 additions and 3 deletions

View file

@ -5,7 +5,7 @@ It has colorful syntax highlighting and integrate with [ccc](https://github.com/
# Usage
```sh
vip -c file # Cat mode
vip -c file # Cat(1) mode with syntax highlighting
vip file
```

View file

@ -119,7 +119,7 @@ language_t langs[] = {
"//",
"/*",
"*/",
{ "const", "switch", "if", "while", "for", "break", "continue", "return", "else", "struct", "union", "typedef", "static", "enum", "case", "sizeof", "#include", "#define", "#if", "#elseif", "#endif", "int|", "long|", "double|", "float|", "char|", "unsigned|", "void|", "size_t|", "uint8_t|", NULL },
{ "const", "default", "switch", "if", "while", "for", "break", "continue", "return", "else", "struct", "union", "typedef", "static", "enum", "case", "sizeof", "#include", "#define", "#if", "#elseif", "#endif", "int|", "short|", "long|", "double|", "float|", "char|", "unsigned|", "void|", "size_t|", "uint8_t|", NULL },
{ ".c", ".h", ".cpp", NULL },
},
};

12
vip.c
View file

@ -782,12 +782,22 @@ int is_symbol(int c)
}
void update_highlight(row_t *row)
{
{
row->hl = realloc(row->hl, row->render_size);
memset(row->hl, NORMAL, row->render_size);
if (cur_editor->syntax == NULL) return;
if (strcmp(cur_editor->syntax->filetype, "c")) return;
// diff
// --- YELLOW
// +++ PEACH
// @@ OVERLAY0
// index TEAL
// diff BLUE
// + GREEN
// - RED
char **keywords = cur_editor->syntax->keywords;
char *scs = cur_editor->syntax->singleline_comment_start;