Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Add support for Emacs style key sequences #30

Open
marcusolsson opened this issue Jun 4, 2017 · 2 comments
Open

Add support for Emacs style key sequences #30

marcusolsson opened this issue Jun 4, 2017 · 2 comments

Comments

@marcusolsson
Copy link
Owner

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() })
@grafov
Copy link

grafov commented Nov 3, 2017

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

@cceckman
Copy link
Contributor

cceckman commented Nov 5, 2017

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="ε"];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants