mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-22 12:55:17 +00:00
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:
parent
45143f9541
commit
f6c6e59a50
@ -219,7 +219,7 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR
|
||||
.RE
|
||||
|
||||
.RS
|
||||
\fBACTION: DEFAULT BINDINGS:
|
||||
\fBACTION: DEFAULT BINDINGS (NOTES):
|
||||
\fBabort\fR \fIctrl-c ctrl-g ctrl-q esc\fR
|
||||
\fBaccept\fR \fIenter double-click\fR
|
||||
\fBbackward-char\fR \fIctrl-b left\fR
|
||||
@ -249,6 +249,8 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR
|
||||
\fBtoggle\fR
|
||||
\fBtoggle-all\fR
|
||||
\fBtoggle-down\fR \fIctrl-i (tab)\fR
|
||||
\fBtoggle-in\fR (\fB--reverse\fR ? \fBtoggle-up\fR : \fBtoggle-down\fR)
|
||||
\fBtoggle-out\fR (\fB--reverse\fR ? \fBtoggle-down\fR : \fBtoggle-up\fR)
|
||||
\fBtoggle-sort\fR (equivalent to \fB--toggle-sort\fR)
|
||||
\fBtoggle-up\fR \fIbtab (shift-tab)\fR
|
||||
\fBunix-line-discard\fR \fIctrl-u\fR
|
||||
|
@ -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":
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user