diff options
author | mitchell <unknown> | 2019-07-11 12:49:28 -0400 |
---|---|---|
committer | mitchell <unknown> | 2019-07-11 12:49:28 -0400 |
commit | e305512e58c726ef1855ffec4af69c90cfc9e396 (patch) | |
tree | 9ac416d8c4d4c676d9bf8b7c6f546e179b583616 /src/Editor.cxx | |
parent | f40378978a7b3bb901a2085a2c76b1ac4a3f45a0 (diff) | |
download | scintilla-mirror-e305512e58c726ef1855ffec4af69c90cfc9e396.tar.gz |
Backport: Feature [feature-requests:#1293]. InsertCharacter replaces AddCharUTF.
Backport of changeset 7575:e1e9f53b0423.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 11 |
1 files changed, 6 insertions, 5 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())); } } |