mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-25 22:27:41 +00:00
Fix arrow key handling
This commit is contained in:
parent
73379963a3
commit
cb0246add6
17
fzf
17
fzf
@ -295,6 +295,7 @@ begin
|
|||||||
input = ''
|
input = ''
|
||||||
cursor = 0
|
cursor = 0
|
||||||
actions = {
|
actions = {
|
||||||
|
:nop => proc {},
|
||||||
ctrl(:c) => 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 {
|
||||||
@ -324,14 +325,14 @@ begin
|
|||||||
cursor = ridx
|
cursor = ridx
|
||||||
},
|
},
|
||||||
127 => proc { input[cursor -= 1] = '' if cursor > 0 },
|
127 => proc { input[cursor -= 1] = '' if cursor > 0 },
|
||||||
68 => proc { cursor = [0, cursor - 1].max },
|
:left => proc { cursor = [0, cursor - 1].max },
|
||||||
67 => proc { cursor = [input.length, cursor + 1].min },
|
:right => proc { cursor = [input.length, cursor + 1].min },
|
||||||
}.tap { |actions|
|
}.tap { |actions|
|
||||||
actions[ctrl :b] = actions[68]
|
actions[ctrl :b] = actions[68]
|
||||||
actions[ctrl :f] = actions[67]
|
actions[ctrl :f] = actions[67]
|
||||||
actions[ctrl :h] = actions[127]
|
actions[ctrl :h] = actions[127]
|
||||||
actions[66] = actions[ctrl :n] = actions[ctrl :j]
|
actions[ctrl :n] = actions[ctrl :j]
|
||||||
actions[65] = actions[ctrl :p] = actions[ctrl :k]
|
actions[ctrl :p] = actions[ctrl :k]
|
||||||
}
|
}
|
||||||
|
|
||||||
while true
|
while true
|
||||||
@ -339,7 +340,13 @@ begin
|
|||||||
if ord == 27
|
if ord == 27
|
||||||
ord = tty.getc.ord
|
ord = tty.getc.ord
|
||||||
if ord == 91
|
if ord == 91
|
||||||
ord = tty.getc.ord
|
ord = case tty.getc.ord
|
||||||
|
when 68 then :left
|
||||||
|
when 67 then :right
|
||||||
|
when 66 then ctrl(:j)
|
||||||
|
when 65 then ctrl(:k)
|
||||||
|
else :nop
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user