mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 11:29:01 +00:00
Add CTRL-G and ESC (C-[) as abort key (#7)
This commit is contained in:
parent
04bf3abe99
commit
4745d50931
@ -106,7 +106,7 @@ history | fzf +s
|
|||||||
### Key binding
|
### Key binding
|
||||||
|
|
||||||
Use CTRL-J and CTRL-K (or CTRL-N and CTRL-P) to change the selection, press
|
Use CTRL-J and CTRL-K (or CTRL-N and CTRL-P) to change the selection, press
|
||||||
enter key to select the item. CTRL-C will terminate the finder.
|
enter key to select the item. CTRL-C, CTRL-G, or ESC will terminate the finder.
|
||||||
|
|
||||||
The following readline key bindings should also work as expected.
|
The following readline key bindings should also work as expected.
|
||||||
|
|
||||||
|
22
fzf
22
fzf
@ -10,7 +10,7 @@
|
|||||||
# URL: https://github.com/junegunn/fzf
|
# URL: https://github.com/junegunn/fzf
|
||||||
# Author: Junegunn Choi
|
# Author: Junegunn Choi
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# Last update: November 17, 2013
|
# Last update: November 20, 2013
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013 Junegunn Choi
|
# Copyright (c) 2013 Junegunn Choi
|
||||||
#
|
#
|
||||||
@ -643,8 +643,7 @@ class FZF
|
|||||||
cursor = (input[0, cursor].rindex(/\s\S/) || -1) + 1
|
cursor = (input[0, cursor].rindex(/\s\S/) || -1) + 1
|
||||||
}
|
}
|
||||||
actions = {
|
actions = {
|
||||||
:nop => proc { nil },
|
:esc => proc { exit 1 },
|
||||||
ctrl(:c) => proc { exit 1 },
|
|
||||||
ctrl(:d) => proc { exit 1 if input.empty? },
|
ctrl(:d) => proc { exit 1 if input.empty? },
|
||||||
ctrl(:m) => proc {
|
ctrl(:m) => proc {
|
||||||
got = pick
|
got = pick
|
||||||
@ -688,6 +687,7 @@ class FZF
|
|||||||
actions[ctrl(:h)] = actions[127]
|
actions[ctrl(:h)] = actions[127]
|
||||||
actions[ctrl(:n)] = actions[ctrl(:j)]
|
actions[ctrl(:n)] = actions[ctrl(:j)]
|
||||||
actions[ctrl(:p)] = actions[ctrl(:k)]
|
actions[ctrl(:p)] = actions[ctrl(:k)]
|
||||||
|
actions[ctrl(:g)] = actions[ctrl(:c)] = actions[:esc]
|
||||||
actions[:stab] = actions[9]
|
actions[:stab] = actions[9]
|
||||||
|
|
||||||
while true
|
while true
|
||||||
@ -696,22 +696,20 @@ class FZF
|
|||||||
|
|
||||||
ord = tty.getc.ord
|
ord = tty.getc.ord
|
||||||
ord =
|
ord =
|
||||||
case ord = tty.getc.ord
|
case ord = (tty.read_nonblock(1).ord rescue :esc)
|
||||||
when 91
|
when 91
|
||||||
case tty.getc.ord
|
case (tty.read_nonblock(1).ord rescue nil)
|
||||||
when 68 then :left
|
when 68 then :left
|
||||||
when 67 then :right
|
when 67 then :right
|
||||||
when 66 then ctrl(:j)
|
when 66 then ctrl(:j)
|
||||||
when 65 then ctrl(:k)
|
when 65 then ctrl(:k)
|
||||||
when 90 then :stab
|
when 90 then :stab
|
||||||
else :nop
|
else next
|
||||||
end
|
end
|
||||||
when 'b'.ord
|
when 'b'.ord then :alt_b
|
||||||
:alt_b
|
when 'f'.ord then :alt_f
|
||||||
when 'f'.ord
|
when :esc then :esc
|
||||||
:alt_f
|
else next
|
||||||
else
|
|
||||||
ord
|
|
||||||
end if ord == 27
|
end if ord == 27
|
||||||
|
|
||||||
upd = actions.fetch(ord, proc { |ord|
|
upd = actions.fetch(ord, proc { |ord|
|
||||||
|
Loading…
Reference in New Issue
Block a user