mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 22:31:52 +09:00
IME candidates separator to use \x1E instead of a comma
This commit is contained in:
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gamecontroller
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import java.io.File
|
||||
|
||||
typealias IMECanditates = List<String>
|
||||
typealias IMECandidates = List<String>
|
||||
typealias IMEOutput = String
|
||||
typealias Keysyms = Array<Array<String?>>
|
||||
|
||||
@@ -22,8 +22,8 @@ data class TerrarumIME(
|
||||
val name: String,
|
||||
val config: TerrarumIMEConf,
|
||||
// (headkey, shiftin, altgrin, lowLayerKeysym)
|
||||
val acceptChar: (Int, Boolean, Boolean, String) -> Pair<IMECanditates, IMEOutput>,
|
||||
val backspace: () -> IMECanditates,
|
||||
val acceptChar: (Int, Boolean, Boolean, String) -> Pair<IMECandidates, IMEOutput>,
|
||||
val backspace: () -> IMECandidates,
|
||||
val endCompose: () -> IMEOutput,
|
||||
val reset: () -> Unit,
|
||||
val composing: () -> Boolean
|
||||
|
||||
@@ -19,6 +19,10 @@ class IMEProviderDelegate(val ime: IME) {
|
||||
|
||||
class IMEDictionary(private val filename: String) {
|
||||
|
||||
companion object {
|
||||
const val CAND_DELIM = '\u001E'
|
||||
}
|
||||
|
||||
private val candidates = HashMap<String, String>(16384)
|
||||
private val keys = SortedArrayList<String>(16384) // keys on the .han file are absofreakinlutely not sorted
|
||||
|
||||
@@ -30,7 +34,7 @@ class IMEDictionary(private val filename: String) {
|
||||
if (it.contains(',')) {
|
||||
val (key, value) = it.split(',')
|
||||
if (candidates.containsKey(key)) {
|
||||
candidates[key] += ",$value"
|
||||
candidates[key] += "$CAND_DELIM$value"
|
||||
}
|
||||
else {
|
||||
candidates[key] = value
|
||||
@@ -80,8 +84,8 @@ class IMEDictionary(private val filename: String) {
|
||||
val keysym = allRelevantKeys[index]
|
||||
if (!keysym.startsWith(key)) break
|
||||
|
||||
val outstr = ",${candidates[keysym]}"
|
||||
outsize += outstr.count { it == ',' }
|
||||
val outstr = "$CAND_DELIM${candidates[keysym]}"
|
||||
outsize += outstr.count { it == CAND_DELIM }
|
||||
out.append(outstr)
|
||||
|
||||
index += 1
|
||||
|
||||
Reference in New Issue
Block a user