From b39e98f7e8a340bb5777029b05fc84b2b5ba6c08 Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 6 Jul 2023 18:00:14 -0400 Subject: TODO highlighting in single-line comments, more js keywords --- control | 2 +- keywords.h | 59 ++++++++++++++++++++++++++++++++--------------------------- keywords.py | 18 +++++++++++++----- main.c | 3 --- syntax.c | 41 +++++++++++++++++++++++++++++------------ ted.h | 2 +- 6 files changed, 76 insertions(+), 49 deletions(-) diff --git a/control b/control index af26cb6..fa21f96 100644 --- a/control +++ b/control @@ -1,5 +1,5 @@ Package: ted -Version: 2.3.2 +Version: 2.3.3 Section: text Priority: optional Architecture: amd64 diff --git a/keywords.h b/keywords.h index fae4a16..faf190e 100644 --- a/keywords.h +++ b/keywords.h @@ -154,26 +154,29 @@ static const Keyword syntax_keywords_javascript_S[5] = {{"Set", SYNTAX_BUILTIN}, static const Keyword syntax_keywords_javascript_T[2] = {{"TypeError", SYNTAX_BUILTIN},{"TypedArray", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_javascript_U[5] = {{"URIError", SYNTAX_BUILTIN},{"Uint16Array", SYNTAX_BUILTIN},{"Uint32Array", SYNTAX_BUILTIN},{"Uint8Array", SYNTAX_BUILTIN},{"Uint8ClampedArray", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_javascript_W[4] = {{"WeakMap", SYNTAX_BUILTIN},{"WeakRef", SYNTAX_BUILTIN},{"WeakSet", SYNTAX_BUILTIN},{"WebAssembly", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_javascript_a[1] = {{"await", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_a[3] = {{"arguments", SYNTAX_BUILTIN},{"async", SYNTAX_KEYWORD},{"await", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_javascript_b[1] = {{"break", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_c[5] = {{"case", SYNTAX_KEYWORD},{"catch", SYNTAX_KEYWORD},{"class", SYNTAX_KEYWORD},{"const", SYNTAX_KEYWORD},{"continue", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_d[6] = {{"debugger", SYNTAX_KEYWORD},{"decodeURI", SYNTAX_BUILTIN},{"decodeURIComponent", SYNTAX_BUILTIN},{"default", SYNTAX_KEYWORD},{"delete", SYNTAX_KEYWORD},{"do", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_c[7] = {{"case", SYNTAX_KEYWORD},{"catch", SYNTAX_KEYWORD},{"class", SYNTAX_KEYWORD},{"console", SYNTAX_BUILTIN},{"const", SYNTAX_KEYWORD},{"continue", SYNTAX_KEYWORD},{"customElements", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_d[8] = {{"debugger", SYNTAX_KEYWORD},{"decodeURI", SYNTAX_BUILTIN},{"decodeURIComponent", SYNTAX_BUILTIN},{"default", SYNTAX_KEYWORD},{"delete", SYNTAX_KEYWORD},{"devicePixelRatio", SYNTAX_BUILTIN},{"do", SYNTAX_KEYWORD},{"document", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_javascript_e[6] = {{"else", SYNTAX_KEYWORD},{"encodeURI", SYNTAX_BUILTIN},{"encodeURIComponent", SYNTAX_BUILTIN},{"eval", SYNTAX_BUILTIN},{"export", SYNTAX_KEYWORD},{"extends", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_f[4] = {{"false", SYNTAX_CONSTANT},{"finally", SYNTAX_KEYWORD},{"for", SYNTAX_KEYWORD},{"function", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_f[6] = {{"false", SYNTAX_CONSTANT},{"finally", SYNTAX_KEYWORD},{"for", SYNTAX_KEYWORD},{"frameElement", SYNTAX_BUILTIN},{"frames", SYNTAX_BUILTIN},{"function", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_javascript_g[1] = {{"globalThis", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_javascript_i[6] = {{"if", SYNTAX_KEYWORD},{"import", SYNTAX_KEYWORD},{"in", SYNTAX_KEYWORD},{"instanceof", SYNTAX_KEYWORD},{"isFinite", SYNTAX_BUILTIN},{"isNaN", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_javascript_l[1] = {{"let", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_n[2] = {{"new", SYNTAX_KEYWORD},{"null", SYNTAX_CONSTANT}}; -static const Keyword syntax_keywords_javascript_p[2] = {{"parseFloat", SYNTAX_BUILTIN},{"parseInt", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_h[1] = {{"history", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_i[8] = {{"if", SYNTAX_KEYWORD},{"import", SYNTAX_KEYWORD},{"in", SYNTAX_KEYWORD},{"innerHeight", SYNTAX_BUILTIN},{"innerWidth", SYNTAX_BUILTIN},{"instanceof", SYNTAX_KEYWORD},{"isFinite", SYNTAX_BUILTIN},{"isNaN", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_l[5] = {{"length", SYNTAX_BUILTIN},{"let", SYNTAX_KEYWORD},{"localStorage", SYNTAX_BUILTIN},{"location", SYNTAX_BUILTIN},{"locationbar", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_m[1] = {{"menubar", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_n[4] = {{"name", SYNTAX_BUILTIN},{"navigator", SYNTAX_BUILTIN},{"new", SYNTAX_KEYWORD},{"null", SYNTAX_CONSTANT}}; +static const Keyword syntax_keywords_javascript_o[4] = {{"of", SYNTAX_KEYWORD},{"opener", SYNTAX_BUILTIN},{"outerHeight", SYNTAX_BUILTIN},{"outerWidth", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_javascript_p[6] = {{"pageXOffset", SYNTAX_BUILTIN},{"pageYOffset", SYNTAX_BUILTIN},{"parent", SYNTAX_BUILTIN},{"parseFloat", SYNTAX_BUILTIN},{"parseInt", SYNTAX_BUILTIN},{"personalbar", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_javascript_r[1] = {{"return", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_s[2] = {{"super", SYNTAX_KEYWORD},{"switch", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_t[5] = {{"this", SYNTAX_KEYWORD},{"throw", SYNTAX_KEYWORD},{"true", SYNTAX_CONSTANT},{"try", SYNTAX_KEYWORD},{"typeof", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_s[15] = {{"scheduler", SYNTAX_BUILTIN},{"screen", SYNTAX_BUILTIN},{"screenLeft", SYNTAX_BUILTIN},{"screenTop", SYNTAX_BUILTIN},{"screenX", SYNTAX_BUILTIN},{"screenY", SYNTAX_BUILTIN},{"scrollX", SYNTAX_BUILTIN},{"scrollY", SYNTAX_BUILTIN},{"scrollbars", SYNTAX_BUILTIN},{"self", SYNTAX_BUILTIN},{"sessionStorage", SYNTAX_BUILTIN},{"speechSynthesis", SYNTAX_BUILTIN},{"statusbar", SYNTAX_BUILTIN},{"super", SYNTAX_KEYWORD},{"switch", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_t[7] = {{"this", SYNTAX_KEYWORD},{"throw", SYNTAX_KEYWORD},{"toolbar", SYNTAX_BUILTIN},{"top", SYNTAX_BUILTIN},{"true", SYNTAX_CONSTANT},{"try", SYNTAX_KEYWORD},{"typeof", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_javascript_u[1] = {{"undefined", SYNTAX_CONSTANT}}; -static const Keyword syntax_keywords_javascript_v[2] = {{"var", SYNTAX_KEYWORD},{"void", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_javascript_w[2] = {{"while", SYNTAX_KEYWORD},{"with", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_v[3] = {{"var", SYNTAX_KEYWORD},{"visualViewport", SYNTAX_BUILTIN},{"void", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_javascript_w[3] = {{"while", SYNTAX_KEYWORD},{"window", SYNTAX_BUILTIN},{"with", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_javascript_y[1] = {{"yield", SYNTAX_KEYWORD}}; static const KeywordList syntax_all_keywords_javascript[128] = { - ['A'] = {syntax_keywords_javascript_A, arr_count(syntax_keywords_javascript_A)}, ['B'] = {syntax_keywords_javascript_B, arr_count(syntax_keywords_javascript_B)}, ['D'] = {syntax_keywords_javascript_D, arr_count(syntax_keywords_javascript_D)}, ['E'] = {syntax_keywords_javascript_E, arr_count(syntax_keywords_javascript_E)}, ['F'] = {syntax_keywords_javascript_F, arr_count(syntax_keywords_javascript_F)}, ['G'] = {syntax_keywords_javascript_G, arr_count(syntax_keywords_javascript_G)}, ['I'] = {syntax_keywords_javascript_I, arr_count(syntax_keywords_javascript_I)}, ['J'] = {syntax_keywords_javascript_J, arr_count(syntax_keywords_javascript_J)}, ['M'] = {syntax_keywords_javascript_M, arr_count(syntax_keywords_javascript_M)}, ['N'] = {syntax_keywords_javascript_N, arr_count(syntax_keywords_javascript_N)}, ['O'] = {syntax_keywords_javascript_O, arr_count(syntax_keywords_javascript_O)}, ['P'] = {syntax_keywords_javascript_P, arr_count(syntax_keywords_javascript_P)}, ['R'] = {syntax_keywords_javascript_R, arr_count(syntax_keywords_javascript_R)}, ['S'] = {syntax_keywords_javascript_S, arr_count(syntax_keywords_javascript_S)}, ['T'] = {syntax_keywords_javascript_T, arr_count(syntax_keywords_javascript_T)}, ['U'] = {syntax_keywords_javascript_U, arr_count(syntax_keywords_javascript_U)}, ['W'] = {syntax_keywords_javascript_W, arr_count(syntax_keywords_javascript_W)}, ['a'] = {syntax_keywords_javascript_a, arr_count(syntax_keywords_javascript_a)}, ['b'] = {syntax_keywords_javascript_b, arr_count(syntax_keywords_javascript_b)}, ['c'] = {syntax_keywords_javascript_c, arr_count(syntax_keywords_javascript_c)}, ['d'] = {syntax_keywords_javascript_d, arr_count(syntax_keywords_javascript_d)}, ['e'] = {syntax_keywords_javascript_e, arr_count(syntax_keywords_javascript_e)}, ['f'] = {syntax_keywords_javascript_f, arr_count(syntax_keywords_javascript_f)}, ['g'] = {syntax_keywords_javascript_g, arr_count(syntax_keywords_javascript_g)}, ['i'] = {syntax_keywords_javascript_i, arr_count(syntax_keywords_javascript_i)}, ['l'] = {syntax_keywords_javascript_l, arr_count(syntax_keywords_javascript_l)}, ['n'] = {syntax_keywords_javascript_n, arr_count(syntax_keywords_javascript_n)}, ['p'] = {syntax_keywords_javascript_p, arr_count(syntax_keywords_javascript_p)}, ['r'] = {syntax_keywords_javascript_r, arr_count(syntax_keywords_javascript_r)}, ['s'] = {syntax_keywords_javascript_s, arr_count(syntax_keywords_javascript_s)}, ['t'] = {syntax_keywords_javascript_t, arr_count(syntax_keywords_javascript_t)}, ['u'] = {syntax_keywords_javascript_u, arr_count(syntax_keywords_javascript_u)}, ['v'] = {syntax_keywords_javascript_v, arr_count(syntax_keywords_javascript_v)}, ['w'] = {syntax_keywords_javascript_w, arr_count(syntax_keywords_javascript_w)}, ['y'] = {syntax_keywords_javascript_y, arr_count(syntax_keywords_javascript_y)} + ['A'] = {syntax_keywords_javascript_A, arr_count(syntax_keywords_javascript_A)}, ['B'] = {syntax_keywords_javascript_B, arr_count(syntax_keywords_javascript_B)}, ['D'] = {syntax_keywords_javascript_D, arr_count(syntax_keywords_javascript_D)}, ['E'] = {syntax_keywords_javascript_E, arr_count(syntax_keywords_javascript_E)}, ['F'] = {syntax_keywords_javascript_F, arr_count(syntax_keywords_javascript_F)}, ['G'] = {syntax_keywords_javascript_G, arr_count(syntax_keywords_javascript_G)}, ['I'] = {syntax_keywords_javascript_I, arr_count(syntax_keywords_javascript_I)}, ['J'] = {syntax_keywords_javascript_J, arr_count(syntax_keywords_javascript_J)}, ['M'] = {syntax_keywords_javascript_M, arr_count(syntax_keywords_javascript_M)}, ['N'] = {syntax_keywords_javascript_N, arr_count(syntax_keywords_javascript_N)}, ['O'] = {syntax_keywords_javascript_O, arr_count(syntax_keywords_javascript_O)}, ['P'] = {syntax_keywords_javascript_P, arr_count(syntax_keywords_javascript_P)}, ['R'] = {syntax_keywords_javascript_R, arr_count(syntax_keywords_javascript_R)}, ['S'] = {syntax_keywords_javascript_S, arr_count(syntax_keywords_javascript_S)}, ['T'] = {syntax_keywords_javascript_T, arr_count(syntax_keywords_javascript_T)}, ['U'] = {syntax_keywords_javascript_U, arr_count(syntax_keywords_javascript_U)}, ['W'] = {syntax_keywords_javascript_W, arr_count(syntax_keywords_javascript_W)}, ['a'] = {syntax_keywords_javascript_a, arr_count(syntax_keywords_javascript_a)}, ['b'] = {syntax_keywords_javascript_b, arr_count(syntax_keywords_javascript_b)}, ['c'] = {syntax_keywords_javascript_c, arr_count(syntax_keywords_javascript_c)}, ['d'] = {syntax_keywords_javascript_d, arr_count(syntax_keywords_javascript_d)}, ['e'] = {syntax_keywords_javascript_e, arr_count(syntax_keywords_javascript_e)}, ['f'] = {syntax_keywords_javascript_f, arr_count(syntax_keywords_javascript_f)}, ['g'] = {syntax_keywords_javascript_g, arr_count(syntax_keywords_javascript_g)}, ['h'] = {syntax_keywords_javascript_h, arr_count(syntax_keywords_javascript_h)}, ['i'] = {syntax_keywords_javascript_i, arr_count(syntax_keywords_javascript_i)}, ['l'] = {syntax_keywords_javascript_l, arr_count(syntax_keywords_javascript_l)}, ['m'] = {syntax_keywords_javascript_m, arr_count(syntax_keywords_javascript_m)}, ['n'] = {syntax_keywords_javascript_n, arr_count(syntax_keywords_javascript_n)}, ['o'] = {syntax_keywords_javascript_o, arr_count(syntax_keywords_javascript_o)}, ['p'] = {syntax_keywords_javascript_p, arr_count(syntax_keywords_javascript_p)}, ['r'] = {syntax_keywords_javascript_r, arr_count(syntax_keywords_javascript_r)}, ['s'] = {syntax_keywords_javascript_s, arr_count(syntax_keywords_javascript_s)}, ['t'] = {syntax_keywords_javascript_t, arr_count(syntax_keywords_javascript_t)}, ['u'] = {syntax_keywords_javascript_u, arr_count(syntax_keywords_javascript_u)}, ['v'] = {syntax_keywords_javascript_v, arr_count(syntax_keywords_javascript_v)}, ['w'] = {syntax_keywords_javascript_w, arr_count(syntax_keywords_javascript_w)}, ['y'] = {syntax_keywords_javascript_y, arr_count(syntax_keywords_javascript_y)} }; static const Keyword syntax_keywords_json_f[1] = {{"false", SYNTAX_CONSTANT}}; @@ -200,27 +203,29 @@ static const Keyword syntax_keywords_typescript_S[5] = {{"Set", SYNTAX_BUILTIN}, static const Keyword syntax_keywords_typescript_T[2] = {{"TypeError", SYNTAX_BUILTIN},{"TypedArray", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_typescript_U[5] = {{"URIError", SYNTAX_BUILTIN},{"Uint16Array", SYNTAX_BUILTIN},{"Uint32Array", SYNTAX_BUILTIN},{"Uint8Array", SYNTAX_BUILTIN},{"Uint8ClampedArray", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_typescript_W[4] = {{"WeakMap", SYNTAX_BUILTIN},{"WeakRef", SYNTAX_BUILTIN},{"WeakSet", SYNTAX_BUILTIN},{"WebAssembly", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_typescript_a[3] = {{"any", SYNTAX_KEYWORD},{"as", SYNTAX_KEYWORD},{"await", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_a[5] = {{"any", SYNTAX_KEYWORD},{"arguments", SYNTAX_BUILTIN},{"as", SYNTAX_KEYWORD},{"async", SYNTAX_KEYWORD},{"await", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_typescript_b[1] = {{"break", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_c[5] = {{"case", SYNTAX_KEYWORD},{"catch", SYNTAX_KEYWORD},{"class", SYNTAX_KEYWORD},{"const", SYNTAX_KEYWORD},{"continue", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_d[6] = {{"debugger", SYNTAX_KEYWORD},{"decodeURI", SYNTAX_BUILTIN},{"decodeURIComponent", SYNTAX_BUILTIN},{"default", SYNTAX_KEYWORD},{"delete", SYNTAX_KEYWORD},{"do", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_c[7] = {{"case", SYNTAX_KEYWORD},{"catch", SYNTAX_KEYWORD},{"class", SYNTAX_KEYWORD},{"console", SYNTAX_BUILTIN},{"const", SYNTAX_KEYWORD},{"continue", SYNTAX_KEYWORD},{"customElements", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_typescript_d[8] = {{"debugger", SYNTAX_KEYWORD},{"decodeURI", SYNTAX_BUILTIN},{"decodeURIComponent", SYNTAX_BUILTIN},{"default", SYNTAX_KEYWORD},{"delete", SYNTAX_KEYWORD},{"devicePixelRatio", SYNTAX_BUILTIN},{"do", SYNTAX_KEYWORD},{"document", SYNTAX_BUILTIN}}; static const Keyword syntax_keywords_typescript_e[7] = {{"else", SYNTAX_KEYWORD},{"encodeURI", SYNTAX_BUILTIN},{"encodeURIComponent", SYNTAX_BUILTIN},{"enum", SYNTAX_KEYWORD},{"eval", SYNTAX_BUILTIN},{"export", SYNTAX_KEYWORD},{"extends", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_f[4] = {{"false", SYNTAX_CONSTANT},{"finally", SYNTAX_KEYWORD},{"for", SYNTAX_KEYWORD},{"function", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_f[6] = {{"false", SYNTAX_CONSTANT},{"finally", SYNTAX_KEYWORD},{"for", SYNTAX_KEYWORD},{"frameElement", SYNTAX_BUILTIN},{"frames", SYNTAX_BUILTIN},{"function", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_typescript_g[2] = {{"get", SYNTAX_BUILTIN},{"globalThis", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_typescript_i[8] = {{"if", SYNTAX_KEYWORD},{"implements", SYNTAX_KEYWORD},{"import", SYNTAX_KEYWORD},{"in", SYNTAX_KEYWORD},{"instanceof", SYNTAX_KEYWORD},{"interface", SYNTAX_KEYWORD},{"isFinite", SYNTAX_BUILTIN},{"isNaN", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_typescript_l[1] = {{"let", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_m[1] = {{"module", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_n[3] = {{"new", SYNTAX_KEYWORD},{"null", SYNTAX_CONSTANT},{"number", SYNTAX_BUILTIN}}; -static const Keyword syntax_keywords_typescript_p[5] = {{"package", SYNTAX_KEYWORD},{"parseFloat", SYNTAX_BUILTIN},{"parseInt", SYNTAX_BUILTIN},{"private", SYNTAX_KEYWORD},{"public", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_h[1] = {{"history", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_typescript_i[10] = {{"if", SYNTAX_KEYWORD},{"implements", SYNTAX_KEYWORD},{"import", SYNTAX_KEYWORD},{"in", SYNTAX_KEYWORD},{"innerHeight", SYNTAX_BUILTIN},{"innerWidth", SYNTAX_BUILTIN},{"instanceof", SYNTAX_KEYWORD},{"interface", SYNTAX_KEYWORD},{"isFinite", SYNTAX_BUILTIN},{"isNaN", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_typescript_l[5] = {{"length", SYNTAX_BUILTIN},{"let", SYNTAX_KEYWORD},{"localStorage", SYNTAX_BUILTIN},{"location", SYNTAX_BUILTIN},{"locationbar", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_typescript_m[2] = {{"menubar", SYNTAX_BUILTIN},{"module", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_n[5] = {{"name", SYNTAX_BUILTIN},{"navigator", SYNTAX_BUILTIN},{"new", SYNTAX_KEYWORD},{"null", SYNTAX_CONSTANT},{"number", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_typescript_o[4] = {{"of", SYNTAX_KEYWORD},{"opener", SYNTAX_BUILTIN},{"outerHeight", SYNTAX_BUILTIN},{"outerWidth", SYNTAX_BUILTIN}}; +static const Keyword syntax_keywords_typescript_p[9] = {{"package", SYNTAX_KEYWORD},{"pageXOffset", SYNTAX_BUILTIN},{"pageYOffset", SYNTAX_BUILTIN},{"parent", SYNTAX_BUILTIN},{"parseFloat", SYNTAX_BUILTIN},{"parseInt", SYNTAX_BUILTIN},{"personalbar", SYNTAX_BUILTIN},{"private", SYNTAX_KEYWORD},{"public", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_typescript_r[1] = {{"return", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_s[5] = {{"set", SYNTAX_BUILTIN},{"static", SYNTAX_KEYWORD},{"string", SYNTAX_BUILTIN},{"super", SYNTAX_KEYWORD},{"switch", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_t[6] = {{"this", SYNTAX_KEYWORD},{"throw", SYNTAX_KEYWORD},{"true", SYNTAX_CONSTANT},{"try", SYNTAX_KEYWORD},{"type", SYNTAX_KEYWORD},{"typeof", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_s[18] = {{"scheduler", SYNTAX_BUILTIN},{"screen", SYNTAX_BUILTIN},{"screenLeft", SYNTAX_BUILTIN},{"screenTop", SYNTAX_BUILTIN},{"screenX", SYNTAX_BUILTIN},{"screenY", SYNTAX_BUILTIN},{"scrollX", SYNTAX_BUILTIN},{"scrollY", SYNTAX_BUILTIN},{"scrollbars", SYNTAX_BUILTIN},{"self", SYNTAX_BUILTIN},{"sessionStorage", SYNTAX_BUILTIN},{"set", SYNTAX_BUILTIN},{"speechSynthesis", SYNTAX_BUILTIN},{"static", SYNTAX_KEYWORD},{"statusbar", SYNTAX_BUILTIN},{"string", SYNTAX_BUILTIN},{"super", SYNTAX_KEYWORD},{"switch", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_t[8] = {{"this", SYNTAX_KEYWORD},{"throw", SYNTAX_KEYWORD},{"toolbar", SYNTAX_BUILTIN},{"top", SYNTAX_BUILTIN},{"true", SYNTAX_CONSTANT},{"try", SYNTAX_KEYWORD},{"type", SYNTAX_KEYWORD},{"typeof", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_typescript_u[1] = {{"undefined", SYNTAX_CONSTANT}}; -static const Keyword syntax_keywords_typescript_v[2] = {{"var", SYNTAX_KEYWORD},{"void", SYNTAX_KEYWORD}}; -static const Keyword syntax_keywords_typescript_w[2] = {{"while", SYNTAX_KEYWORD},{"with", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_v[3] = {{"var", SYNTAX_KEYWORD},{"visualViewport", SYNTAX_BUILTIN},{"void", SYNTAX_KEYWORD}}; +static const Keyword syntax_keywords_typescript_w[3] = {{"while", SYNTAX_KEYWORD},{"window", SYNTAX_BUILTIN},{"with", SYNTAX_KEYWORD}}; static const Keyword syntax_keywords_typescript_y[1] = {{"yield", SYNTAX_KEYWORD}}; static const KeywordList syntax_all_keywords_typescript[128] = { - ['A'] = {syntax_keywords_typescript_A, arr_count(syntax_keywords_typescript_A)}, ['B'] = {syntax_keywords_typescript_B, arr_count(syntax_keywords_typescript_B)}, ['D'] = {syntax_keywords_typescript_D, arr_count(syntax_keywords_typescript_D)}, ['E'] = {syntax_keywords_typescript_E, arr_count(syntax_keywords_typescript_E)}, ['F'] = {syntax_keywords_typescript_F, arr_count(syntax_keywords_typescript_F)}, ['G'] = {syntax_keywords_typescript_G, arr_count(syntax_keywords_typescript_G)}, ['I'] = {syntax_keywords_typescript_I, arr_count(syntax_keywords_typescript_I)}, ['J'] = {syntax_keywords_typescript_J, arr_count(syntax_keywords_typescript_J)}, ['M'] = {syntax_keywords_typescript_M, arr_count(syntax_keywords_typescript_M)}, ['N'] = {syntax_keywords_typescript_N, arr_count(syntax_keywords_typescript_N)}, ['O'] = {syntax_keywords_typescript_O, arr_count(syntax_keywords_typescript_O)}, ['P'] = {syntax_keywords_typescript_P, arr_count(syntax_keywords_typescript_P)}, ['R'] = {syntax_keywords_typescript_R, arr_count(syntax_keywords_typescript_R)}, ['S'] = {syntax_keywords_typescript_S, arr_count(syntax_keywords_typescript_S)}, ['T'] = {syntax_keywords_typescript_T, arr_count(syntax_keywords_typescript_T)}, ['U'] = {syntax_keywords_typescript_U, arr_count(syntax_keywords_typescript_U)}, ['W'] = {syntax_keywords_typescript_W, arr_count(syntax_keywords_typescript_W)}, ['a'] = {syntax_keywords_typescript_a, arr_count(syntax_keywords_typescript_a)}, ['b'] = {syntax_keywords_typescript_b, arr_count(syntax_keywords_typescript_b)}, ['c'] = {syntax_keywords_typescript_c, arr_count(syntax_keywords_typescript_c)}, ['d'] = {syntax_keywords_typescript_d, arr_count(syntax_keywords_typescript_d)}, ['e'] = {syntax_keywords_typescript_e, arr_count(syntax_keywords_typescript_e)}, ['f'] = {syntax_keywords_typescript_f, arr_count(syntax_keywords_typescript_f)}, ['g'] = {syntax_keywords_typescript_g, arr_count(syntax_keywords_typescript_g)}, ['i'] = {syntax_keywords_typescript_i, arr_count(syntax_keywords_typescript_i)}, ['l'] = {syntax_keywords_typescript_l, arr_count(syntax_keywords_typescript_l)}, ['m'] = {syntax_keywords_typescript_m, arr_count(syntax_keywords_typescript_m)}, ['n'] = {syntax_keywords_typescript_n, arr_count(syntax_keywords_typescript_n)}, ['p'] = {syntax_keywords_typescript_p, arr_count(syntax_keywords_typescript_p)}, ['r'] = {syntax_keywords_typescript_r, arr_count(syntax_keywords_typescript_r)}, ['s'] = {syntax_keywords_typescript_s, arr_count(syntax_keywords_typescript_s)}, ['t'] = {syntax_keywords_typescript_t, arr_count(syntax_keywords_typescript_t)}, ['u'] = {syntax_keywords_typescript_u, arr_count(syntax_keywords_typescript_u)}, ['v'] = {syntax_keywords_typescript_v, arr_count(syntax_keywords_typescript_v)}, ['w'] = {syntax_keywords_typescript_w, arr_count(syntax_keywords_typescript_w)}, ['y'] = {syntax_keywords_typescript_y, arr_count(syntax_keywords_typescript_y)} + ['A'] = {syntax_keywords_typescript_A, arr_count(syntax_keywords_typescript_A)}, ['B'] = {syntax_keywords_typescript_B, arr_count(syntax_keywords_typescript_B)}, ['D'] = {syntax_keywords_typescript_D, arr_count(syntax_keywords_typescript_D)}, ['E'] = {syntax_keywords_typescript_E, arr_count(syntax_keywords_typescript_E)}, ['F'] = {syntax_keywords_typescript_F, arr_count(syntax_keywords_typescript_F)}, ['G'] = {syntax_keywords_typescript_G, arr_count(syntax_keywords_typescript_G)}, ['I'] = {syntax_keywords_typescript_I, arr_count(syntax_keywords_typescript_I)}, ['J'] = {syntax_keywords_typescript_J, arr_count(syntax_keywords_typescript_J)}, ['M'] = {syntax_keywords_typescript_M, arr_count(syntax_keywords_typescript_M)}, ['N'] = {syntax_keywords_typescript_N, arr_count(syntax_keywords_typescript_N)}, ['O'] = {syntax_keywords_typescript_O, arr_count(syntax_keywords_typescript_O)}, ['P'] = {syntax_keywords_typescript_P, arr_count(syntax_keywords_typescript_P)}, ['R'] = {syntax_keywords_typescript_R, arr_count(syntax_keywords_typescript_R)}, ['S'] = {syntax_keywords_typescript_S, arr_count(syntax_keywords_typescript_S)}, ['T'] = {syntax_keywords_typescript_T, arr_count(syntax_keywords_typescript_T)}, ['U'] = {syntax_keywords_typescript_U, arr_count(syntax_keywords_typescript_U)}, ['W'] = {syntax_keywords_typescript_W, arr_count(syntax_keywords_typescript_W)}, ['a'] = {syntax_keywords_typescript_a, arr_count(syntax_keywords_typescript_a)}, ['b'] = {syntax_keywords_typescript_b, arr_count(syntax_keywords_typescript_b)}, ['c'] = {syntax_keywords_typescript_c, arr_count(syntax_keywords_typescript_c)}, ['d'] = {syntax_keywords_typescript_d, arr_count(syntax_keywords_typescript_d)}, ['e'] = {syntax_keywords_typescript_e, arr_count(syntax_keywords_typescript_e)}, ['f'] = {syntax_keywords_typescript_f, arr_count(syntax_keywords_typescript_f)}, ['g'] = {syntax_keywords_typescript_g, arr_count(syntax_keywords_typescript_g)}, ['h'] = {syntax_keywords_typescript_h, arr_count(syntax_keywords_typescript_h)}, ['i'] = {syntax_keywords_typescript_i, arr_count(syntax_keywords_typescript_i)}, ['l'] = {syntax_keywords_typescript_l, arr_count(syntax_keywords_typescript_l)}, ['m'] = {syntax_keywords_typescript_m, arr_count(syntax_keywords_typescript_m)}, ['n'] = {syntax_keywords_typescript_n, arr_count(syntax_keywords_typescript_n)}, ['o'] = {syntax_keywords_typescript_o, arr_count(syntax_keywords_typescript_o)}, ['p'] = {syntax_keywords_typescript_p, arr_count(syntax_keywords_typescript_p)}, ['r'] = {syntax_keywords_typescript_r, arr_count(syntax_keywords_typescript_r)}, ['s'] = {syntax_keywords_typescript_s, arr_count(syntax_keywords_typescript_s)}, ['t'] = {syntax_keywords_typescript_t, arr_count(syntax_keywords_typescript_t)}, ['u'] = {syntax_keywords_typescript_u, arr_count(syntax_keywords_typescript_u)}, ['v'] = {syntax_keywords_typescript_v, arr_count(syntax_keywords_typescript_v)}, ['w'] = {syntax_keywords_typescript_w, arr_count(syntax_keywords_typescript_w)}, ['y'] = {syntax_keywords_typescript_y, arr_count(syntax_keywords_typescript_y)} }; static const Keyword syntax_keywords_go_a[1] = {{"append", SYNTAX_BUILTIN}}; diff --git a/keywords.py b/keywords.py index 75d02dc..54eaf9a 100755 --- a/keywords.py +++ b/keywords.py @@ -343,14 +343,14 @@ for attr in attributes_html: keywords_javascript = [ - 'break', 'case', 'catch', 'class', 'const', + 'async', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'export', 'extends', 'finally', 'for', 'function', 'if', 'import', 'in', - 'instanceof', 'new', 'return', 'super', + 'instanceof', 'new', 'of', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield', - 'let', 'await' + 'let', ] constants_json = [ @@ -359,7 +359,7 @@ constants_json = [ constants_javascript = constants_json + ['undefined'] builtins_javascript = [ - 'AggregateError','Array','ArrayBuffer','AsyncFunction','AsyncGenerator','AsyncGeneratorFunction', + 'AggregateError','arguments','Array','ArrayBuffer','AsyncFunction','AsyncGenerator','AsyncGeneratorFunction', 'Atomics','BigInt','BigInt64Array','BigUint64Array','Boolean','DataView','Date','decodeURI', 'decodeURIComponent','encodeURI','encodeURIComponent','Error','eval','EvalError','FinalizationRegistry', 'Float32Array','Float64Array','Function','Generator','GeneratorFunction','globalThis','Infinity', @@ -367,7 +367,15 @@ builtins_javascript = [ 'NaN','Number','Object','parseFloat','parseInt','Promise','Proxy','RangeError','ReferenceError', 'Reflect','RegExp','Set','SharedArrayBuffer','String','Symbol','SyntaxError','TypedArray', 'TypeError','Uint16Array','Uint32Array','Uint8Array','Uint8ClampedArray', - 'URIError','WeakMap','WeakRef','WeakSet','WebAssembly' + 'URIError','WeakMap','WeakRef','WeakSet','WebAssembly', + # window properties + 'console', 'customElements', 'devicePixelRatio', 'document', 'frameElement', + 'frames', 'history', 'innerHeight', 'innerWidth', 'length', 'localStorage', + 'location', 'locationbar', 'menubar', 'name', 'navigator', 'opener', + 'outerHeight', 'outerWidth', 'pageXOffset', 'pageYOffset', 'parent', + 'personalbar', 'scheduler', 'screen', 'screenLeft', 'screenTop', 'screenX', + 'screenY', 'scrollbars', 'scrollX', 'scrollY', 'self', 'sessionStorage', + 'speechSynthesis', 'statusbar', 'toolbar', 'top', 'visualViewport', 'window' ] keywords_java = [ diff --git a/main.c b/main.c index 38b084a..4b16e88 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,4 @@ /* -TODO: -- fix TODO highlighting in single-line comments (javascript & others?) -- highlight "of" (& other ES6 keywords?) in javascript FUTURE FEATURES: - autodetect indentation (tabs vs spaces) - font setting & support for multiple fonts to cover more characters diff --git a/syntax.c b/syntax.c index 1a5e1cf..308f39e 100644 --- a/syntax.c +++ b/syntax.c @@ -523,7 +523,7 @@ static void syntax_highlight_rust(SyntaxState *state, const char32_t *line, u32 // just handle it all now if (char_types) { for (u32 j = i; j < line_len; ++j) - char_types[j] = SYNTAX_COMMENT; + char_types[j] = syntax_highlight_comment(line, j, line_len); } i = line_len - 1; dealt_with = true; @@ -731,7 +731,7 @@ static void syntax_highlight_python(SyntaxState *state, const char32_t *line, u3 // comment if (char_types) { for (u32 j = i; j < line_len; ++j) - char_types[j] = SYNTAX_COMMENT; + char_types[j] = syntax_highlight_comment(line, j, line_len); dealt_with = true; } i = line_len - 1; @@ -895,7 +895,7 @@ static void syntax_highlight_tex(SyntaxState *state, const char32_t *line, u32 l if (!verbatim) { for (; i < line_len; ++i) { if (char_types) - char_types[i] = SYNTAX_COMMENT; + char_types[i] = syntax_highlight_comment(line, i, line_len); } } break; @@ -1150,7 +1150,7 @@ static void syntax_highlight_html_like(SyntaxState *state, const char32_t *line, // (don't worry, comments can't nest in HTML) comment = false; } else { - if (char_types) char_types[i] = SYNTAX_COMMENT; + if (char_types) char_types[i] = syntax_highlight_comment(line, i, line_len); } } else if (!in_sgl_string && !in_dbl_string && str32_has_ascii_prefix(remains, "