diff options
| author | Erik Kundiman <erik@megapahit.org> | 2024-01-29 17:42:38 +0800 |
|---|---|---|
| committer | Erik Kundiman <erik@megapahit.org> | 2024-01-30 12:06:48 +0800 |
| commit | aaa8cb5a37a720ff67792d0a31fec793b03b3742 (patch) | |
| tree | 734ce89b2f133f1fd55cd04e5e79eb5c1ed06d50 /indra/llui/lllineeditor.cpp | |
| parent | 4c97df0ab1b450d5680975e18e894b6676a589ee (diff) | |
First attempt to fix unicode input
It should work well enough with most, but on Japanese (I assume all CJK),
for now the composition part is still left printed out along with the result
(as opposed to just replaced by the result). It's to be fixed next.
Diffstat (limited to 'indra/llui/lllineeditor.cpp')
| -rw-r--r-- | indra/llui/lllineeditor.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 60dbfd68c6..34d08b99de 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -1009,6 +1009,21 @@ void LLLineEditor::addChar(const llwchar uni_char) getWindow()->hideCursorUntilMouseMove(); } +void LLLineEditor::addString(char *s) +{ + if (hasSelection()) + deleteSelection(); + else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) { + if (!prevalidateInput(mText.getWString() + .substr(getCursor(), 1))) + return; + mText.erase(getCursor(), 1); + } + mText.insert(getCursor(), utf8str_to_wstring(s)); + setCursor(getCursor() + 1); + getWindow()->hideCursorUntilMouseMove(); +} + // Extends the selection box to the new cursor position void LLLineEditor::extendSelection( S32 new_cursor_pos ) { @@ -1650,6 +1665,36 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char) return handled; } +BOOL LLLineEditor::handleUnicodeStringHere(char *uni_str) +{ + auto handled = FALSE; + + if ((gFocusMgr.getKeyboardFocus() == this) + && getVisible() && !mReadOnly) { + handled = TRUE; + LLLineEditorRollback rollback(this); + + addString(uni_str); + + mKeystrokeTimer.reset(); + deselect(); + auto need_to_rollback = FALSE; + need_to_rollback |= (mPrevalidateFunc + && !mPrevalidateFunc(mText.getWString())); + + if (need_to_rollback) { + rollback.doRollback(this); + LLUI::getInstance()->reportBadKeystroke(); + } + + if (!need_to_rollback && handled) { + onKeystroke(); + mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY); + } + } + + return handled; +} BOOL LLLineEditor::canDoDelete() const { |
