Skip to content

Commit

Permalink
Revert "Add vim bindings to TerminalMenus (#37940)"
Browse files Browse the repository at this point in the history
This reverts commit 4a19b75.
Closes #41799.

(cherry picked from commit 702cf55)
  • Loading branch information
timholy authored and KristofferC committed Aug 25, 2021
1 parent 1b3fb60 commit 7208ff2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 3 additions & 3 deletions stdlib/REPL/src/TerminalMenus/AbstractMenu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ function request(term::REPL.Terminals.TTYTerminal, m::AbstractMenu; cursor::Unio
lastoption = numoptions(m)
c = readkey(term.in_stream)

if c == Int(ARROW_UP) || c == Int('k')
if c == Int(ARROW_UP)
cursor[] = move_up!(m, cursor[], lastoption)
elseif c == Int(ARROW_DOWN) || c == Int('j')
elseif c == Int(ARROW_DOWN)
cursor[] = move_down!(m, cursor[], lastoption)
elseif c == Int(PAGE_UP)
cursor[] = page_up!(m, cursor[], lastoption)
Expand All @@ -217,7 +217,7 @@ function request(term::REPL.Terminals.TTYTerminal, m::AbstractMenu; cursor::Unio
elseif c == Int(END_KEY)
cursor[] = lastoption
m.pageoffset = lastoption - m.pagesize
elseif c == 13 || c == Int(' ') # <enter> or <space>
elseif c == 13 # <enter>
# will break if pick returns true
pick(m, cursor[]) && break
elseif c == UInt32('q')
Expand Down
20 changes: 4 additions & 16 deletions stdlib/REPL/test/TerminalMenus/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@ using Test

function simulate_input(expected, menu::TerminalMenus.AbstractMenu, keys...;
kwargs...)
keydict = Dict(:up => "\e[A",
:down => "\e[B",
:enter => "\r")
vimdict = Dict(:up => "k",
:down => "j",
:enter => " ")
errs = []
got = _simulate_input(keydict, deepcopy(menu), keys...; kwargs...)
got == expected || push!(errs, :arrows => got)
got = _simulate_input(vimdict, menu, keys...; kwargs...)
got == expected || push!(errs, :vim => got)
isempty(errs) || return errs
end
keydict = Dict(:up => "\e[A",
:down => "\e[B",
:enter => "\r")

function _simulate_input(keydict, menu::TerminalMenus.AbstractMenu, keys...;
kwargs...)
for key in keys
if isa(key, Symbol)
write(stdin.buffer, keydict[key])
Expand All @@ -30,7 +18,7 @@ function _simulate_input(keydict, menu::TerminalMenus.AbstractMenu, keys...;
end
end

request(menu; suppress_output=true, kwargs...)
request(menu; suppress_output=true, kwargs...) == expected
end

include("radio_menu.jl")
Expand Down

0 comments on commit 7208ff2

Please sign in to comment.