diff options
| author | Vlastimil Ovčáčík <vovcacik@github.ovcacik.org> | 2021-09-20 19:48:53 +0200 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2021-10-03 01:39:30 +0900 |
| commit | 4271e9cffae06b0b98d334d67ff7f0f5f9da80b0 (patch) | |
| tree | 7d8bc27dc74b89145ee70a5c2d016107ee44948a /src/tui | |
| parent | f3dc8a10d5b5a639f7924cf32f2e02f0f9c48e67 (diff) | |
| download | fzf-4271e9cffae06b0b98d334d67ff7f0f5f9da80b0.tar.gz | |
Fix Ctrl+Space key combination to emit CtrlSpace instead of Rune ' '
Diffstat (limited to 'src/tui')
| -rw-r--r-- | src/tui/tcell.go | 3 | ||||
| -rw-r--r-- | src/tui/tcell_test.go | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/tui/tcell.go b/src/tui/tcell.go index be22d87c..8ef3fba3 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -396,6 +396,9 @@ func (r *FullscreenRenderer) GetChar() Event { r := ev.Rune() switch { + // translate native key events to ascii control characters + case r == ' ' && ctrl: + return Event{CtrlSpace, 0, nil} // handle AltGr characters case ctrlAlt: return Event{Rune, r, nil} // dropping modifiers diff --git a/src/tui/tcell_test.go b/src/tui/tcell_test.go index 5aff3926..1a10faf2 100644 --- a/src/tui/tcell_test.go +++ b/src/tui/tcell_test.go @@ -91,7 +91,7 @@ func TestGetCharEventKey(t *testing.T) { // section 2: Ctrl+[ \]_] {giveKey{tcell.KeyCtrlSpace, rune(tcell.KeyCtrlSpace), tcell.ModCtrl}, wantKey{CtrlSpace, 0, nil}}, // fabricated {giveKey{tcell.KeyNUL, rune(tcell.KeyNUL), tcell.ModNone}, wantKey{CtrlSpace, 0, nil}}, // fabricated, unhandled - {giveKey{tcell.KeyRune, ' ', tcell.ModCtrl}, wantKey{Rune, ' ', nil}}, // actual Ctrl+' ' + {giveKey{tcell.KeyRune, ' ', tcell.ModCtrl}, wantKey{CtrlSpace, 0, nil}}, // actual Ctrl+' ' {giveKey{tcell.KeyCtrlBackslash, rune(tcell.KeyCtrlBackslash), tcell.ModCtrl}, wantKey{CtrlBackSlash, 0, nil}}, {giveKey{tcell.KeyCtrlRightSq, rune(tcell.KeyCtrlRightSq), tcell.ModCtrl}, wantKey{CtrlRightBracket, 0, nil}}, {giveKey{tcell.KeyCtrlUnderscore, rune(tcell.KeyCtrlUnderscore), tcell.ModShift | tcell.ModCtrl}, wantKey{CtrlSlash, 0, nil}}, |
