From 0d705dc8559657d7396efa0c3342e2c70d3844b4 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 7 Jan 2026 22:34:27 +0100 Subject: [PATCH] WIP Map CSI-u keypad keys Arguably, tcell should take care of this, but as long as it doesn't, map them on our side. --- .../jesseduffield/gocui/tcell_driver.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go index 6e9c12b4c..6a8222398 100644 --- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go +++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go @@ -263,6 +263,25 @@ func (wrapper TcellResizeEventWrapper) toTcellEvent() tcell.Event { return tcell.NewEventResize(wrapper.Width, wrapper.Height) } +var CSIu_keypad_mappings = map[rune]rune{ + 57399: '0', + 57400: '1', + 57401: '2', + 57402: '3', + 57403: '4', + 57404: '5', + 57405: '6', + 57406: '7', + 57407: '8', + 57408: '9', + 57409: '.', + 57410: '/', + 57411: '*', + 57412: '-', + 57413: '+', + 57415: '=', +} + // pollEvent get tcell.Event and transform it into gocuiEvent func (g *Gui) pollEvent() GocuiEvent { var tev tcell.Event @@ -295,6 +314,11 @@ func (g *Gui) pollEvent() GocuiEvent { // special handling for spacebar k = 32 // tcell keys ends at 31 or starts at 256 ch = rune(0) + } else if ch == 57414 { // the CSI-u value for KP_ENTER + k = tcell.KeyCR + ch = rune(0) + } else if str, ok := CSIu_keypad_mappings[ch]; ok { + ch = str } } mod := tev.Modifiers()