summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-01-14 02:35:43 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-01-14 02:35:43 +0900
commitf6c6e59a50d580595fd5117ab51b058988fc5f83 (patch)
tree13051b91ef1f667a3860d5c66d8161503bd573c4 /src
parent45143f9541d55c5efdadc7ea8acd9474a19eb8c6 (diff)
Add toggle-in and toggle-out for --bind
Related: #452 When `--multi` is set, tab key will bring your cursor down, and shift-tab up. But since fzf by default draws the screen in bottom-up fashion, one may feel that the opposite of the behavior is more desirable and choose to customize the key bindings as follows. export FZF_DEFAULT_OPTS="--bind tab:toggle-up,shift-tab:toggle-down" This configuration, however, becomes no longer straightforward when `--reverse` is set and fzf switches to top-down layout. To address the requirement, this commit adds `toggle-in` and `toggle-out` option which switch direction depending on `--reverse`-ness. export FZF_DEFAULT_OPTS="--bind tab:toggle-out,shift-tab:toggle-in"
Diffstat (limited to 'src')
-rw-r--r--src/options.go4
-rw-r--r--src/terminal.go12
2 files changed, 16 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index 6399343c..962e516e 100644
--- a/src/options.go
+++ b/src/options.go
@@ -566,6 +566,10 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b
keymap[key] = actToggleDown
case "toggle-up":
keymap[key] = actToggleUp
+ case "toggle-in":
+ keymap[key] = actToggleIn
+ case "toggle-out":
+ keymap[key] = actToggleOut
case "toggle-all":
keymap[key] = actToggleAll
case "select-all":
diff --git a/src/terminal.go b/src/terminal.go
index 381ae7c5..ab11587f 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -125,6 +125,8 @@ const (
actToggleAll
actToggleDown
actToggleUp
+ actToggleIn
+ actToggleOut
actDown
actUp
actPageUp
@@ -949,6 +951,16 @@ func (t *Terminal) Loop() {
}
req(reqList, reqInfo)
}
+ case actToggleIn:
+ if t.reverse {
+ return doAction(actToggleUp, mapkey)
+ }
+ return doAction(actToggleDown, mapkey)
+ case actToggleOut:
+ if t.reverse {
+ return doAction(actToggleDown, mapkey)
+ }
+ return doAction(actToggleUp, mapkey)
case actToggleDown:
if t.multi && t.merger.Length() > 0 {
toggle()