Skip to content

layout-agnostic key bindings for non-Latin keyboards - #71

Merged
umputun merged 1 commit into
umputun:masterfrom
sanchesfree:feature/layout-agnostic-keys-v2
Apr 8, 2026
Merged

umputun merged 1 commit into
umputun:masterfrom
sanchesfree:feature/layout-agnostic-keys-v2

Conversation

@sanchesfree

Copy link
Copy Markdown
Contributor

Summary

Hotkeys now work regardless of the active keyboard layout. Pressing г (Cyrillic) triggers the same action as u, ξ (Greek) as j, ח (Hebrew) as j — all based on physical key position.

How it works

A transparent fallback in Keymap.Resolve(): when a pressed key has no direct binding and is a known non-Latin character, it is translated to its Latin QWERTY equivalent and looked up again. Purely additive — existing behavior unchanged.

Design decisions:

  • Only non-ASCII characters mapped. ASCII like ; or , exist at different positions across layouts — mapping them would be ambiguous.
  • No interface changes, no new flags, no config. Invisible to users who don't need it.
  • Help overlay, --dump-keys, KeysFor() unaffected — canonical Latin bindings only.

Supported layouts

Layout Script Users
Russian ЙЦУКЕН Cyrillic ~150M
Ukrainian Cyrillic ~40M
Belarusian, Kazakh, Serbian Cyrillic Cyrillic ~25M
Greek Greek ~13M
Hebrew Hebrew ~10M

CJK layouts don't need this (IME sends Latin). Latin-script layouts already send correct letters.

Files changed

  • app/keymap/layout.go (new) — static map[rune]rune + layoutResolve()
  • app/keymap/keymap.go — Resolve() tries layout alias on miss (3 lines)
  • app/keymap/layout_test.go (new) — unit + integration tests

Extensibility

Adding a layout = appending entries to the map. Arabic, Thai, etc. can be added the same way.

When a non-Latin keyboard layout is active (Russian, Greek, Hebrew),
hotkeys work based on physical key position. Pressing г triggers the
same action as u, ξ as j, ח as j — all transparent via Resolve().

- layout.go: static rune→rune map for 3 layouts (~150 entries)
- keymap.go: Resolve() fallback tries layout alias on miss
- layout_test.go: unit + integration tests for all layouts

Only non-ASCII characters mapped to avoid ambiguity.
@sanchesfree
sanchesfree requested a review from umputun as a code owner April 8, 2026 19:25
@sanchesfree

Copy link
Copy Markdown
Contributor Author

sorry for the noise — the original PR (#64) got auto-closed by GitHub after a force push to remove stray files from commit history. couldn't reopen it, so this is a clean re-creation with the same code (single commit, no junk).

reference: #64

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thx. all feedback from #64 addressed - Ukrainian і→s fixed, test names match assertions, debug files removed, shared km mutation fixed.

@umputun
umputun merged commit 5adb061 into umputun:master Apr 8, 2026
1 check passed
umputun added a commit that referenced this pull request Apr 8, 2026
Move standalone Save/gitDiff/gitCommitHash/filterRepoFiles functions
to methods on Service struct. Extract history save logic from run()
into saveHistory() with histReq parameter struct. Fix gofmt indentation
in layout.go from merged PR #71.
umputun added a commit that referenced this pull request Apr 8, 2026
* feat: add review history auto-save on quit

Add app/history/ package that saves review session history to
~/.config/revdiff/history/<repo>/<timestamp>.md on quit. Includes
header metadata, annotations, and git diff for annotated files.
Wired into main app quit path. All errors logged, never fatal.

* refactor(history): use Service struct and extract saveHistory helper

Move standalone Save/gitDiff/gitCommitHash/filterRepoFiles functions
to methods on Service struct. Extract history save logic from run()
into saveHistory() with histReq parameter struct. Fix gofmt indentation
in layout.go from merged PR #71.

* fix: improve git diff error logging and clarify non-git history paths

Capture stderr from git diff failures for better diagnostics.
Clarify docs that --stdin saves under stdin/ subdir and --only
uses parent directory name instead of repo name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants