-
-
Notifications
You must be signed in to change notification settings - Fork 122
SetKeyBinding with ModCtrl + rune #26
Comments
There's currently no support for modifiers but this is definitely a must-have for an initial release. Apart from setting the API for The reason it takes an Maybe we could just change the signature into Example usage: ui.SetKeybinding('q', tui.ModNone, func() { ... }
ui.SetKeybinding(tui.KeySpace, tui.ModCtrl, func() { ... } |
I noticed this enum in tcell
So for example I forget why (I've been busy) but I didn't get it to work earlier |
Ok... so this isn't an acceptable solution or anything, but I got the
Problem is... I have no idea why this works. I mean, I have an idea, I logged the values of these when I smash the keyboard. But I don't really get where these values are coming from... |
Currently, package main
import (
"fmt"
)
func main() {
fmt.Println(int('n')) // 110
} While the ASCII code will be constant, the value of the The "magic" is done here: https://github.com/marcusolsson/tui-go/blob/master/ui_tcell.go#L56-L61 where we do a type switch on the I'm actually in the middle of rewriting the event handling, so I'd probably hold off on this issue a bit. If you're interested, there's a branch called |
Cool, thanks for clarifying -- I'll check in sometime next week 😸 |
No worries! Thanks for your interest in tui-go! |
Good to know you are working on it, I'm working on this little thing https://github.com/gonzaloserrano/git-br and would love to bind shift or cmd + enter :-) |
Cool project @sp-gonzalo-serrano ! :) While I am working on this, I'm currently trying to better understand terminal input handling. For example, from the tcell documentation:
Another example: a tcell key event could contain theoretically contain a I'm going to need to read up on this before attempting a solution. For now, I won't be able to make any promises as to when this will be done. (Meanwhile, I've just submitted a related pull request for event handling, that will unfortunately break some existing code) |
Hey! This all seems great, I really like the #29 method -- as you say, it might be more intuitive to new users who don't feel like understanding how the keybinding work 😉 -- also, my solution is more or less incomplete, (unable to perform the Shift-Enter needed by @sp-gonzalo-serrano ) It's not totally clear to me how the innerds of #29 work, but that also doesn't matter as long as I can Mod my keybindings 😄 . And the Emacs style sequences sounds awesome! I'm cool with closing #28 (I'm not invested in the pr I submitted) and this issue if your PR does the job. Thanks for responding/taking care of this issue so timely! |
Thank you both for your feedback, especially @fenimore for both creating the issue and submitting the initial pull request! Unfortunately, Shift+Enter and Ctrl+Enter does not yet seem to work for #29 either (although Alt+Enter does) so I'm guessing there's more to do there. Found this line that hints that Ctrl+Enter might have another code. Good thing is hopefully we'll be able to work on supporting the edge cases without users needing to bother. I'm going ahead and merging #29, but it'll need more testing. Adding tests for more key sequences to keybinding_test.go will be much appreciated ;-) |
Also, created #30 |
Hi, is it already possible to add keybindings with the
ModKeys
?If so I can't figure how from the docs and examples.
I see
SetKeybinding
takes(inter{}, func )
.How are
ModKey
events handled?The text was updated successfully, but these errors were encountered: