From f90d98c3c451aa5be2979ff05863b5aa8bee9336 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Tue, 20 Apr 2021 14:18:56 -0400 Subject: cfg syntax highlighting --- README.md | 2 +- keywords.h | 9 +++++++ keywords.py | 4 +++ main.c | 2 -- syntax.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- ted.cfg | 1 + ted.h | 2 ++ 7 files changed, 96 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 054ce0e..9450b98 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ in other editors. - Multiple tabs, each with a different file - Split screen (default: Ctrl+\\, Ctrl+Shift+\\) - Auto-indent -- Syntax highlighting for C, C++, Rust, Python, LaTeX, and Markdown. +- Syntax highlighting for C, C++, HTML, LaTeX, Markdown, Python, and Rust. - Find and replace (with regular expressions!) - Run build command (F4), go to errors - Run any shell command (Ctrl+!) diff --git a/keywords.h b/keywords.h index 5fdb0e5..c880b77 100644 --- a/keywords.h +++ b/keywords.h @@ -203,3 +203,12 @@ static Keyword const *const syntax_all_keywords_html[] = { ['a'] = syntax_keywords_html_a, ['b'] = syntax_keywords_html_b, ['c'] = syntax_keywords_html_c, ['d'] = syntax_keywords_html_d, ['e'] = syntax_keywords_html_e, ['f'] = syntax_keywords_html_f, ['h'] = syntax_keywords_html_h, ['i'] = syntax_keywords_html_i, ['k'] = syntax_keywords_html_k, ['l'] = syntax_keywords_html_l, ['m'] = syntax_keywords_html_m, ['n'] = syntax_keywords_html_n, ['o'] = syntax_keywords_html_o, ['p'] = syntax_keywords_html_p, ['r'] = syntax_keywords_html_r, ['s'] = syntax_keywords_html_s, ['t'] = syntax_keywords_html_t, ['u'] = syntax_keywords_html_u, ['v'] = syntax_keywords_html_v, ['w'] = syntax_keywords_html_w }; +static Keyword const syntax_keywords_config_f[2] = {{"false", SYNTAX_CONSTANT}}; +static Keyword const syntax_keywords_config_n[2] = {{"no", SYNTAX_CONSTANT}}; +static Keyword const syntax_keywords_config_o[3] = {{"off", SYNTAX_CONSTANT},{"on", SYNTAX_CONSTANT}}; +static Keyword const syntax_keywords_config_t[2] = {{"true", SYNTAX_CONSTANT}}; +static Keyword const syntax_keywords_config_y[2] = {{"yes", SYNTAX_CONSTANT}}; +static Keyword const *const syntax_all_keywords_config[] = { + ['f'] = syntax_keywords_config_f, ['n'] = syntax_keywords_config_n, ['o'] = syntax_keywords_config_o, ['t'] = syntax_keywords_config_t, ['y'] = syntax_keywords_config_y +}; + diff --git a/keywords.py b/keywords.py index c8f7e9c..2413dd9 100755 --- a/keywords.py +++ b/keywords.py @@ -243,6 +243,9 @@ attributes_html = [ 'srclang','srcset','start','step','style','tabindex','target', 'title','translate','type','usemap','value','width','wrap' ] +constants_config = [ + 'on', 'off', 'yes', 'no', 'true', 'false' +] assert len(attributes_html) == len(set(attributes_html)) @@ -274,4 +277,5 @@ output_keywords(file, cpp_things, 'cpp') output_keywords(file, label(keywords_rust, SYNTAX_KEYWORD) + label(builtins_rust, SYNTAX_BUILTIN) + label(constants_rust, SYNTAX_CONSTANT), 'rust') output_keywords(file, label(keywords_python, SYNTAX_KEYWORD) + label(builtins_python, SYNTAX_BUILTIN), 'python') output_keywords(file, label(builtins_html, SYNTAX_BUILTIN), 'html') +output_keywords(file, label(constants_config, SYNTAX_CONSTANT), 'config') file.close() diff --git a/main.c b/main.c index 044a11b..d140f29 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,3 @@ -// Highlighting for: -// - Config (cfg) // :set-language command; -1 = default language for this extension #include "base.h" diff --git a/syntax.c b/syntax.c index 2e361cf..bc8803c 100644 --- a/syntax.c +++ b/syntax.c @@ -16,12 +16,18 @@ Language language_from_str(char const *str) { // start of single line comment for language l -- used for comment/uncomment selection char const *language_comment_start(Language l) { switch (l) { - case LANG_C: return "/* "; + case LANG_C: + return "/* "; case LANG_RUST: - case LANG_CPP: return "// "; - case LANG_PYTHON: return "# "; - case LANG_TEX: return "% "; - case LANG_HTML: return "