tui-go icon indicating copy to clipboard operation
tui-go copied to clipboard

Add support for Emacs style key sequences

Open marcusolsson opened this issue 7 years ago • 2 comments

For example, the key sequence, Ctrl+X followed by Ctrl+C.

Here's some API proposals (are there more?):

// Proposal 1
ui.SetKeybinding([]string{"Ctrl+X", "Ctrl+C"}, func() { ui.Quit() })

// Proposal 2
ui.SetKeybinding(func() { ui.Quit() }, "Ctrl+X", "Ctrl+C")

// Proposal 3
ui.SetKeybinding(tui.KeySequence("Ctrl+X", "Ctrl+C"), func() { ui.Quit() })

marcusolsson avatar Jun 04 '17 18:06 marcusolsson

Imho the proposal 2 with using of variable parameters is the most clean!

grafov avatar Nov 03 '17 21:11 grafov

Stopping by as a curious Vim user:

How close do the presses have to be to be considered the same event? Where is that timeout set (UI?)

Or is it just a prefix tree, where falling off resets:

ui.SetKeybinding(tui.KeySequence("Ctrl+X", "Ctrl+C"), func { ui.Quit() })
ui.SetKeybinding("Z", func { fmt.Println("You pressed Z!") })

Rendered link

digraph G {
  start -> v [label="Ctrl+X"] ;
  start ->  PRINT [label="Z"];
  v ->  QUIT [label="Ctrl+C"];
  v -> start [label="ε"];
}

cceckman avatar Nov 05 '17 19:11 cceckman