Refactor keyboard action handling and improve text parsing - #2060
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors keyboard key/action handling by replacing the previous Keycode enum-based mapping with a new KeyCode utility and a KeyActionToken model, while extending generated RimeKeyMapping helpers to support synthetic codes for uppercase letters and symbols.
Changes:
- Add synthetic keycode ranges (uppercase + symbols) and lookup helpers to the generated
RimeKeyMapping. - Introduce
KeyCodeand migrate parsing/display-label logic away from the removedime/enums/Keycode.kt. - Update theme YAML preset key
sendvalues to match the new keycode/name handling.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| codegen/src/main/java/com/osfans/trime/codegen/GenKeyMapping.kt | Extends generated mapping with synthetic code offsets and new lookup/query functions. |
| app/src/main/java/com/osfans/trime/ime/keyboard/KeyCode.kt | New keycode/name parsing and display-label logic replacing Keycode enum utilities. |
| app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardActionListener.kt | API adjustment (removes onRelease, renames onText parameter). |
| app/src/main/java/com/osfans/trime/ime/keyboard/Keyboard.kt | Updates clickability checks to align with nullable click tokens. |
| app/src/main/java/com/osfans/trime/ime/keyboard/KeyAction.kt | Migrates KeyAction construction/parsing to KeyActionToken and KeyCode. |
| app/src/main/java/com/osfans/trime/ime/keyboard/Key.kt | Adjusts behavior/action map construction for nullable tokens. |
| app/src/main/java/com/osfans/trime/ime/keyboard/CommonKeyboardActionListener.kt | Refactors key event mapping and text tokenization for simulated sequences. |
| app/src/main/java/com/osfans/trime/ime/enums/Keycode.kt | Removes the old enum-based keycode mapping implementation. |
| app/src/main/java/com/osfans/trime/data/theme/model/TextKeyboard.kt | Switches click/behavior action fields to KeyActionToken? and decodes accordingly. |
| app/src/main/java/com/osfans/trime/data/theme/model/KeyActionToken.kt | Adds a new Parcelable token model for scalar vs inline-mapping actions. |
| app/src/main/java/com/osfans/trime/data/theme/KeyActionManager.kt | Updates cache keys and overloads to support KeyActionToken. |
| app/src/main/assets/shared/trime.yaml | Updates preset key send values to new names (e.g. FUNCTION/SWITCH_CHARSET/SEARCH). |
| app/src/main/assets/shared/tongwenfeng.trime.yaml | Same preset key send normalization as shared config. |
| app/src/test/assets/trime.yaml | Mirrors shared YAML send updates for test assets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge the regex patterns to simplify the matching.
Collaborator
Author
|
The changes in this PR have verified in the community. Everything looks fine. |
Bambooin
approved these changes
Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request
Issue tracker
Fixes will automatically close the related issues
Fixes # N/A
Feature
Describe features of this pull request
Code of conduct
Code style
make sytle-lintBuild pass
make debugManually test
Code Review
Daily build
Login and download artifact at https://github.com/osfans/trime/actions
Additional Info