From d7af3e5f517f27d13f623ce892a2438147ec645a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 16 May 2025 22:38:58 -0300 Subject: [PATCH 1/3] Fix the usual problem of highlighting "if()" and etc as functions in C, C++, JavaScript and TypeScript (this should be done for every language but I'm too lazy). --- src/eepp/ui/doc/languages/c.cpp | 4 ++++ src/eepp/ui/doc/languages/cpp.cpp | 8 ++++++-- src/eepp/ui/doc/languages/javascript.cpp | 4 ++++ .../src/eepp/ui/doc/languages/typescript.cpp | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/eepp/ui/doc/languages/c.cpp b/src/eepp/ui/doc/languages/c.cpp index 01c468466..fed955573 100644 --- a/src/eepp/ui/doc/languages/c.cpp +++ b/src/eepp/ui/doc/languages/c.cpp @@ -18,6 +18,10 @@ void addC() { { { "'", "'", "\\" }, "string" }, { { "c_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, { { "[%+%-=/%*%^%%<>!~|&]" }, "operator" }, + { { "(if|for|while|switch|sizeof|_Alignof|defined)\\s*(?=\\()" }, + { "normal", "keyword", "keyword" }, + "", + SyntaxPatternMatchType::RegEx }, { { "[%a_][%w_]*%f[(]" }, "function" }, { { "#[%a_][%w_]*" }, "symbol" }, { { "[%a_][%w_]*" }, "symbol" }, diff --git a/src/eepp/ui/doc/languages/cpp.cpp b/src/eepp/ui/doc/languages/cpp.cpp index ac4d475f7..4bd9faf77 100644 --- a/src/eepp/ui/doc/languages/cpp.cpp +++ b/src/eepp/ui/doc/languages/cpp.cpp @@ -25,6 +25,10 @@ void addCPP() { { "keyword", "keyword", "literal" } }, { { "cpp_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, { { "[%+%-=/%*%^%%<>!~|&]" }, "operator" }, + { { "(if|for|while|switch|catch|sizeof|typeid|defined)\\s*(?=\\()" }, + { "normal", "keyword", "keyword" }, + "", + SyntaxPatternMatchType::RegEx }, { { "[%a_][%w_]*%f[(]" }, "function" }, { { "std%:%:[%w_]*" }, "keyword2" }, { { "(%[)(%[)(%a[%w_]+)(%])(%])" }, @@ -92,7 +96,7 @@ void addCPP() { { "bitor", "keyword" }, { "thread_local", "keyword" }, { "uint64_t", "keyword2" }, { "char32_t", "keyword2" }, { "alignas", "keyword" }, { "export", "keyword" }, - { "ssize_t", "keyword2" }, + { "ssize_t", "keyword2" }, { "signed", "keyword2" }, { "#if", "keyword" }, { "#ifdef", "keyword" }, { "#ifndef", "keyword" }, { "#else", "keyword" }, @@ -101,7 +105,7 @@ void addCPP() { { "#endif", "keyword" }, { "#include", "keyword" }, { "#define", "keyword" }, { "#undef", "keyword" }, { "#line", "keyword" }, { "#error", "keyword" }, - { "#pragma", "keyword" }, { "signed", "keyword2" }, + { "#pragma", "keyword" }, { "#warning", "keyword" }, }, "//", diff --git a/src/eepp/ui/doc/languages/javascript.cpp b/src/eepp/ui/doc/languages/javascript.cpp index eb786b421..22f8f49a5 100644 --- a/src/eepp/ui/doc/languages/javascript.cpp +++ b/src/eepp/ui/doc/languages/javascript.cpp @@ -20,6 +20,10 @@ void addJavaScript() { "string" }, { { "js_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, { { "[%+%-=/%*%^%%<>!~|&]" }, "operator" }, + { { "(if|for|while|switch|catch|with)\\s*(?=\\()" }, + { "normal", "keyword", "keyword" }, + "", + SyntaxPatternMatchType::RegEx }, { { "([%w_][%w_]+)%.([%w_][%w%d_]*)%s*(=)%s*(function)" }, { "normal", "keyword2", "function", "operator", "keyword" } }, { { "([%w_][%w_]+)%.([%w_][%w%d_]*)%s*(=)%s*(async%s*function)" }, diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/typescript.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/typescript.cpp index acc442b45..04dc2217d 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/typescript.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/typescript.cpp @@ -23,6 +23,10 @@ void addTypeScript() { { { "[%+%-=/%*%^%%<>!~|&]" }, "operator" }, { { "(interface%s)([%a_][%w_]*)" }, { "normal", "keyword", "keyword2" } }, { { "(type%s)([%a_][%w_]*)" }, { "normal", "keyword", "keyword2" } }, + { { "(if|for|while|switch|catch|with)\\s*(?=\\()" }, + { "normal", "keyword", "keyword" }, + "", + SyntaxPatternMatchType::RegEx }, { { "[%a_][%w_$]*%f[(]" }, "function" }, { { "[%a_][%w_]*" }, "symbol" }, From aafcb3e3ca9a5b7db1bbef9f3245d67b3522dbe3 Mon Sep 17 00:00:00 2001 From: NullPlane <111517889+NullPlane@users.noreply.github.com> Date: Sat, 17 May 2025 16:48:42 +0200 Subject: [PATCH 2/3] Update de.xml (#115) Fixed misinterpretation --- bin/assets/i18n/de.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/assets/i18n/de.xml b/bin/assets/i18n/de.xml index cf9c95ca5..28909000c 100644 --- a/bin/assets/i18n/de.xml +++ b/bin/assets/i18n/de.xml @@ -4,9 +4,9 @@ author: 'NullPlane' author_link: 'github.com/NullPlane' collaborators: [ 'SpartanJ', 'NullPlane' ] - version: '0.7.1_r00' + version: '0.7.1_r01' created: 2024-02-08 - updated: 2025-04-15 + updated: 2025-05-17 language: 'de' format: 'xml' file: 'de.xml' @@ -568,7 +568,7 @@ Bitte die Anwendung neu starten. Ordner aktueller Datei öffnen... Kontextmenü öffnen Dokumentsymbolsuche öffnen - Dokumente öffnen + Geöffnete Dokumente Datei öffnen Datei öffnen... Datei aus dem Netz öffnen... From 99c173ef67a0d4259110e80df9d567c8f415196c Mon Sep 17 00:00:00 2001 From: Panzerschrek Date: Mon, 19 May 2025 20:35:31 +0300 Subject: [PATCH 3/3] =?UTF-8?q?Simplify=20and=20improve=20=C3=9C=20syntax?= =?UTF-8?q?=20highlighting.=20(#116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support all langauge operator symbols ($:.@?). Remove extra rules for functions, classes, import directives etc., since their detection can't work properly in all cases - lexical analysis only isn't enough. --- .../src/eepp/ui/doc/languages/u.cpp | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/u.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/u.cpp index 8deb550c4..6711993f9 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/u.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/u.cpp @@ -10,27 +10,16 @@ void addU() { { "Ü", { "%.u$", "%.uh$" }, { - { { "//.-\n" }, "comment" }, - { { "/%*", "%*/" }, "comment" }, - { { "\"", "[\"\n]", "\\" }, "string" }, - { { "'", "'", "\\" }, "string" }, - { { "(class|template|namespace|enum)\\s+([A-Za-z]\\w*)" }, - { "keyword", "keyword", "keyword2" }, - "", - SyntaxPatternMatchType::RegEx }, - { { "$%(([%a_]%w*)%)" }, { "operator", "keyword2", "keyword2" } }, - { { "^%s*(import)%s+([<%\"][%w%d%.%\\%/%_%-]+[>%\"])" }, - { "keyword", "keyword", "literal" } }, - { { "cpp_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, - { { "[%+%-=/%*%^%%<>!~|&]" }, "operator" }, - { { "[%a_][%w_]*%f[(]" }, "function" }, - { { "ust%:%:[%w_]*" }, "keyword2" }, - { { "[%a_][%w_]*" }, "symbol" }, - + { { "//.-\n" }, "comment" }, // Single-line comments. + { { "/%*", "%*/" }, "comment" }, // Multi-line comments. + { { "\"", "[\"\n]", "\\" }, "string" }, // String literals. + { { "'", "'", "\\" }, "string" }, // Char literals. + { { "cpp_number_parser" }, "number", "", SyntaxPatternMatchType::Parser }, // Numbers. TODO - support Ü-specific formats. + { { "[%+%-=/%*%^%%<>!~|&$:.@?]" }, "operator" }, // Various operators. + { { "[%a_][%w_]*" }, "symbol" }, // Regular identifiers. }, { - - { "pretty_main", "function" }, + // Keywords. { "fn", "keyword" }, { "op", "keyword" }, { "var", "keyword" }, @@ -119,6 +108,7 @@ void addU() { { "cast_ref_unsafe", "keyword" }, { "cast_mut", "keyword" }, { "uninitialized", "keyword" }, + // Built-in type keywords. { "void", "keyword2" }, { "bool", "keyword2" }, { "i8", "keyword2" },