Skip to content

Commit

Permalink
fix: space key always showed current schema name
Browse files Browse the repository at this point in the history
We should make it show the theme desired label first
  • Loading branch information
WhiredPlanck committed Nov 10, 2024
1 parent db3fdf5 commit b5fbc33
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/src/main/java/com/osfans/trime/ime/keyboard/KeyAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class KeyAction(
option = it.getValue("option")?.getString() ?: ""
select = it.getValue("select")?.getString() ?: ""
toggle = it.getValue("toggle")?.getString() ?: ""
label = it.getValue("label")?.getString() ?: ""
preview = it.getValue("preview")?.getString() ?: ""
shiftLock = it.getValue("shift_lock")?.getString() ?: ""
commit = it.getValue("commit")?.getString() ?: ""
Expand All @@ -138,18 +139,18 @@ class KeyAction(
code = KeyEvent.KEYCODE_FUNCTION
}

if (code == KeyEvent.KEYCODE_SPACE) {
label = Rime.currentSchemaName
} else if (code != KeyEvent.KEYCODE_UNKNOWN) {
label = it
.getValue("label")
?.getString()
?.ifEmpty { Keycode.getDisplayLabel(code, modifier) } ?: ""
if (label.isEmpty()) {
if (code == KeyEvent.KEYCODE_SPACE) {
label = Rime.currentSchemaName
} else if (code != KeyEvent.KEYCODE_UNKNOWN) {
label = Keycode.getDisplayLabel(code, modifier)
}
}
}
} else {
// match like: { x: 1 } or { x: q } ...
code = Keycode.keyCodeOf(unbraced)
// match like: { x: "(){Left}" } (key sequence to simulate)
if (unbraced.isNotEmpty() && code == KeyEvent.KEYCODE_UNKNOWN) {
text = raw
label = raw.replace(BRACED_STR, "")
Expand Down

0 comments on commit b5fbc33

Please sign in to comment.