aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx11
-rw-r--r--src/Editor.h2
-rw-r--r--src/ScintillaBase.cxx12
-rw-r--r--src/ScintillaBase.h5
4 files changed, 19 insertions, 11 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 161e71706..eb8e4f521 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';
- AddCharUTF(s, 1);
+ InsertCharacter(s, 1);
}
void Editor::FilterSelections() {
@@ -1898,8 +1898,8 @@ void Editor::FilterSelections() {
}
}
-// AddCharUTF inserts an array of bytes which may or may not be in UTF-8.
-void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
+// InsertCharacter inserts a character encoded in document code page.
+void Editor::InsertCharacter(const char *s, unsigned int len) {
if (len == 0) {
return;
}
@@ -1974,7 +1974,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
}
int ch = static_cast<unsigned char>(s[0]);
- if (treatAsDBCS || pdoc->dbcsCodePage != SC_CP_UTF8) {
+ if (pdoc->dbcsCodePage != SC_CP_UTF8) {
if (len > 1) {
// DBCS code page or DBCS font character set.
ch = (ch << 8) | static_cast<unsigned char>(s[1]);
@@ -1994,7 +1994,8 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
NotifyChar(ch);
if (recordingMacro) {
- NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(s));
+ std::string copy(s, len); // ensure NUL-terminated
+ NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(copy.data()));
}
}
diff --git a/src/Editor.h b/src/Editor.h
index e8d1ed48e..9c3f3934c 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 AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
+ virtual void InsertCharacter(const char *s, unsigned int len);
void ClearBeforeTentativeStart();
void InsertPaste(const char *text, Sci::Position len);
enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 };
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 0c00309b7..a72267d32 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -78,17 +78,21 @@ void ScintillaBase::Finalise() {
popup.Destroy();
}
-void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
- const bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
+void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool /*treatAsDBCS*/) {
+ InsertCharacter(s, len);
+}
+
+void ScintillaBase::InsertCharacter(const char *s, unsigned int len) {
+ const bool isFillUp = ac.Active() && ac.IsFillUpChar(s[0]);
if (!isFillUp) {
- Editor::AddCharUTF(s, len, treatAsDBCS);
+ Editor::InsertCharacter(s, len);
}
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::AddCharUTF(s, len, treatAsDBCS);
+ Editor::InsertCharacter(s, len);
}
}
}
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index 39fb9d411..dc1438155 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -61,7 +61,10 @@ protected:
void Initialise() override {}
void Finalise() override;
- void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false) override;
+ // 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 Command(int cmdId);
void CancelModes() override;
int KeyCommand(unsigned int iMessage) override;