From 99e69de57d94f4bcf8d72a69c9215684ee4152ee Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 22 Apr 2025 11:13:52 +1000 Subject: Move common IME code from platform layers to ScintillaBase. --- src/ScintillaBase.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/ScintillaBase.cxx') 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(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) { -- cgit v1.2.3