mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-02-09 15:38:42 +00:00
Add key combinations for ctrl-delete and shift-delete (#3284)
Currently there is not option to bind ctrl-delete and shift-delete. As suggested by issue #3240, shift-delete could be used to bind "delete entry from history" as it is a common way to do so in other applications, e.g. browsers. This, however, does only implement to use the key combination itself and does not assign a default action to any of them. This does enable to call one's all predefined actions. With the exec action this can expanded like the issue #3240 suggested. If desirable, the key combinations could later get a default behavior. Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
This commit is contained in:
parent
e2dd2a133e
commit
37f258b1bf
@ -873,6 +873,8 @@ e.g.
|
|||||||
.br
|
.br
|
||||||
\fIctrl-space\fR
|
\fIctrl-space\fR
|
||||||
.br
|
.br
|
||||||
|
\fIctrl-delete\fR
|
||||||
|
.br
|
||||||
\fIctrl-\\\fR
|
\fIctrl-\\\fR
|
||||||
.br
|
.br
|
||||||
\fIctrl-]\fR
|
\fIctrl-]\fR
|
||||||
@ -941,6 +943,8 @@ e.g.
|
|||||||
.br
|
.br
|
||||||
\fIshift-right\fR
|
\fIshift-right\fR
|
||||||
.br
|
.br
|
||||||
|
\fIshift-delete\fR
|
||||||
|
.br
|
||||||
\fIalt-shift-up\fR
|
\fIalt-shift-up\fR
|
||||||
.br
|
.br
|
||||||
\fIalt-shift-down\fR
|
\fIalt-shift-down\fR
|
||||||
|
@ -614,6 +614,8 @@ func parseKeyChordsImpl(str string, message string, exit func(string)) map[tui.E
|
|||||||
add(tui.BSpace)
|
add(tui.BSpace)
|
||||||
case "ctrl-space":
|
case "ctrl-space":
|
||||||
add(tui.CtrlSpace)
|
add(tui.CtrlSpace)
|
||||||
|
case "ctrl-delete":
|
||||||
|
add(tui.CtrlDelete)
|
||||||
case "ctrl-^", "ctrl-6":
|
case "ctrl-^", "ctrl-6":
|
||||||
add(tui.CtrlCaret)
|
add(tui.CtrlCaret)
|
||||||
case "ctrl-/", "ctrl-_":
|
case "ctrl-/", "ctrl-_":
|
||||||
@ -684,6 +686,8 @@ func parseKeyChordsImpl(str string, message string, exit func(string)) map[tui.E
|
|||||||
add(tui.SLeft)
|
add(tui.SLeft)
|
||||||
case "shift-right":
|
case "shift-right":
|
||||||
add(tui.SRight)
|
add(tui.SRight)
|
||||||
|
case "shift-delete":
|
||||||
|
add(tui.SDelete)
|
||||||
case "left-click":
|
case "left-click":
|
||||||
add(tui.LeftClick)
|
add(tui.LeftClick)
|
||||||
case "right-click":
|
case "right-click":
|
||||||
|
@ -430,7 +430,19 @@ func (r *LightRenderer) escSequence(sz *int) Event {
|
|||||||
}
|
}
|
||||||
return Event{Invalid, 0, nil} // INS
|
return Event{Invalid, 0, nil} // INS
|
||||||
case '3':
|
case '3':
|
||||||
|
if r.buffer[3] == '~' {
|
||||||
return Event{Del, 0, nil}
|
return Event{Del, 0, nil}
|
||||||
|
}
|
||||||
|
if len(r.buffer) == 6 && r.buffer[5] == '~' {
|
||||||
|
*sz = 6
|
||||||
|
switch r.buffer[4] {
|
||||||
|
case '5':
|
||||||
|
return Event{CtrlDelete, 0, nil}
|
||||||
|
case '2':
|
||||||
|
return Event{SDelete, 0, nil}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Event{Invalid, 0, nil}
|
||||||
case '4':
|
case '4':
|
||||||
return Event{End, 0, nil}
|
return Event{End, 0, nil}
|
||||||
case '5':
|
case '5':
|
||||||
|
@ -413,6 +413,12 @@ func (r *FullscreenRenderer) GetChar() Event {
|
|||||||
case tcell.KeyHome:
|
case tcell.KeyHome:
|
||||||
return Event{Home, 0, nil}
|
return Event{Home, 0, nil}
|
||||||
case tcell.KeyDelete:
|
case tcell.KeyDelete:
|
||||||
|
if ctrl {
|
||||||
|
return Event{CtrlDelete, 0, nil}
|
||||||
|
}
|
||||||
|
if shift {
|
||||||
|
return Event{SDelete, 0, nil}
|
||||||
|
}
|
||||||
return Event{Del, 0, nil}
|
return Event{Del, 0, nil}
|
||||||
case tcell.KeyEnd:
|
case tcell.KeyEnd:
|
||||||
return Event{End, 0, nil}
|
return Event{End, 0, nil}
|
||||||
|
@ -41,6 +41,7 @@ const (
|
|||||||
CtrlZ
|
CtrlZ
|
||||||
ESC
|
ESC
|
||||||
CtrlSpace
|
CtrlSpace
|
||||||
|
CtrlDelete
|
||||||
|
|
||||||
// https://apple.stackexchange.com/questions/24261/how-do-i-send-c-that-is-control-slash-to-the-terminal
|
// https://apple.stackexchange.com/questions/24261/how-do-i-send-c-that-is-control-slash-to-the-terminal
|
||||||
CtrlBackSlash
|
CtrlBackSlash
|
||||||
@ -74,6 +75,7 @@ const (
|
|||||||
SDown
|
SDown
|
||||||
SLeft
|
SLeft
|
||||||
SRight
|
SRight
|
||||||
|
SDelete
|
||||||
|
|
||||||
F1
|
F1
|
||||||
F2
|
F2
|
||||||
|
@ -2922,6 +2922,15 @@ class TestGoFZF < TestBase
|
|||||||
tmux.until { assert_block(expected, _1) }
|
tmux.until { assert_block(expected, _1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_delete_with_modifiers
|
||||||
|
tmux.send_keys "seq 100 | #{FZF} --bind 'ctrl-delete:up+up,shift-delete:down,focus:transform-prompt:echo [{}]'", :Enter
|
||||||
|
tmux.until { |lines| assert_equal 100, lines.item_count }
|
||||||
|
tmux.send_keys 'C-Delete'
|
||||||
|
tmux.until { |lines| assert_equal '[3]', lines[-1] }
|
||||||
|
tmux.send_keys 'S-Delete'
|
||||||
|
tmux.until { |lines| assert_equal '[2]', lines[-1] }
|
||||||
|
end
|
||||||
|
|
||||||
def test_become_tty
|
def test_become_tty
|
||||||
tmux.send_keys "sleep 0.5 | #{FZF} --bind 'start:reload:ls' --bind 'load:become:tty'", :Enter
|
tmux.send_keys "sleep 0.5 | #{FZF} --bind 'start:reload:ls' --bind 'load:become:tty'", :Enter
|
||||||
tmux.until { |lines| assert_includes lines, '/dev/tty' }
|
tmux.until { |lines| assert_includes lines, '/dev/tty' }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user