diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index 240787e7b..396f4120b 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -19,6 +19,7 @@ extern "C" { /* Return false on failure: */ int Scintilla_RegisterClasses(void *hInstance); int Scintilla_ReleaseResources(void); +int Scintilla_InputCodePage(void); #endif int Scintilla_LinkLexers(void); @@ -398,7 +399,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETPRINTCOLOURMODE 2149 #define SCFIND_WHOLEWORD 0x2 #define SCFIND_MATCHCASE 0x4 +// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> #define SCFIND_DOT_MATCH_ALL 0x1000 +// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< #define SCFIND_WORDSTART 0x00100000 #define SCFIND_REGEXP 0x00200000 #define SCFIND_POSIX 0x00400000 @@ -1043,6 +1046,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_INSERTCHECK 0x100000 #define SC_MOD_CHANGETABSTOPS 0x200000 #define SC_MODEVENTMASKALL 0x3FFFFF +// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> +#define SC_CHARADDED_NORMAL 0 +#define SC_CHARADDED_TENTATIVE 1 +#define SC_CHARADDED_IME 2 +// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< #define SC_UPDATE_CONTENT 0x1 #define SC_UPDATE_SELECTION 0x2 #define SC_UPDATE_V_SCROLL 0x4 diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index f71460284..6eb3ea2ef 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -2766,6 +2766,13 @@ val SC_MOD_INSERTCHECK=0x100000 val SC_MOD_CHANGETABSTOPS=0x200000 val SC_MODEVENTMASKALL=0x3FFFFF +// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> +# modifiers for SCN_CHARADDED: normal input, inline IME tentative, IME full composited +val SC_CHARADDED_NORMAL=0 +val SC_CHARADDED_TENTATIVE=1 +val SC_CHARADDED_IME=2 +// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< + enu Update=SC_UPDATE_ val SC_UPDATE_CONTENT=0x1 val SC_UPDATE_SELECTION=0x2 diff --git a/scintilla/patch_text.txt b/scintilla/patch_text.txt index 0ff89d399..60c29973b 100644 --- a/scintilla/patch_text.txt +++ b/scintilla/patch_text.txt @@ -1,5 +1,8 @@ // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> - + // >>> NON STD SCI PATCH <<< // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< + +https://github.com/RaiKoHoff/notepad2 +https://github.com/zufuliu/notepad2 diff --git a/scintilla/src/EditModel.cxx b/scintilla/src/EditModel.cxx index 23df27de3..ef0be3681 100644 --- a/scintilla/src/EditModel.cxx +++ b/scintilla/src/EditModel.cxx @@ -62,7 +62,9 @@ EditModel::EditModel() : braces{} { highlightGuideColumn = 0; primarySelection = true; imeInteraction = imeWindowed; - isInlineIMEComposition = false; + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> + charAddedSource = SC_CHARADDED_NORMAL; + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< bidirectional = Bidirectional::bidiDisabled; foldFlags = 0; foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN; diff --git a/scintilla/src/EditModel.h b/scintilla/src/EditModel.h index 10f7925b4..e87b0ee15 100644 --- a/scintilla/src/EditModel.h +++ b/scintilla/src/EditModel.h @@ -37,7 +37,9 @@ public: bool primarySelection; enum IMEInteraction { imeWindowed, imeInline } imeInteraction; - bool isInlineIMEComposition; + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> + int charAddedSource; + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< enum class Bidirectional { bidiDisabled, bidiL2R, bidiR2L } bidirectional; diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 8d440c71b..af3b87068 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -1894,6 +1894,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { // Vector elements point into selection in order to change selection. std::vector selPtrs; + selPtrs.reserve(sel.Count()); for (size_t r = 0; r < sel.Count(); r++) { selPtrs.push_back(&sel.Range(r)); } @@ -1958,7 +1959,10 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { SetLastXChosen(); } - if (!isInlineIMEComposition) { + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> + // We don't handle inline IME tentative characters + if (charAddedSource != SC_CHARADDED_TENTATIVE) { + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< if (treatAsDBCS) { NotifyChar((static_cast(s[0]) << 8) | static_cast(s[1])); @@ -1976,7 +1980,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { } NotifyChar(byte); } - } + } // >>> NON STD SCI PATCH <<< if (recordingMacro) { NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(s)); @@ -2327,6 +2331,9 @@ void Editor::NotifyChar(int ch) { SCNotification scn = {}; scn.nmhdr.code = SCN_CHARADDED; scn.ch = ch; + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> + scn.modifiers = charAddedSource; + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< NotifyParent(scn); } diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 50ca0a6f0..caa36fd19 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -152,8 +152,6 @@ Used by VSCode, Atom etc. typedef UINT_PTR (WINAPI *SetCoalescableTimerSig)(HWND hwnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, ULONG uToleranceDelay); -// GCC has trouble with the standard COM ABI so do it the old C way with explicit vtables. - using namespace Scintilla; namespace { @@ -1009,7 +1007,9 @@ sptr_t ScintillaWin::HandleCompositionWindowed(uptr_t wParam, sptr_t lParam) { if (lParam & GCS_RESULTSTR) { IMContext imc(MainHWND()); if (imc.hIMC) { + charAddedSource = SC_CHARADDED_IME; AddWString(imc.GetCompositionString(GCS_RESULTSTR)); + charAddedSource = SC_CHARADDED_NORMAL; // Set new position after converted const Point pos = PointMainCaret(); @@ -1215,7 +1215,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { const bool tmpRecordingMacro = recordingMacro; recordingMacro = false; - isInlineIMEComposition = true; + charAddedSource = SC_CHARADDED_TENTATIVE; const int codePage = CodePageOfDocument(); for (size_t i = 0; i < wcs.size(); ) { const size_t ucWidth = UTF16CharLength(wcs[i]); @@ -1227,7 +1227,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { DrawImeIndicator(imeIndicator[i], static_cast(docChar.size())); i += ucWidth; } - isInlineIMEComposition = false; + charAddedSource = SC_CHARADDED_NORMAL; recordingMacro = tmpRecordingMacro; // Move IME caret from current last position to imeCaretPos. @@ -1240,7 +1240,9 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { view.imeCaretBlockOverride = true; } } else if (lParam & GCS_RESULTSTR) { + charAddedSource = SC_CHARADDED_IME; AddWString(imc.GetCompositionString(GCS_RESULTSTR)); + charAddedSource = SC_CHARADDED_NORMAL; } EnsureCaretVisible(); SetCandidateWindowPos(); @@ -1463,7 +1465,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam KeyCommand(SCI_ZOOMIN); } else { KeyCommand(SCI_ZOOMOUT); - } + } // send to main window too ! ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); } else { diff --git a/src/Notepad3.c b/src/Notepad3.c index d5c456ea2..b9af9f09c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -6164,9 +6164,9 @@ static void __fastcall _HandleTinyExpr() //============================================================================= // -// _IsIMEOpenNativeMode() +// _IsIMEOpenInNativeMode() // -static bool __fastcall _IsIMEOpenNativeMode() +static bool __fastcall _IsIMEOpenInNativeMode() { bool result = false; HIMC const himc = ImmGetContext(g_hwndEdit); @@ -6174,7 +6174,7 @@ static bool __fastcall _IsIMEOpenNativeMode() if (ImmGetOpenStatus(himc)) { DWORD dwConversion = IME_CMODE_ALPHANUMERIC, dwSentence = 0; if (ImmGetConversionStatus(himc, &dwConversion, &dwSentence)) { - result = ((dwConversion & IME_CMODE_LANGUAGE) != IME_CMODE_ALPHANUMERIC); + result = (dwConversion != IME_CMODE_ALPHANUMERIC); } } ImmReleaseContext(g_hwndEdit, himc); @@ -6378,7 +6378,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) } if ((g_bAutoCompleteWords || g_bAutoCLexerKeyWords)) { - if ((g_bAutoCinASCIIModeOnly && ich > 0x7F) || _IsIMEOpenNativeMode()) { + if ((g_bAutoCinASCIIModeOnly && (ich > 0x7F)) || (scn->modifiers != SC_CHARADDED_NORMAL)) { SciCall_AutoCCancel(); return 0LL; }