#include "hl.h" typedef struct { char * attribute; char * foreground_color; char * background_color; } terminal_hl_t; void cterm_render_callback(const char * const string, const int length, void * const attributes) { if(!length){ fputs(TERMINAL_STYLE_BOLD, stdout); putchar(*string); fputs(TERMINAL_RESET, stdout); return; } terminal_hl_t * term_hl = (terminal_hl_t*)attributes; fputs(term_hl->attribute, stdout); fputs(term_hl->foreground_color, stdout); for (int i = 0; i < length; i++) { putchar(*(string+i)); } fputs(TERMINAL_RESET, stdout); } display_t * cterm = &(display_t) { .key = "cterm", .callback = cterm_render_callback }; int terminal_hl_init(void){ hl_init(); new_display_mode(cterm); // terminal_hl_t terminal_keyword_hl = (terminal_hl_t) { .attribute = TERMINAL_STYLE_BOLD, .foreground_color = TERMINAL_COLOR_FG_GREEN, .background_color = NULL }; keyword_hl = &(hl_group_t) { .link = NULL, .attributes = (void*)&terminal_keyword_hl }; // terminal_hl_t terminal_preprocessor_hl = (terminal_hl_t) { .attribute = TERMINAL_STYLE_BOLD, .foreground_color = TERMINAL_COLOR_FG_BLUE, .background_color = NULL }; preprocessor_hl = &(hl_group_t) { .link = NULL, .attributes = (void*)&terminal_preprocessor_hl }; // terminal_hl_t terminal_symbol_hl = (terminal_hl_t) { .attribute = TERMINAL_STYLE_BOLD, .foreground_color = TERMINAL_COLOR_FG_YELLOW, .background_color = NULL }; symbol_hl = &(hl_group_t) { .link = NULL, .attributes = (void*)&terminal_symbol_hl }; return 0; }