diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/EditModel.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 13 | ||||
-rw-r--r-- | src/Editor.h | 4 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 8 | ||||
-rw-r--r-- | src/ScintillaBase.h | 2 |
5 files changed, 15 insertions, 14 deletions
diff --git a/src/EditModel.h b/src/EditModel.h index b63f2129f..9e2f6d94d 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -37,7 +37,7 @@ public: bool primarySelection; enum IMEInteraction { imeWindowed, imeInline } imeInteraction; - + enum class CharacterSource { directInput, tentativeInput, imeResult }; enum class Bidirectional { bidiDisabled, bidiL2R, bidiR2L } bidirectional; int foldFlags; diff --git a/src/Editor.cxx b/src/Editor.cxx index 92c77571e..2cf12f61f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1891,7 +1891,7 @@ void Editor::AddChar(char ch) { char s[2]; s[0] = ch; s[1] = '\0'; - InsertCharacter(std::string_view(s, 1)); + InsertCharacter(std::string_view(s, 1), CharacterSource::directInput); } void Editor::FilterSelections() { @@ -1902,7 +1902,7 @@ void Editor::FilterSelections() { } // InsertCharacter inserts a character encoded in document code page. -void Editor::InsertCharacter(std::string_view sv) { +void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) { if (sv.empty()) { return; } @@ -1994,9 +1994,9 @@ void Editor::InsertCharacter(std::string_view sv) { ch = utf32[0]; } } - NotifyChar(ch); + NotifyChar(ch, charSource); - if (recordingMacro) { + if (recordingMacro && charSource != CharacterSource::tentativeInput) { std::string copy(sv); // ensure NUL-terminated NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(copy.data())); } @@ -2342,10 +2342,11 @@ void Editor::NotifyErrorOccurred(Document *, void *, int status) { errorStatus = status; } -void Editor::NotifyChar(int ch) { +void Editor::NotifyChar(int ch, CharacterSource charSource) { SCNotification scn = {}; scn.nmhdr.code = SCN_CHARADDED; scn.ch = ch; + scn.characterSource = static_cast<int>(charSource); NotifyParent(scn); } @@ -3091,7 +3092,7 @@ void Editor::NewLine() { for (size_t i = 0; i < countInsertions; i++) { const char *eol = StringFromEOLMode(pdoc->eolMode); while (*eol) { - NotifyChar(*eol); + NotifyChar(*eol, CharacterSource::directInput); if (recordingMacro) { char txt[2]; txt[0] = *eol; diff --git a/src/Editor.h b/src/Editor.h index 5716ba048..f16a46693 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -393,7 +393,7 @@ protected: // ScintillaBase subclass needs access to much of Editor Sci::Position RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace); SelectionPosition RealizeVirtualSpace(const SelectionPosition &position); void AddChar(char ch); - virtual void InsertCharacter(std::string_view sv); + virtual void InsertCharacter(std::string_view sv, CharacterSource charSource); void ClearBeforeTentativeStart(); void InsertPaste(const char *text, Sci::Position len); enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 }; @@ -421,7 +421,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual int GetCtrlID() { return ctrlID; } virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded); - void NotifyChar(int ch); + void NotifyChar(int ch, CharacterSource charSource); void NotifySavePoint(bool isSavePoint); void NotifyModifyAttempt(); virtual void NotifyDoubleClick(Point pt, int modifiers); diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 6799dfd06..296f5f8e6 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -80,20 +80,20 @@ void ScintillaBase::Finalise() { } void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool /*treatAsDBCS*/) { - InsertCharacter(std::string_view(s, len)); + InsertCharacter(std::string_view(s, len), CharacterSource::directInput); } -void ScintillaBase::InsertCharacter(std::string_view sv) { +void ScintillaBase::InsertCharacter(std::string_view sv, CharacterSource charSource) { const bool isFillUp = ac.Active() && ac.IsFillUpChar(sv[0]); if (!isFillUp) { - Editor::InsertCharacter(sv); + Editor::InsertCharacter(sv, charSource); } if (ac.Active()) { AutoCompleteCharacterAdded(sv[0]); // For fill ups add the character after the autocompletion has // triggered so containers see the key so can display a calltip. if (isFillUp) { - Editor::InsertCharacter(sv); + Editor::InsertCharacter(sv, charSource); } } } diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index d28e47c4e..fc4315e6d 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -63,7 +63,7 @@ protected: // This method is deprecated, use InsertCharacter instead. The treatAsDBCS parameter is no longer used. virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false); - void InsertCharacter(std::string_view sv) override; + void InsertCharacter(std::string_view sv, CharacterSource charSource) override; void Command(int cmdId); void CancelModes() override; int KeyCommand(unsigned int iMessage) override; |