new std hi groups; terribly named constructor for them
This commit is contained in:
parent
07ae27b825
commit
7e432b4b63
11
source/hl.h
11
source/hl.h
@ -260,9 +260,14 @@ void render_string(const char * const string,
|
||||
// -------------------------
|
||||
// ### Library Mangement ###
|
||||
// -------------------------
|
||||
hl_group_t * keyword_hl = NULL;
|
||||
hl_group_t * preprocessor_hl = NULL;
|
||||
hl_group_t * symbol_hl = NULL;
|
||||
hl_group_t * special_hl = NULL;
|
||||
hl_group_t * control_hl = NULL;
|
||||
hl_group_t * keyword_hl = NULL;
|
||||
hl_group_t * block_hl = NULL;
|
||||
hl_group_t * separator_hl = NULL;
|
||||
hl_group_t * operator_hl = NULL;
|
||||
hl_group_t * comment_hl = NULL;
|
||||
hl_group_t * string_literal_hl = NULL;
|
||||
|
||||
int hl_init(void) {
|
||||
return 0;
|
||||
|
@ -17,8 +17,12 @@ void cterm_render_callback(const char * const string,
|
||||
}
|
||||
|
||||
terminal_hl_t * term_hl = (terminal_hl_t*)attributes;
|
||||
fputs(term_hl->attribute, stdout);
|
||||
fputs(term_hl->foreground_color, stdout);
|
||||
if (term_hl->attribute) {
|
||||
fputs(term_hl->attribute, stdout);
|
||||
}
|
||||
if (term_hl->foreground_color) {
|
||||
fputs(term_hl->foreground_color, stdout);
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
putchar(*(string+i));
|
||||
}
|
||||
@ -30,34 +34,28 @@ display_t * cterm = &(display_t) {
|
||||
.callback = cterm_render_callback
|
||||
};
|
||||
|
||||
void fun(const char * const attribute,
|
||||
const char * const color,
|
||||
hl_group_t * * group){
|
||||
terminal_hl_t * t = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
|
||||
t->attribute = attribute;
|
||||
t->foreground_color = color;;
|
||||
t->background_color = NULL;
|
||||
(*group) = (hl_group_t *)malloc(sizeof(hl_group_t));
|
||||
(*group)->link = NULL;
|
||||
(*group)->attributes = (void*)t;
|
||||
}
|
||||
|
||||
int terminal_hl_init(void){
|
||||
hl_init();
|
||||
new_display_mode(cterm);
|
||||
//
|
||||
terminal_hl_t * terminal_keyword_hl = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
|
||||
terminal_keyword_hl->attribute = TERMINAL_STYLE_BOLD;
|
||||
terminal_keyword_hl->foreground_color = TERMINAL_COLOR_FG_GREEN;;
|
||||
terminal_keyword_hl->background_color = NULL;
|
||||
keyword_hl = (hl_group_t *)malloc(sizeof(hl_group_t));
|
||||
keyword_hl->link = NULL;
|
||||
keyword_hl->attributes = (void*)terminal_keyword_hl;
|
||||
//
|
||||
terminal_hl_t * terminal_preprocessor_hl = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
|
||||
terminal_preprocessor_hl->attribute = TERMINAL_STYLE_BOLD;
|
||||
terminal_preprocessor_hl->foreground_color = TERMINAL_COLOR_FG_BLUE;
|
||||
terminal_preprocessor_hl->background_color = NULL;
|
||||
preprocessor_hl = (hl_group_t *)malloc(sizeof(hl_group_t));
|
||||
preprocessor_hl->link = NULL;
|
||||
preprocessor_hl->attributes = (void*)terminal_keyword_hl;
|
||||
//
|
||||
terminal_hl_t * terminal_symbol_hl = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
|
||||
terminal_symbol_hl->attribute = TERMINAL_STYLE_BOLD;
|
||||
terminal_symbol_hl->foreground_color = TERMINAL_COLOR_FG_YELLOW;
|
||||
terminal_symbol_hl->background_color = NULL;
|
||||
symbol_hl = (hl_group_t *)malloc(sizeof(hl_group_t));
|
||||
symbol_hl->link = NULL;
|
||||
symbol_hl->attributes = (void*)terminal_symbol_hl;
|
||||
fun(TERMINAL_STYLE_BOLD, TERMINAL_COLOR_FG_CYAN, &special_hl);
|
||||
fun(TERMINAL_STYLE_BOLD, TERMINAL_COLOR_FG_YELLOW, &control_hl);
|
||||
fun(NULL, TERMINAL_COLOR_FG_YELLOW, &operator_hl);
|
||||
fun(TERMINAL_STYLE_BOLD, TERMINAL_COLOR_FG_GREEN, &keyword_hl);
|
||||
fun(TERMINAL_STYLE_BOLD, TERMINAL_COLOR_FG_BLUE, &comment_hl);
|
||||
fun(TERMINAL_STYLE_BOLD, TERMINAL_COLOR_FG_RED, &string_literal_hl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user