vcom/internal/tui/keys/defaults.go
vrubelroman 526ba9270f feat(tui): key registry with contexts, layout translation and chords (6.1.1)
ActionIDs bound per input context; Browse/Info table from design §8.1,
modal and viewer contexts. ЙЦУКЕН keys are translated for command
contexts only, text contexts pass everything but control keys through
(U-P1-5); chords (y y) use a per-context buffer; help and footer are
generated from the table (U-P1-16).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 08:55:59 +03:00

34 lines
868 B
Go

package keys
import "unicode"
// DefaultBindings collects the bindings of every feature file. Features add
// their own bindings_<feature>.go so parallel work does not touch one file.
func DefaultBindings() []Binding {
var out []Binding
for _, part := range [][]Binding{
browseBindings(), modalBindings(), viewerBindings(),
opsBindings(), sshBindings(), archiveBindings(), miscBindings(),
} {
out = append(out, part...)
}
return out
}
// Translate maps a key typed in the ЙЦУКЕН layout to its QWERTY name, for
// matching per-modal hotkeys (dialog buttons) the same way Resolve does.
// Other keys are returned unchanged.
func Translate(k string) string {
rs := []rune(k)
if len(rs) != 1 {
return k
}
q, ok := jcuken[unicode.ToLower(rs[0])]
if !ok {
return k
}
if unicode.IsUpper(rs[0]) {
q = unicode.ToUpper(q)
}
return string(q)
}