MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

global highlight state

+10 -9
+3 -1
include/highlight.h
··· 18 18 int template_depth; 19 19 } highlight_state; 20 20 21 + #define HL_STATE_INIT ((highlight_state){ .mode = HL_STATE_NORMAL, .template_depth = 0 }) 22 + 21 23 typedef enum { 22 24 HL_NONE, 23 25 HL_KEYWORD, ··· 68 70 void hl_iter_init(hl_iter *it, const char *input, size_t input_len, const highlight_state *state); 69 71 bool hl_iter_next(hl_iter *it, hl_span *out); 70 72 71 - int ant_highlighl( 73 + int ant_highlight( 72 74 const char *input, size_t input_len, 73 75 char *out, size_t out_size 74 76 );
+1 -1
src/errors.c
··· 479 479 int src_cols_limit = error_context_src_cols_limit(gutter_w); 480 480 481 481 char tagged[4096]; char rendered[8192]; 482 - highlight_state hl_state = { .mode = HL_STATE_NORMAL, .template_depth = 0 }; 482 + highlight_state hl_state = HL_STATE_INIT; 483 483 484 484 jsoff_t cur = ctx_start; 485 485 int line_no = first_line_no;
+3 -3
src/highlight.c
··· 96 96 it->input = input; 97 97 it->input_len = input_len; 98 98 it->pos = 0; 99 - it->state = state ? *state : (highlight_state){ .mode = HL_STATE_NORMAL, .template_depth = 0 }; 99 + it->state = state ? *state : HL_STATE_INIT; 100 100 it->ctx = HL_CTX_NONE; 101 101 } 102 102 ··· 479 479 return (int)o.pos; 480 480 } 481 481 482 - int ant_highlighl(const char *input, size_t input_len, char *out, size_t out_size) { 483 - highlight_state state = { .mode = HL_STATE_NORMAL, .template_depth = 0 }; 482 + int ant_highlight(const char *input, size_t input_len, char *out, size_t out_size) { 483 + highlight_state state = HL_STATE_INIT; 484 484 return ant_highlight_stateful(input, input_len, out, out_size, &state); 485 485 } 486 486
+3 -4
src/repl.c
··· 533 533 typedef void (*key_handler_t)(INPUT); 534 534 535 535 static crprintf_compiled *hl_prog = NULL; 536 - static highlight_state hl_line_state = { .mode = HL_STATE_NORMAL, .template_depth = 0 }; 536 + static highlight_state hl_line_state = HL_STATE_INIT; 537 537 538 538 static void refresh_line(const char *line, int len, int pos, const char *prompt) { 539 539 fputs("\r\033[2K", stdout); ··· 811 811 812 812 if (multiline_buf && multiline_len > 0) { 813 813 char scratch[8192]; 814 - // TODO: dry 815 - hl_line_state = (highlight_state){ .mode = HL_STATE_NORMAL, .template_depth = 0 }; 814 + hl_line_state = HL_STATE_INIT; 816 815 ant_highlight_stateful(multiline_buf, multiline_len, scratch, sizeof(scratch), &hl_line_state); 817 - } else hl_line_state = (highlight_state){ .mode = HL_STATE_NORMAL, .template_depth = 0 }; 816 + } else hl_line_state = HL_STATE_INIT; 818 817 819 818 fputs(prompt, stdout); 820 819 fflush(stdout);