From da5f896de6830a6b79230f186a5523e368858c56 Mon Sep 17 00:00:00 2001 From: PeterCJ Date: Sun, 5 May 2024 13:22:49 -0700 Subject: [PATCH] Language enhancement: allow custom tags in HTML HTML Lexer, TAG Style: enable user-defined keywords Implement and verify @mpheath solution from https://community.notepad-plus-plus.org/topic/25741/html-user-defined-keywords Fix #15093, close #15094 --- PowerEditor/installer/themes/Bespin.xml | 2 +- PowerEditor/installer/themes/Black board.xml | 2 +- PowerEditor/installer/themes/Choco.xml | 2 +- .../installer/themes/DansLeRuSH-Dark.xml | 2 +- .../installer/themes/DarkModeDefault.xml | 2 +- PowerEditor/installer/themes/Deep Black.xml | 2 +- PowerEditor/installer/themes/Hello Kitty.xml | 2 +- .../installer/themes/HotFudgeSundae.xml | 2 +- .../installer/themes/Mono Industrial.xml | 2 +- PowerEditor/installer/themes/Monokai.xml | 2 +- PowerEditor/installer/themes/MossyLawn.xml | 2 +- PowerEditor/installer/themes/Navajo.xml | 2 +- PowerEditor/installer/themes/Obsidian.xml | 2 +- .../installer/themes/Plastic Code Wrap.xml | 2 +- PowerEditor/installer/themes/Ruby Blue.xml | 2 +- .../installer/themes/Solarized-light.xml | 2 +- PowerEditor/installer/themes/Solarized.xml | 2 +- PowerEditor/installer/themes/Twilight.xml | 2 +- PowerEditor/installer/themes/Vibrant Ink.xml | 2 +- PowerEditor/installer/themes/Zenburn.xml | 2 +- PowerEditor/installer/themes/khaki.xml | 2 +- .../installer/themes/vim Dark Blue.xml | 2 +- .../ScintillaComponent/ScintillaEditView.cpp | 22 ++++++++++++++----- .../ScintillaComponent/ScintillaEditView.h | 1 + PowerEditor/src/stylers.model.xml | 2 +- 25 files changed, 40 insertions(+), 29 deletions(-) diff --git a/PowerEditor/installer/themes/Bespin.xml b/PowerEditor/installer/themes/Bespin.xml index 3e9417b2c..e8e92dc17 100644 --- a/PowerEditor/installer/themes/Bespin.xml +++ b/PowerEditor/installer/themes/Bespin.xml @@ -207,7 +207,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/Black board.xml b/PowerEditor/installer/themes/Black board.xml index 50cdc8902..953776b83 100644 --- a/PowerEditor/installer/themes/Black board.xml +++ b/PowerEditor/installer/themes/Black board.xml @@ -209,7 +209,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/Choco.xml b/PowerEditor/installer/themes/Choco.xml index cdd0a6a63..8dc51c1e7 100644 --- a/PowerEditor/installer/themes/Choco.xml +++ b/PowerEditor/installer/themes/Choco.xml @@ -209,7 +209,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/DansLeRuSH-Dark.xml b/PowerEditor/installer/themes/DansLeRuSH-Dark.xml index 1424a3744..1fb5651de 100644 --- a/PowerEditor/installer/themes/DansLeRuSH-Dark.xml +++ b/PowerEditor/installer/themes/DansLeRuSH-Dark.xml @@ -399,7 +399,7 @@ Installation : Copy this file to "%APPDATA%\Notepad++\themes" and in a portable - + diff --git a/PowerEditor/installer/themes/DarkModeDefault.xml b/PowerEditor/installer/themes/DarkModeDefault.xml index 26f896331..fa5e625b6 100644 --- a/PowerEditor/installer/themes/DarkModeDefault.xml +++ b/PowerEditor/installer/themes/DarkModeDefault.xml @@ -593,7 +593,7 @@ License: GPL2 - + diff --git a/PowerEditor/installer/themes/Deep Black.xml b/PowerEditor/installer/themes/Deep Black.xml index 14c8b6405..a984a6c16 100644 --- a/PowerEditor/installer/themes/Deep Black.xml +++ b/PowerEditor/installer/themes/Deep Black.xml @@ -210,7 +210,7 @@ https://notepad-plus-plus.org/donate/ - + diff --git a/PowerEditor/installer/themes/Hello Kitty.xml b/PowerEditor/installer/themes/Hello Kitty.xml index 8f99a3b59..0d9e2aa6f 100644 --- a/PowerEditor/installer/themes/Hello Kitty.xml +++ b/PowerEditor/installer/themes/Hello Kitty.xml @@ -306,7 +306,7 @@ so your enhanced file can be included in Notepad++ future release. - + diff --git a/PowerEditor/installer/themes/HotFudgeSundae.xml b/PowerEditor/installer/themes/HotFudgeSundae.xml index 6f7666acf..177a737e3 100644 --- a/PowerEditor/installer/themes/HotFudgeSundae.xml +++ b/PowerEditor/installer/themes/HotFudgeSundae.xml @@ -408,7 +408,7 @@ Installation: - + diff --git a/PowerEditor/installer/themes/Mono Industrial.xml b/PowerEditor/installer/themes/Mono Industrial.xml index 21e9bedb5..8861c4043 100644 --- a/PowerEditor/installer/themes/Mono Industrial.xml +++ b/PowerEditor/installer/themes/Mono Industrial.xml @@ -241,7 +241,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/Monokai.xml b/PowerEditor/installer/themes/Monokai.xml index 200718767..160d2844e 100644 --- a/PowerEditor/installer/themes/Monokai.xml +++ b/PowerEditor/installer/themes/Monokai.xml @@ -241,7 +241,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/MossyLawn.xml b/PowerEditor/installer/themes/MossyLawn.xml index d7facf874..fd99f163e 100644 --- a/PowerEditor/installer/themes/MossyLawn.xml +++ b/PowerEditor/installer/themes/MossyLawn.xml @@ -409,7 +409,7 @@ Installation: - + diff --git a/PowerEditor/installer/themes/Navajo.xml b/PowerEditor/installer/themes/Navajo.xml index c3b03b541..d47aa0904 100644 --- a/PowerEditor/installer/themes/Navajo.xml +++ b/PowerEditor/installer/themes/Navajo.xml @@ -406,7 +406,7 @@ Installation: - + diff --git a/PowerEditor/installer/themes/Obsidian.xml b/PowerEditor/installer/themes/Obsidian.xml index b8555d249..696cfa4cc 100644 --- a/PowerEditor/installer/themes/Obsidian.xml +++ b/PowerEditor/installer/themes/Obsidian.xml @@ -311,7 +311,7 @@ Notepad++ Custom Style - + diff --git a/PowerEditor/installer/themes/Plastic Code Wrap.xml b/PowerEditor/installer/themes/Plastic Code Wrap.xml index c43e92cf0..0dc700040 100644 --- a/PowerEditor/installer/themes/Plastic Code Wrap.xml +++ b/PowerEditor/installer/themes/Plastic Code Wrap.xml @@ -241,7 +241,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/Ruby Blue.xml b/PowerEditor/installer/themes/Ruby Blue.xml index 58691197c..7a7f3af82 100644 --- a/PowerEditor/installer/themes/Ruby Blue.xml +++ b/PowerEditor/installer/themes/Ruby Blue.xml @@ -236,7 +236,7 @@ http://sourceforge.net/donate/index.php?group_id=95717 - + diff --git a/PowerEditor/installer/themes/Solarized-light.xml b/PowerEditor/installer/themes/Solarized-light.xml index 7edacb7c4..75ca69bd4 100644 --- a/PowerEditor/installer/themes/Solarized-light.xml +++ b/PowerEditor/installer/themes/Solarized-light.xml @@ -417,7 +417,7 @@ Installation: - + diff --git a/PowerEditor/installer/themes/Solarized.xml b/PowerEditor/installer/themes/Solarized.xml index c7cb20d5b..f3b8caeff 100644 --- a/PowerEditor/installer/themes/Solarized.xml +++ b/PowerEditor/installer/themes/Solarized.xml @@ -568,7 +568,7 @@ Installation: - + diff --git a/PowerEditor/installer/themes/Twilight.xml b/PowerEditor/installer/themes/Twilight.xml index b8efbb0bb..989a6508d 100644 --- a/PowerEditor/installer/themes/Twilight.xml +++ b/PowerEditor/installer/themes/Twilight.xml @@ -242,7 +242,7 @@ Credits: - + diff --git a/PowerEditor/installer/themes/Vibrant Ink.xml b/PowerEditor/installer/themes/Vibrant Ink.xml index 102f2b1e7..0f96163ce 100644 --- a/PowerEditor/installer/themes/Vibrant Ink.xml +++ b/PowerEditor/installer/themes/Vibrant Ink.xml @@ -217,7 +217,7 @@ http://sourceforge.net/donate/index.php?group_id=95717 - + diff --git a/PowerEditor/installer/themes/Zenburn.xml b/PowerEditor/installer/themes/Zenburn.xml index e9a23f568..33c735db2 100644 --- a/PowerEditor/installer/themes/Zenburn.xml +++ b/PowerEditor/installer/themes/Zenburn.xml @@ -581,7 +581,7 @@ License: GPL2 - + diff --git a/PowerEditor/installer/themes/khaki.xml b/PowerEditor/installer/themes/khaki.xml index 5013dbf4f..a99c3a995 100644 --- a/PowerEditor/installer/themes/khaki.xml +++ b/PowerEditor/installer/themes/khaki.xml @@ -406,7 +406,7 @@ Installation: - + diff --git a/PowerEditor/installer/themes/vim Dark Blue.xml b/PowerEditor/installer/themes/vim Dark Blue.xml index e4bf86eb0..69835bf8d 100644 --- a/PowerEditor/installer/themes/vim Dark Blue.xml +++ b/PowerEditor/installer/themes/vim Dark Blue.xml @@ -302,7 +302,7 @@ - + diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 2cbe46d13..797d4ac26 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -828,13 +828,8 @@ void ScintillaEditView::setXmlLexer(LangType type) else if ((type == L_HTML) || (type == L_PHP) || (type == L_ASP) || (type == L_JSP)) { setLexerFromLangID(L_HTML); - const TCHAR *htmlKeyWords_generic = NppParameters::getInstance().getWordList(L_HTML, LANG_INDEX_INSTR); - - WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); - const char *htmlKeyWords = wmc.wchar2char(htmlKeyWords_generic, CP_ACP); - execute(SCI_SETKEYWORDS, 0, reinterpret_cast(htmlKeyWords?htmlKeyWords:"")); - makeStyle(L_HTML); + setHTMLLexer(); setEmbeddedJSLexer(); setEmbeddedPhpLexer(); setEmbeddedAspLexer(); @@ -846,6 +841,21 @@ void ScintillaEditView::setXmlLexer(LangType type) execute(SCI_SETPROPERTY, reinterpret_cast("fold.hypertext.comment"), reinterpret_cast("1")); } +void ScintillaEditView::setHTMLLexer() +{ + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + makeStyle(L_HTML, pKwArray); + + basic_string keywordList(""); + if (pKwArray[LANG_INDEX_INSTR]) + { + basic_string kwlW = pKwArray[LANG_INDEX_INSTR]; + keywordList = wstring2string(kwlW, CP_ACP); + } + + execute(SCI_SETKEYWORDS, 0, reinterpret_cast(getCompleteKeywordList(keywordList, L_HTML, LANG_INDEX_INSTR))); +} + void ScintillaEditView::setEmbeddedJSLexer() { const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 289a0f985..396914cc8 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -827,6 +827,7 @@ protected: //Complex lexers (same lexer, different language) void setXmlLexer(LangType type); void setCppLexer(LangType type); + void setHTMLLexer(); void setJsLexer(); void setTclLexer(); void setObjCLexer(LangType type); diff --git a/PowerEditor/src/stylers.model.xml b/PowerEditor/src/stylers.model.xml index 6d2fb139b..fcc1f9f28 100644 --- a/PowerEditor/src/stylers.model.xml +++ b/PowerEditor/src/stylers.model.xml @@ -569,7 +569,7 @@ - +