From 314c2c5afa316a8044c589bc3cc3448f8796be6a Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 12 Nov 2021 17:54:40 +0900 Subject: [PATCH] =?UTF-8?q?fixme:=20=EC=A1=B0=ED=95=A9=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=EB=90=9C=20'=E1=84=83=E1=86=9E=E1=86=AF'=EC=9D=84=20?= =?UTF-8?q?=EC=A7=80=EC=9A=B0=EB=A9=B4=20=EC=A2=85=EC=84=B1=EB=A7=8C=20?= =?UTF-8?q?=EC=A7=80=EC=9B=8C=EC=A7=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terrarum/ui/UIItemTextLineInput.kt | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt index fadc2e778..c23722785 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt @@ -177,17 +177,35 @@ class UIItemTextLineInput( private fun inputBackspaceOnce(dbgprn: Int = 0) { if (cursorX > 0) { - while (true) { - cursorX -= 1 -// val oldlen = textbuf.size - val oldChar = textbuf.removeAt(cursorX) - val charFore = textbuf.lastOrNull() -// val newlen = textbuf.size + var characterTrailersDeleted = 0 -// if (dbgprn > 0) printdbg(this, "${dbgprn}del char U+${oldChar.toString(16)} '${String(intArrayOf(oldChar), 0, if (oldChar > 65535) 2 else 1)}'; length: $oldlen -> $newlen") - // continue deleting hangul pieces because of the font... - if (cursorX == 0 || (charFore !in 0x1100..0x11A7 && charFore !in 0xA960..0xA97F && charFore !in 0xD7B0..0xD7CA)) break + while (cursorX > 0) { + val charToDelet = textbuf.lastOrNull() + + if (charToDelet != null) { + if (dbgprn > 0) { + printdbg(this, "$dbgprn)charToDelet=U+${charToDelet.toString(16).uppercase()} '${String(intArrayOf(charToDelet), 0, if (charToDelet > 65535) 2 else 1)}', characterTrailersDeleted=${characterTrailersDeleted}") + } + + // continue deleting hangul pieces because of the font... + if (characterTrailersDeleted >= 2 && charToDelet in 0x1160..0x11A7) { + break + } + else if (charToDelet in 0x1100..0x11A7) { // TODO diacritics, unicode ZWJ shits + characterTrailersDeleted += 1 + cursorX -= 1 + textbuf.removeAt(cursorX) + } + else if (characterTrailersDeleted > 0) { + break + } + else { + cursorX -= 1 + textbuf.removeAt(cursorX) + break + } + } } cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX))) @@ -302,7 +320,7 @@ class UIItemTextLineInput( repeat(op.first[0].toInt()) { if (textbuf.isNotEmpty()) { // printdbg(this, "") - inputBackspaceOnce() + inputBackspaceOnce(3) } } @@ -385,8 +403,10 @@ class UIItemTextLineInput( private fun endComposing() { getIME()?.let { - val s = it.endCompose() - paste(s.toCodePoints()) + if (it.config.mode != TerrarumIMEMode.REWRITE) { + val s = it.endCompose() + paste(s.toCodePoints()) + } } fboUpdateLatch = true candidates = listOf()