New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling the ESCape key #47
Comments
Hi @phf, On one hand, I hardcoded it to avoid adding "tricky" options to the gocui's API, making it simple for the users. On the other hand, I chose
I always remember having troubles, depending on the terminal emulator, to make the ALT/META key works. So, you ended up using 'ESC+' or mapping ALT/META to 'ESC+'. The same happens in OSX and, for instance, iTerm2 recommends: So, for example, when you press "ALT+2", it will send ESC+2. To bind this combination in gocui, you can use: if err := g.SetKeybinding("someView", '2', gocui.ModAlt, someFunc); err != nil {
return err
} Because it uses |
I'm trying to create an editor interface similar to vim with a normal mode and an insert mode. It feels like it should be easy to do this, but when I bind j in ModAlt mode I have to press Esc every time. What am I missing? if err := g.SetKeybinding("main", 'j', gocui.ModAlt, cursorDown); err != nil {
return err
} |
@micronix please take a look at my previous comment. There you have the explanation and solution to that. |
Closed due to inactivity. |
The PR #56 makes the KeyESC binding work correctly. |
At first I was confused why your demos all exit on CTRL-C instead of ESC. Then I noticed that any handler I install for KeyEsc will be ignored. I eventually traced this back to gocui hardcoding the termbox.InputAlt input mode in the MainLoop method in gui.go. If I hack the code to set termbox.InputEsc instead, I get the behavior I want. My first instinct is that this should be the application's choice, not gocui's. However, I may be missing something about what gocui needs in order to work. Any hints?
The text was updated successfully, but these errors were encountered: