From c394a890aa0c8fc75f081ac8c58abb1949c689ee Mon Sep 17 00:00:00 2001 From: VinsWorldcom Date: Tue, 25 Jan 2022 21:32:52 -0500 Subject: [PATCH] Add icons on function items of auto-completion to distiguish from word items Fix #11087, close #11088 --- .../src/ScintillaComponent/AutoCompletion.cpp | 70 ++++++++++++++++++- .../src/ScintillaComponent/AutoCompletion.h | 2 +- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp index 85916626e..77f3cee65 100644 --- a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp @@ -20,6 +20,66 @@ #include "AutoCompletion.h" #include "Notepad_plus_msgs.h" +const auto FUNC_IMG_ID = 1000; +const char* xpmfn[] = { + /* columns rows colors chars-per-pixel */ + "16 16 36 1 ", + "u c None", + " c #131313", + ". c #252525", + "X c #161616", + "o c #202020", + "O c #393939", + "+ c #242424", + "@ c #282828", + "# c #4E4E4E", + "$ c #343434", + "% c #5B5B5B", + "& c #5F5F5F", + "* c #626262", + "= c #404040", + "- c #686868", + "; c #434343", + ": c #464646", + "> c #484848", + ", c #494949", + "< c #515151", + "1 c #929292", + "2 c #9B9B9B", + "3 c #636363", + "4 c #656565", + "5 c #AFAFAF", + "6 c #B7B7B7", + "7 c #757575", + "8 c #CDCDCD", + "9 c #858585", + "0 c #868686", + "q c #DDDDDD", + "w c #E1E1E1", + "e c #E9E9E9", + "r c #EEEEEE", + "t c #959595", + "y c #F6F6F6", + /* pixels */ + "uuuuuuuuuuuuuuuu", + "uuuuu5o.:yuuuuuu", + "uuuu8 $:.0uuuuuu", + "uuuu2 yuuuuuuuuu", + "uuu6$ 46uuuuuuuu", + "uuuO Ouuuuuuuu", + "uuuu;#uuuuuuuuuu", + "uuuu##y& 3uu<+uu", + "uuuu#;0.@X0, >uu", + "uuuu+>uuroo >uuu", + "uuuu >uuu* =uuuu", + "uuuu 2uu, Xotuuu", + "uuue 4u< >9 %owu", + "u:,#X0uO>uu1 $yu", + "u- +7uuuuuuuuuuu", + "uuuuuuuuuuuuuuuu" +}; + + using namespace std; static bool isInList(const generic_string& word, const vector & wordArray) @@ -58,6 +118,8 @@ bool AutoCompletion::showApiComplete() return false; _pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' ')); + _pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?')); + _pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn)); _pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase); _pEditView->showAutoComletion(curPos - startPos, _keyWords.c_str()); @@ -142,6 +204,8 @@ bool AutoCompletion::showApiAndWordComplete() // Make Scintilla show the autocompletion menu _pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' ')); + _pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?')); + _pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn)); _pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase); _pEditView->showAutoComletion(curPos - startPos, words.c_str()); return true; @@ -400,6 +464,8 @@ bool AutoCompletion::showWordComplete(bool autoInsert) // Make Scintilla show the autocompletion menu _pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' ')); + _pEditView->execute(SCI_AUTOCSETTYPESEPARATOR, WPARAM('?')); + _pEditView->execute(SCI_REGISTERIMAGE, FUNC_IMG_ID, LPARAM(xpmfn)); _pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase); _pEditView->showAutoComletion(curPos - startPos, words.c_str()); return true; @@ -901,12 +967,14 @@ bool AutoCompletion::setLanguage(LangType language) for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) { const TCHAR *name = funcNode->Attribute(TEXT("name")); + generic_string imgid = TEXT("?") + intToString(FUNC_IMG_ID); if (name) { size_t len = lstrlen(name); if (len) { - _keyWordArray.push_back(name); + generic_string word = name + imgid; + _keyWordArray.push_back(word.c_str()); if (len > _keyWordMaxLen) _keyWordMaxLen = len; } diff --git a/PowerEditor/src/ScintillaComponent/AutoCompletion.h b/PowerEditor/src/ScintillaComponent/AutoCompletion.h index c5103b54a..6b0eb0f3a 100644 --- a/PowerEditor/src/ScintillaComponent/AutoCompletion.h +++ b/PowerEditor/src/ScintillaComponent/AutoCompletion.h @@ -88,7 +88,7 @@ private: generic_string _keyWords; size_t _keyWordMaxLen = 0; - FunctionCallTip _funcCalltip; + FunctionCallTip _funcCalltip; const TCHAR * getApiFileName(); void getWordArray(std::vector & wordArray, TCHAR *beginChars, TCHAR *excludeChars);