diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2020-12-30 01:59:18 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2020-12-30 18:39:17 +0900 |
| commit | 7f8e0dbc408eff786865d0e2d9e3c62ec3ed4776 (patch) | |
| tree | deeac2dc561a2ccd5bf444f4180abb43bff060be /src/tui/tui.go | |
| parent | 0de7ab18f64db7838c8ca06d08188f976cbfdbb4 (diff) | |
| download | fzf-7f8e0dbc408eff786865d0e2d9e3c62ec3ed4776.tar.gz | |
Extend support for alt key chords
"alt-" with any case-sensitive character is allowed
Diffstat (limited to 'src/tui/tui.go')
| -rw-r--r-- | src/tui/tui.go | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/tui/tui.go b/src/tui/tui.go index edbc9a14..cc9c7f67 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -8,8 +8,10 @@ import ( ) // Types of user action +type EventType int + const ( - Rune = iota + Rune EventType = iota CtrlA CtrlB @@ -89,8 +91,6 @@ const ( Change BackwardEOF - AltSpace - AltSlash AltBS AltUp @@ -103,20 +103,38 @@ const ( AltSLeft AltSRight - Alt0 + Alt + CtrlAlt ) -const ( // Reset iota - AltA = Alt0 + 'a' - '0' + iota - AltB - AltC - AltD - AltE - AltF - AltZ = AltA + 'z' - 'a' - CtrlAltA = AltZ + 1 - CtrlAltM = CtrlAltA + 'm' - 'a' -) +func (t EventType) AsEvent() Event { + return Event{t, 0, nil} +} + +func (t EventType) Int() int { + return int(t) +} + +func (t EventType) Byte() byte { + return byte(t) +} + +func (e Event) Comparable() Event { + // Ignore MouseEvent pointer + return Event{e.Type, e.Char, nil} +} + +func Key(r rune) Event { + return Event{Rune, r, nil} +} + +func AltKey(r rune) Event { + return Event{Alt, r, nil} +} + +func CtrlAltKey(r rune) Event { + return Event{CtrlAlt, r, nil} +} const ( doubleClickDuration = 500 * time.Millisecond @@ -251,7 +269,7 @@ type ColorTheme struct { } type Event struct { - Type int + Type EventType Char rune MouseEvent *MouseEvent } |
