aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormitchell <unknown>2019-07-11 14:12:28 -0400
committermitchell <unknown>2019-07-11 14:12:28 -0400
commit2a15b94200abe8ee0df2dddc296f3dafd55655f8 (patch)
tree7236773c70225185fe1532d109a66f98c39e8d18 /src
parent55446b8967ed0a7f66502424d309f0b8fa74919f (diff)
downloadscintilla-mirror-2a15b94200abe8ee0df2dddc296f3dafd55655f8.tar.gz
Backport: Bug [#2038]. Source of input reported in SCN_CHARADDED.
This may be SC_CHARACTERSOURCE_DIRECT_INPUT, SC_CHARACTERSOURCE_TENTATIVE_INPUT, or SC_CHARACTERSOURCE_IME_RESULT. Backport of changeset 7613:4cfac35c71bd.
Diffstat (limited to 'src')
-rw-r--r--src/EditModel.h1
-rw-r--r--src/Editor.cxx13
-rw-r--r--src/Editor.h4
-rw-r--r--src/ScintillaBase.cxx8
-rw-r--r--src/ScintillaBase.h2
5 files changed, 15 insertions, 13 deletions
diff --git a/src/EditModel.h b/src/EditModel.h
index ab5c23cdb..9aee35a62 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -37,6 +37,7 @@ public:
bool primarySelection;
enum IMEInteraction { imeWindowed, imeInline } imeInteraction;
+ enum class CharacterSource { directInput, tentativeInput, imeResult };
int foldFlags;
int foldDisplayTextStyle;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index e963ba339..4cceb1f5d 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1888,7 +1888,7 @@ void Editor::AddChar(char ch) {
char s[2];
s[0] = ch;
s[1] = '\0';
- InsertCharacter(s, 1);
+ InsertCharacter(s, 1, CharacterSource::directInput);
}
void Editor::FilterSelections() {
@@ -1899,7 +1899,7 @@ void Editor::FilterSelections() {
}
// InsertCharacter inserts a character encoded in document code page.
-void Editor::InsertCharacter(const char *s, unsigned int len) {
+void Editor::InsertCharacter(const char *s, unsigned int len, CharacterSource charSource) {
if (len == 0) {
return;
}
@@ -1991,9 +1991,9 @@ void Editor::InsertCharacter(const char *s, unsigned int len) {
ch = utf32[0];
}
}
- NotifyChar(ch);
+ NotifyChar(ch, charSource);
- if (recordingMacro) {
+ if (recordingMacro && charSource != CharacterSource::tentativeInput) {
std::string copy(s, len); // ensure NUL-terminated
NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(copy.data()));
}
@@ -2339,10 +2339,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);
}
@@ -3088,7 +3089,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 9c3f3934c..4077fa1a4 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(const char *s, unsigned int len);
+ virtual void InsertCharacter(const char *s, unsigned int len, 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 a72267d32..1e7695d5f 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -79,20 +79,20 @@ void ScintillaBase::Finalise() {
}
void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool /*treatAsDBCS*/) {
- InsertCharacter(s, len);
+ InsertCharacter(s, len, CharacterSource::directInput);
}
-void ScintillaBase::InsertCharacter(const char *s, unsigned int len) {
+void ScintillaBase::InsertCharacter(const char *s, unsigned int len, CharacterSource charSource) {
const bool isFillUp = ac.Active() && ac.IsFillUpChar(s[0]);
if (!isFillUp) {
- Editor::InsertCharacter(s, len);
+ Editor::InsertCharacter(s, len, charSource);
}
if (ac.Active()) {
AutoCompleteCharacterAdded(s[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(s, len);
+ Editor::InsertCharacter(s, len, charSource);
}
}
}
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index dc1438155..e922ab057 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -64,7 +64,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(const char *s, unsigned int len) override;
+ void InsertCharacter(const char *s, unsigned int len, CharacterSource charSource) override;
void Command(int cmdId);
void CancelModes() override;
int KeyCommand(unsigned int iMessage) override;