Can't map Ctrl+M/Enter (in the `keys` table)
Andrew15-5 opened this issue · comments
I wanted to give this client a try, but immediately faced the keymap problem. It looks like for some reason Ctrl+M keymap is treated like Enter desp... ok, it looks like because it is Enter: https://www.physics.udel.edu/~watson/scen103/ascii.html. I'm guessing it's an upstream issue then?
config
[keys]
focus_guilds_tree = "Ctrl+R"
# focus_messages_text = "Ctrl+M"
# focus_message_input = "Ctrl+F"
focus_messages_text = "Ctrl+F"
focus_message_input = "Ctrl+M"
patch
diff --git a/cmd/main_flex.go b/cmd/main_flex.go
index ce6b6fc..adc065a 100644
--- a/cmd/main_flex.go
+++ b/cmd/main_flex.go
@@ -1,6 +1,9 @@
package cmd
import (
+ "fmt"
+ "os"
+
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
@@ -39,18 +42,45 @@ func (mf *MainFlex) init() {
mf.AddItem(right, 0, 4, false)
}
+func lg(text any) {
+ file := "/tmp/a"
+ b, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
+ if err != nil {
+ panic(err)
+ }
+ defer b.Close()
+ if _, err := fmt.Fprintf(b, "%s\n", text); err != nil {
+ panic(err)
+ }
+}
+
func (mf *MainFlex) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
+ lg("===================================================")
+ lg("===================================================")
+ lg("===================================================")
+ lg(cfg.Keys.FocusMessagesText)
+ lg(event.Key())
+ lg(event.Modifiers())
+ lg(event.Rune())
switch event.Name() {
case cfg.Keys.FocusGuildsTree:
+ lg(cfg.Keys.FocusGuildsTree)
+ lg("setting focus on app.SetFocus(mf.guildsTree)")
app.SetFocus(mf.guildsTree)
return nil
case cfg.Keys.FocusMessagesText:
+ lg(cfg.Keys.FocusMessagesText)
+ lg("setting focus on app.SetFocus(mf.messagesText)")
app.SetFocus(mf.messagesText)
return nil
case cfg.Keys.FocusMessageInput:
+ lg(cfg.Keys.FocusMessageInput)
+ lg("setting focus on app.SetFocus(mf.messageInput)")
app.SetFocus(mf.messageInput)
return nil
case cfg.Keys.ToggleGuildsTree:
+ lg(cfg.Keys.ToggleGuildsTree)
+ lg("setting focus on app.SetFocus(mf.guildsTree) 2")
// The guilds tree is visible if the numbers of items is two.
if mf.GetItemCount() == 2 {
mf.RemoveItem(mf.guildsTree)
@@ -64,6 +94,7 @@ func (mf *MainFlex) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
return nil
}
+ lg("Returning event")
return event
}
logs
tail -f /tmp/a
===================================================
===================================================
===================================================
Ctrl+F
%!s(tcell.Key=6)
%!s(tcell.ModMask=2)
%!s(int32=6)
Ctrl+F
setting focus on app.SetFocus(mf.messagesText)
===================================================
===================================================
===================================================
Ctrl+F
%!s(tcell.Key=18)
%!s(tcell.ModMask=2)
%!s(int32=18)
Ctrl+R
setting focus on app.SetFocus(mf.guildsTree)
===================================================
===================================================
===================================================
Ctrl+F
%!s(tcell.Key=13)
%!s(tcell.ModMask=0)
%!s(int32=13)
Returning event
Also looks like (Ctrl+)Shift/Alt modifier(s) doesn't work. At least for a few keys that I tested it with.
P.S. I recently switched to Engrammer layout and wanted to map Ctrl+rmf for the first 3 focus functions (just like with harpoon in Neovim), but looks like m
wouldn't be supported for a while.
Edit
I ended up with
focus_guilds_tree = "Ctrl+J"
focus_messages_text = "Ctrl+A"
focus_message_input = "Ctrl+K"
for now. It's like pressing ←, ↑, and → — very intuitive physically (but not "lettery-based").
Unfortunately, that's how terminals work.
Hmm, I guess it really is not possible. I tried binding it in Neovim and Zellij and nothing changed. I didn't really have this issue before, but now I know.