chinese IME almost done

This commit is contained in:
minjaesong
2021-10-27 11:45:56 +09:00
parent b0b1d185ad
commit 0dbcd0711b
9 changed files with 23831 additions and 22 deletions

View File

@@ -0,0 +1,35 @@
package net.torvald.terrarum.gamecontroller
import java.io.File
import java.io.FileReader
class IMEProviderDelegate(val ime: IME) {
private val dictionaries = HashMap<String, IMEDictionary>()
fun requestDictionary(filename: String): IMEDictionary {
return dictionaries.getOrPut(filename) { IMEDictionary(filename) }
}
}
class IMEDictionary(filename: String) {
private val candidates = HashMap<String, String>()
init {
val reader = FileReader(File("assets/keylayout/", filename))
reader.forEachLine {
val (key, value) = it.split(',')
if (candidates.containsKey(key)) {
candidates[key] += ",$value"
}
else {
candidates[key] = value
}
}
}
operator fun get(key: String): String = candidates[key] ?: ""
}