Skip to content
Myr

Add key combinations for ctrl-delete and shift-delete (#3284)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Syphdias · committed by GitHub · parent e2dd2a1 · Browse files · 6 files+38 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>

Diff stats

6 files+38 added−1 removed

  • tests:+9 added−0 removed
  • other:+29 added−1 removed

6 files+38 added−1 removed

modified:man/man1/fzf.1+4 added
871 unmodified lines
872\fIctrl-[a-z]\fR873.br874\fIctrl-space\fR875.br876\fIctrl-delete\fR877.br878\fIctrl-\\\fR879.br880\fIctrl-]\fR881.br
60 unmodified lines
942\fIshift-left\fR943.br944\fIshift-right\fR945.br946\fIshift-delete\fR947.br948\fIalt-shift-up\fR949.br950\fIalt-shift-down\fR951.br
337 unmodified lines
modified:src/tui/light.go+13 added-1 removed
428 unmodified lines
429 return r.GetChar()430 }431 return Event{Invalid, 0, nil} // INS432 case '3':433 if r.buffer[3] == '~' {433 return Event{Del, 0, nil}434 return Event{Del, 0, nil}435 }436 if len(r.buffer) == 6 && r.buffer[5] == '~' {437 *sz = 6438 switch r.buffer[4] {439 case '5':440 return Event{CtrlDelete, 0, nil}441 case '2':442 return Event{SDelete, 0, nil}443 }444 }445 return Event{Invalid, 0, nil}446 case '4':447 return Event{End, 0, nil}448 case '5':449 return Event{PgUp, 0, nil}
647 unmodified lines
modified:src/tui/tcell.go+6 added
411 unmodified lines
412 return Event{Insert, 0, nil}413 case tcell.KeyHome:414 return Event{Home, 0, nil}415 case tcell.KeyDelete:416 if ctrl {417 return Event{CtrlDelete, 0, nil}418 }419 if shift {420 return Event{SDelete, 0, nil}421 }422 return Event{Del, 0, nil}423 case tcell.KeyEnd:424 return Event{End, 0, nil}425 case tcell.KeyPgUp:
339 unmodified lines
modified:src/tui/tui.go+2 added
39 unmodified lines
40 CtrlY41 CtrlZ42 ESC43 CtrlSpace44 CtrlDelete4546 // https://apple.stackexchange.com/questions/24261/how-do-i-send-c-that-is-control-slash-to-the-terminal47 CtrlBackSlash48 CtrlRightBracket
25 unmodified lines
74 SUp75 SDown76 SLeft77 SRight78 SDelete7980 F181 F282 F3
690 unmodified lines
modified:src/options.go+4 added
612 unmodified lines
613 case "bspace", "bs":614 add(tui.BSpace)615 case "ctrl-space":616 add(tui.CtrlSpace)617 case "ctrl-delete":618 add(tui.CtrlDelete)619 case "ctrl-^", "ctrl-6":620 add(tui.CtrlCaret)621 case "ctrl-/", "ctrl-_":622 add(tui.CtrlSlash)
62 unmodified lines
685 case "shift-left":686 add(tui.SLeft)687 case "shift-right":688 add(tui.SRight)689 case "shift-delete":690 add(tui.SDelete)691 case "left-click":692 add(tui.LeftClick)693 case "right-click":694 add(tui.RightClick)
1407 unmodified lines
modified:test/test_go.rb+9 added
2920 unmodified lines
2921 OUTPUT2922 tmux.until { assert_block(expected, _1) }2923 end29242925 def test_delete_with_modifiers2926 tmux.send_keys "seq 100 | #{FZF} --bind 'ctrl-delete:up+up,shift-delete:down,focus:transform-prompt:echo [{}]'", :Enter2927 tmux.until { |lines| assert_equal 100, lines.item_count }2928 tmux.send_keys 'C-Delete'2929 tmux.until { |lines| assert_equal '[3]', lines[-1] }2930 tmux.send_keys 'S-Delete'2931 tmux.until { |lines| assert_equal '[2]', lines[-1] }2932 end29332934 def test_become_tty2935 tmux.send_keys "sleep 0.5 | #{FZF} --bind 'start:reload:ls' --bind 'load:become:tty'", :Enter2936 tmux.until { |lines| assert_includes lines, '/dev/tty' }2937 end
485 unmodified lines