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"
This commit is contained in:
Junegunn Choi
2016-01-14 02:35:43 +09:00
parent 45143f9541
commit f6c6e59a50
3 changed files with 19 additions and 1 deletions

View File

@@ -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()