From 36dceecd58872777d870c8bf9636bd886365f8e9 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 28 Jan 2017 02:54:47 +0900 Subject: [PATCH] Add support for ctrl-space key Close #825 --- CHANGELOG.md | 1 + man/man1/fzf.1 | 1 + src/options.go | 2 ++ src/tui/light.go | 2 ++ src/tui/ncurses.go | 2 ++ src/tui/tcell.go | 2 ++ src/tui/tui.go | 1 + 7 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a5bcd..37ede60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ CHANGELOG switching to the alternate screen. This is useful when the process is short-lived and you're not interested in its output. - e.g. `fzf --bind 'ctrl-y:execute!(echo -n {} | pbcopy)'` +- `ctrl-space` is allowed in `--bind` 0.16.2 ------ diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index 95d0380..f747273 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -426,6 +426,7 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR .B AVAILABLE KEYS: (SYNONYMS) \fIctrl-[a-z]\fR + \fIctrl-space\fR \fIalt-[a-z]\fR \fIalt-[0-9]\fR \fIf[1-12]\fR diff --git a/src/options.go b/src/options.go index d29f8bf..3fadb4e 100644 --- a/src/options.go +++ b/src/options.go @@ -393,6 +393,8 @@ func parseKeyChords(str string, message string) map[int]string { chord = tui.AltZ + int(' ') case "bspace", "bs": chord = tui.BSpace + case "ctrl-space": + chord = tui.CtrlSpace case "alt-enter", "alt-return": chord = tui.AltEnter case "alt-space": diff --git a/src/tui/light.go b/src/tui/light.go index b141368..90b3bae 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -322,6 +322,8 @@ func (r *LightRenderer) GetChar() Event { return Event{CtrlQ, 0, nil} case 127: return Event{BSpace, 0, nil} + case 0: + return Event{CtrlSpace, 0, nil} case ESC: ev := r.escSequence(&sz) // Second chance diff --git a/src/tui/ncurses.go b/src/tui/ncurses.go index 2706c91..978b2e7 100644 --- a/src/tui/ncurses.go +++ b/src/tui/ncurses.go @@ -475,6 +475,8 @@ func (r *FullscreenRenderer) GetChar() Event { return escSequence() case 127: return Event{BSpace, 0, nil} + case 0: + return Event{CtrlSpace, 0, nil} } // CTRL-A ~ CTRL-Z if c >= CtrlA && c <= CtrlZ { diff --git a/src/tui/tcell.go b/src/tui/tcell.go index 4836bf3..aa67ae1 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -270,6 +270,8 @@ func (r *FullscreenRenderer) GetChar() Event { return Event{CtrlY, 0, nil} case tcell.KeyCtrlZ: return Event{CtrlZ, 0, nil} + case tcell.KeyCtrlSpace: + return Event{CtrlSpace, 0, nil} case tcell.KeyBackspace, tcell.KeyBackspace2: if alt { return Event{AltBS, 0, nil} diff --git a/src/tui/tui.go b/src/tui/tui.go index c8bd5fb..2508aa6 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -38,6 +38,7 @@ const ( CtrlY CtrlZ ESC + CtrlSpace Invalid Resize