aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ScintillaBase.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-04-22 11:13:52 +1000
committerNeil <nyamatongwe@gmail.com>2025-04-22 11:13:52 +1000
commit99e69de57d94f4bcf8d72a69c9215684ee4152ee (patch)
treec9d4fb2406babae42a9772309becc59c017f3165 /src/ScintillaBase.cxx
parentac87d3e3b29fead6e30514535b8cf87dcc66304e (diff)
downloadscintilla-mirror-99e69de57d94f4bcf8d72a69c9215684ee4152ee.tar.gz
Move common IME code from platform layers to ScintillaBase.
Diffstat (limited to 'src/ScintillaBase.cxx')
-rw-r--r--src/ScintillaBase.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index a95df76ae..e19f75d36 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -213,6 +213,30 @@ void ScintillaBase::ListNotify(ListBoxEvent *plbe) {
}
}
+void ScintillaBase::MoveImeCarets(Sci::Position offset) noexcept {
+ // Move carets relatively by bytes.
+ for (size_t r = 0; r < sel.Count(); r++) {
+ const Sci::Position positionInsert = sel.Range(r).Start().Position();
+ sel.Range(r) = SelectionRange(positionInsert + offset);
+ }
+}
+
+void ScintillaBase::DrawImeIndicator(int indicator, Sci::Position len) {
+ // Emulate the visual style of IME characters with indicators.
+ // Draw an indicator on the character before caret by the character bytes of len
+ // so it should be called after InsertCharacter().
+ // It does not affect caret positions.
+ const IndicatorNumbers ind = static_cast<IndicatorNumbers>(indicator);
+ if (ind < IndicatorNumbers::Container || ind > IndicatorNumbers::Max) {
+ return;
+ }
+ pdoc->DecorationSetCurrentIndicator(indicator);
+ for (size_t r = 0; r < sel.Count(); r++) {
+ const Sci::Position positionInsert = sel.Range(r).Start().Position();
+ pdoc->DecorationFillRange(positionInsert - len, 1, len);
+ }
+}
+
void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, Sci::Position removeLen, std::string_view text) {
UndoGroup ug(pdoc);
if (multiAutoCMode == MultiAutoComplete::Once) {