From 141a6639bfea6c0bfd3b0f4136b341bfcbc52cb9 Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Fri, 19 Jun 2020 16:36:16 -0700 Subject: [PATCH 1/8] Allow single option in REPL.TerminalMenus --- stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 2 +- stdlib/REPL/src/TerminalMenus/MultiSelectMenu.jl | 4 ++-- stdlib/REPL/src/TerminalMenus/RadioMenu.jl | 6 +++--- .../TerminalMenus/legacytests/old_multiselect_menu.jl | 6 ++---- .../REPL/test/TerminalMenus/legacytests/old_radio_menu.jl | 8 ++++---- stdlib/REPL/test/TerminalMenus/multiselect_menu.jl | 6 ++---- stdlib/REPL/test/TerminalMenus/radio_menu.jl | 8 ++++---- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index ebbebd83671d3..89ba9782a8e3c 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -325,7 +325,7 @@ function printmenu(out, m::AbstractMenu, cursoridx::Int; oldstate=nothing, init: writeline(buf, m, i, i == cursoridx) - i != lastline && print(buf, "\r\n") + (firstline == lastline || i != lastline) && print(buf, "\r\n") end newstate = lastline-firstline # final line doesn't have `\n` diff --git a/stdlib/REPL/src/TerminalMenus/MultiSelectMenu.jl b/stdlib/REPL/src/TerminalMenus/MultiSelectMenu.jl index 9bbc658085c90..b68255c3ecef2 100644 --- a/stdlib/REPL/src/TerminalMenus/MultiSelectMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/MultiSelectMenu.jl @@ -53,14 +53,14 @@ were selected by the user. Any additional keyword arguments will be passed to [`TerminalMenus.MultiSelectConfig`](@ref). """ function MultiSelectMenu(options::Array{String,1}; pagesize::Int=10, selected=Int[], warn::Bool=true, kwargs...) - length(options) < 2 && error("MultiSelectMenu must have at least two options") + length(options) < 1 && error("MultiSelectMenu must have at least one option") # if pagesize is -1, use automatic paging pagesize = pagesize == -1 ? length(options) : pagesize # pagesize shouldn't be bigger than options pagesize = min(length(options), pagesize) # after other checks, pagesize must be greater than 2 - pagesize < 2 && error("pagesize must be >= 2") + pagesize < 1 && error("pagesize must be >= 1") pageoffset = 0 _selected = Set{Int}() diff --git a/stdlib/REPL/src/TerminalMenus/RadioMenu.jl b/stdlib/REPL/src/TerminalMenus/RadioMenu.jl index 6b777e058e975..c8bdc557377b9 100644 --- a/stdlib/REPL/src/TerminalMenus/RadioMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/RadioMenu.jl @@ -44,14 +44,14 @@ user. Any additional keyword arguments will be passed to [`TerminalMenus.Config`](@ref). """ function RadioMenu(options::Array{String,1}; pagesize::Int=10, warn::Bool=true, kwargs...) - length(options) < 2 && error("RadioMenu must have at least two options") + length(options) < 1 && error("RadioMenu must have at least one option") # if pagesize is -1, use automatic paging pagesize = pagesize == -1 ? length(options) : pagesize # pagesize shouldn't be bigger than options pagesize = min(length(options), pagesize) - # after other checks, pagesize must be greater than 2 - pagesize < 2 && error("pagesize must be >= 2") + # after other checks, pagesize must be greater than 1 + pagesize < 1 && error("pagesize must be >= 1") pageoffset = 0 selected = -1 # none diff --git a/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl b/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl index 0c1bd08940289..fad96980d53d7 100644 --- a/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl @@ -5,10 +5,6 @@ # Check to make sure types are imported properly @test MultiSelectMenu <: TerminalMenus.AbstractMenu -# Invalid Menu Params -@test_throws ErrorException MultiSelectMenu(["one"], warn=false) -@test_throws ErrorException MultiSelectMenu(["one", "two", "three"], pagesize=1, warn=false) - # Constructor @test MultiSelectMenu(["one", "two", "three"], warn=false).pagesize == 3 @test MultiSelectMenu(string.(1:30), pagesize=-1, warn=false).pagesize == 30 @@ -37,3 +33,5 @@ TerminalMenus.writeLine(buf, multi_menu, 1, true) # Test SDTIN multi_menu = MultiSelectMenu(string.(1:10), warn=false) @test simulate_input(Set([1,2]), multi_menu, :enter, :down, :enter, 'd') +multi_menu = MultiSelectMenu(["single option"], warn=false) +@test simulate_input(Set([1]), multi_menu, :up, :up, :down, :enter, 'd') diff --git a/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl b/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl index 05038af460835..84f07ebca8812 100644 --- a/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl @@ -5,10 +5,6 @@ # Check to make sure types are imported properly @test RadioMenu <: TerminalMenus.AbstractMenu -# Invalid Menu Params -@test_throws ErrorException RadioMenu(["one"], warn=false) -@test_throws ErrorException RadioMenu(["one", "two", "three"], pagesize=1, warn=false) - # Constructor @test RadioMenu(["one", "two", "three"], warn=false).pagesize == 3 @test RadioMenu(string.(1:30), pagesize=-1, warn=false).pagesize == 30 @@ -40,3 +36,7 @@ TerminalMenus.writeLine(buf, radio_menu, 1, true) # Test using stdin radio_menu = RadioMenu(string.(1:10), warn=false) @test simulate_input(3, radio_menu, :down, :down, :enter) +radio_menu = RadioMenu(["single option"], warn=false) +@test simulate_input(1, radio_menu, :up, :up, :down, :up, :enter) +radio_menu = RadioMenu(string.(1:3), pagesize=1, warn=false) +@test simulate_input(3, radio_menu, :down, :down, :down, :down, :enter) diff --git a/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl b/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl index bfeb27590baf0..e13001301e5a6 100644 --- a/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl @@ -6,10 +6,6 @@ # Check to make sure types are imported properly @test MultiSelectMenu{TerminalMenus.MultiSelectConfig} <: TerminalMenus.ConfiguredMenu # TODO Julia 2.0: delete parameter -# Invalid Menu Params -@test_throws ErrorException MultiSelectMenu(["one"], charset=:ascii) -@test_throws ErrorException MultiSelectMenu(["one", "two", "three"], pagesize=1, charset=:ascii) - # Constructor @test MultiSelectMenu(["one", "two", "three"], charset=:ascii).pagesize == 3 @test MultiSelectMenu(string.(1:30), pagesize=-1, charset=:ascii).pagesize == 30 @@ -57,3 +53,5 @@ end # Test SDTIN multi_menu = MultiSelectMenu(string.(1:10), charset=:ascii) @test simulate_input(Set([1,2]), multi_menu, :enter, :down, :enter, 'd') +multi_menu = MultiSelectMenu(["single option"]) +@test simulate_input(Set([1]), multi_menu, :up, :up, :down, :enter, 'd') diff --git a/stdlib/REPL/test/TerminalMenus/radio_menu.jl b/stdlib/REPL/test/TerminalMenus/radio_menu.jl index a45bb39acb7b1..8d344f1dba697 100644 --- a/stdlib/REPL/test/TerminalMenus/radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/radio_menu.jl @@ -6,10 +6,6 @@ # Check to make sure types are imported properly @test RadioMenu{TerminalMenus.Config} <: TerminalMenus.ConfiguredMenu # TODO Julia 2.0: delete parameter -# Invalid Menu Params -@test_throws ErrorException RadioMenu(["one"]; charset=:ascii) -@test_throws ErrorException RadioMenu(["one", "two", "three"], pagesize=1, charset=:ascii) - # Constructor @test RadioMenu(["one", "two", "three"]; charset=:ascii).pagesize == 3 @test RadioMenu(string.(1:30), pagesize=-1, charset=:ascii).pagesize == 30 @@ -42,3 +38,7 @@ end # Test using stdin radio_menu = RadioMenu(string.(1:10); charset=:ascii) @test simulate_input(3, radio_menu, :down, :down, :enter) +radio_menu = RadioMenu(["single option"]) +@test simulate_input(1, radio_menu, :up, :up, :down, :up, :enter) +radio_menu = RadioMenu(string.(1:3), pagesize=1) +@test simulate_input(3, radio_menu, :down, :down, :down, :down, :enter) From baf607976035379970a04bcb3c224deb789a9ee0 Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Fri, 19 Jun 2020 16:37:21 -0700 Subject: [PATCH 2/8] Fix scroll down issue with pagesize=1 --- stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index 89ba9782a8e3c..439812a39f2cf 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -256,7 +256,7 @@ end function move_down!(m::AbstractMenu, cursor::Int, lastoption::Int=numoptions(m)) if cursor < lastoption cursor += 1 # move selection down - if m.pagesize + m.pageoffset <= cursor < lastoption + if m.pagesize + m.pageoffset <= cursor m.pageoffset += 1 # scroll page down end elseif scroll_wrap(m) From ec66b2ab6f7d165487cf1fcb843661607780b16c Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Fri, 19 Jun 2020 17:32:31 -0700 Subject: [PATCH 3/8] Use print_arrow() instead of printcursor() to print skip empty arrow --- stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index 439812a39f2cf..f17e2a01082c9 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -320,9 +320,10 @@ function printmenu(out, m::AbstractMenu, cursoridx::Int; oldstate=nothing, init: elseif i == lastline && i != lastoption print_arrow(buf, m, down_arrow(m)) else - printcursor(buf, m, i == cursoridx) + print_arrow(buf, m, ' ') end + printcursor(buf, m, i == cursoridx) writeline(buf, m, i, i == cursoridx) (firstline == lastline || i != lastline) && print(buf, "\r\n") @@ -362,10 +363,10 @@ down_arrow(c::AbstractConfig) = down_arrow(c.config) down_arrow(c::Config) = c.down_arrow down_arrow(::AbstractMenu) = CONFIG[:down_arrow] -print_arrow(buf, ::ConfiguredMenu, c::Char) = print(buf, c, " ") +print_arrow(buf, ::ConfiguredMenu, c::Char) = print(buf, c) print_arrow(buf, ::AbstractMenu, c::Char) = print(buf, c) -printcursor(buf, m::ConfiguredMenu, iscursor::Bool) = print(buf, ' ', iscursor ? cursor(m.config) : ' ', ' ') +printcursor(buf, m::ConfiguredMenu, iscursor::Bool) = print(buf, iscursor ? cursor(m.config) : ' ', ' ') cursor(c::AbstractConfig) = cursor(c.config) cursor(c::Config) = c.cursor -printcursor(buf, ::AbstractMenu, ::Bool) = print(buf, ' ') # `writeLine` is expected to do the printing (get from CONFIG[:cursor]) +printcursor(buf, ::AbstractMenu, ::Bool) = nothing # `writeLine` is expected to do the printing (get from CONFIG[:cursor]) From 76ef07cf159c9299c45cc0082b65859dac2b40ca Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Fri, 19 Jun 2020 17:35:05 -0700 Subject: [PATCH 4/8] Add updown arrow for multiple options in one-line page --- stdlib/REPL/docs/src/index.md | 1 + stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 14 ++++++++++++-- stdlib/REPL/src/TerminalMenus/config.jl | 11 ++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/stdlib/REPL/docs/src/index.md b/stdlib/REPL/docs/src/index.md index 7a7eaf64ada8f..be72284c55abf 100644 --- a/stdlib/REPL/docs/src/index.md +++ b/stdlib/REPL/docs/src/index.md @@ -610,6 +610,7 @@ Aside from the overall `charset` option, for `RadioMenu` the configurable option - `cursor::Char='>'|'→'`: character to use for cursor - `up_arrow::Char='^'|'↑'`: character to use for up arrow - `down_arrow::Char='v'|'↓'`: character to use for down arrow + - `updown_arrow::Char='I'|'↕'`: character to use for up/down arrow in one-line page - `scroll_wrap::Bool=false`: optionally wrap-around at the beginning/end of a menu - `ctrl_c_interrupt::Bool=true`: If `false`, return empty on ^C, if `true` throw InterruptException() on ^C diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index f17e2a01082c9..18993bc3daa50 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -315,9 +315,14 @@ function printmenu(out, m::AbstractMenu, cursoridx::Int; oldstate=nothing, init: # clearline print(buf, "\x1b[2K") - if i == firstline && m.pageoffset > 0 + upscrollable = i == firstline && m.pageoffset > 0 + downscrollable = i == lastline && i != lastoption + + if upscrollable && downscrollable + print_arrow(buf, m, updown_arrow(m)) + elseif upscrollable print_arrow(buf, m, up_arrow(m)) - elseif i == lastline && i != lastoption + elseif downscrollable print_arrow(buf, m, down_arrow(m)) else print_arrow(buf, m, ' ') @@ -363,6 +368,11 @@ down_arrow(c::AbstractConfig) = down_arrow(c.config) down_arrow(c::Config) = c.down_arrow down_arrow(::AbstractMenu) = CONFIG[:down_arrow] +updown_arrow(m::ConfiguredMenu) = updown_arrow(m.config) +updown_arrow(m::AbstractConfig) = updown_arrow(c.config) +updown_arrow(c::Config) = c.updown_arrow +updown_arrow(::AbstractMenu) = CONFIG[:updown_arrow] + print_arrow(buf, ::ConfiguredMenu, c::Char) = print(buf, c) print_arrow(buf, ::AbstractMenu, c::Char) = print(buf, c) diff --git a/stdlib/REPL/src/TerminalMenus/config.jl b/stdlib/REPL/src/TerminalMenus/config.jl index 9aded1ee0a186..9c8f001be6c5f 100644 --- a/stdlib/REPL/src/TerminalMenus/config.jl +++ b/stdlib/REPL/src/TerminalMenus/config.jl @@ -6,6 +6,7 @@ struct Config <: AbstractConfig cursor::Char up_arrow::Char down_arrow::Char + updown_arrow::Char scroll_wrap::Bool ctrl_c_interrupt::Bool end @@ -46,6 +47,7 @@ function Config(; cursor::Char = '\0', up_arrow::Char = '\0', down_arrow::Char = '\0', + updown_arrow::Char = '\0', scroll_wrap::Bool = false, ctrl_c_interrupt::Bool = true) charset === :ascii || charset === :unicode || @@ -59,7 +61,10 @@ function Config(; if down_arrow == '\0' down_arrow = charset === :ascii ? 'v' : '↓' end - return Config(cursor, up_arrow, down_arrow, scroll_wrap, ctrl_c_interrupt) + if updown_arrow == '\0' + updown_arrow = charset === :ascii ? 'I' : '↕' + end + return Config(cursor, up_arrow, down_arrow, updown_arrow, scroll_wrap, ctrl_c_interrupt) end """ @@ -133,6 +138,7 @@ function config(;charset::Symbol = :na, cursor::Char = '\0', up_arrow::Char = '\0', down_arrow::Char = '\0', + updown_arrow::Char = '\0', checked::String = "", unchecked::String = "", supress_output::Union{Nothing, Bool}=nothing, # typo was documented, unfortunately @@ -142,12 +148,14 @@ function config(;charset::Symbol = :na, cursor = '>' up_arrow = '^' down_arrow = 'v' + updown_arrow = 'I' checked = "[X]" unchecked = "[ ]" elseif charset === :unicode cursor = '→' up_arrow = '↑' down_arrow = '↓' + updown_arrow = '↕' checked = "✓" unchecked = "⬚" elseif charset === :na @@ -162,6 +170,7 @@ function config(;charset::Symbol = :na, cursor != '\0' && (CONFIG[:cursor] = cursor) up_arrow != '\0' && (CONFIG[:up_arrow] = up_arrow) down_arrow != '\0' && (CONFIG[:down_arrow] = down_arrow) + updown_arrow != '\0' && (CONFIG[:updown_arrow] = updown_arrow) checked != "" && (CONFIG[:checked] = checked) unchecked != "" && (CONFIG[:unchecked] = unchecked) supress_output isa Bool && (CONFIG[:supress_output] = supress_output) From 6f95ed678ea18aa29e5049cb10cae8667bd4633b Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Sat, 20 Jun 2020 13:21:50 -0700 Subject: [PATCH 5/8] Fix typo --- stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index 18993bc3daa50..f182f13d3130e 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -369,7 +369,7 @@ down_arrow(c::Config) = c.down_arrow down_arrow(::AbstractMenu) = CONFIG[:down_arrow] updown_arrow(m::ConfiguredMenu) = updown_arrow(m.config) -updown_arrow(m::AbstractConfig) = updown_arrow(c.config) +updown_arrow(c::AbstractConfig) = updown_arrow(c.config) updown_arrow(c::Config) = c.updown_arrow updown_arrow(::AbstractMenu) = CONFIG[:updown_arrow] From e2738252d6ed55e2dd8a75e0b49609c2b6316819 Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Sat, 20 Jun 2020 13:22:28 -0700 Subject: [PATCH 6/8] print_arrow() no longer needed --- stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index f182f13d3130e..7c33a348f29a6 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -319,13 +319,13 @@ function printmenu(out, m::AbstractMenu, cursoridx::Int; oldstate=nothing, init: downscrollable = i == lastline && i != lastoption if upscrollable && downscrollable - print_arrow(buf, m, updown_arrow(m)) + print(buf, updown_arrow(m)) elseif upscrollable - print_arrow(buf, m, up_arrow(m)) + print(buf, up_arrow(m)) elseif downscrollable - print_arrow(buf, m, down_arrow(m)) + print(buf, down_arrow(m)) else - print_arrow(buf, m, ' ') + print(buf, ' ') end printcursor(buf, m, i == cursoridx) @@ -373,9 +373,6 @@ updown_arrow(c::AbstractConfig) = updown_arrow(c.config) updown_arrow(c::Config) = c.updown_arrow updown_arrow(::AbstractMenu) = CONFIG[:updown_arrow] -print_arrow(buf, ::ConfiguredMenu, c::Char) = print(buf, c) -print_arrow(buf, ::AbstractMenu, c::Char) = print(buf, c) - printcursor(buf, m::ConfiguredMenu, iscursor::Bool) = print(buf, iscursor ? cursor(m.config) : ' ', ' ') cursor(c::AbstractConfig) = cursor(c.config) cursor(c::Config) = c.cursor From 083e62fc12a0069c84c674ac5332853b4add10e0 Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Sat, 20 Jun 2020 13:22:59 -0700 Subject: [PATCH 7/8] Avoid depwarn errors --- stdlib/REPL/test/TerminalMenus/multiselect_menu.jl | 2 +- stdlib/REPL/test/TerminalMenus/radio_menu.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl b/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl index e13001301e5a6..d47d6285be3ce 100644 --- a/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl @@ -53,5 +53,5 @@ end # Test SDTIN multi_menu = MultiSelectMenu(string.(1:10), charset=:ascii) @test simulate_input(Set([1,2]), multi_menu, :enter, :down, :enter, 'd') -multi_menu = MultiSelectMenu(["single option"]) +multi_menu = MultiSelectMenu(["single option"], charset=:ascii) @test simulate_input(Set([1]), multi_menu, :up, :up, :down, :enter, 'd') diff --git a/stdlib/REPL/test/TerminalMenus/radio_menu.jl b/stdlib/REPL/test/TerminalMenus/radio_menu.jl index 8d344f1dba697..e0645afe40371 100644 --- a/stdlib/REPL/test/TerminalMenus/radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/radio_menu.jl @@ -38,7 +38,7 @@ end # Test using stdin radio_menu = RadioMenu(string.(1:10); charset=:ascii) @test simulate_input(3, radio_menu, :down, :down, :enter) -radio_menu = RadioMenu(["single option"]) +radio_menu = RadioMenu(["single option"], charset=:ascii) @test simulate_input(1, radio_menu, :up, :up, :down, :up, :enter) -radio_menu = RadioMenu(string.(1:3), pagesize=1) +radio_menu = RadioMenu(string.(1:3), pagesize=1, charset=:ascii) @test simulate_input(3, radio_menu, :down, :down, :down, :down, :enter) From 75fffc51b224acb606a703ef1eb5372178c46908 Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Sat, 20 Jun 2020 14:48:51 -0700 Subject: [PATCH 8/8] Make move_down!() handling identitcal to the original impl --- stdlib/REPL/src/TerminalMenus/AbstractMenu.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl index 7c33a348f29a6..2b5676cb77706 100644 --- a/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl +++ b/stdlib/REPL/src/TerminalMenus/AbstractMenu.jl @@ -256,7 +256,8 @@ end function move_down!(m::AbstractMenu, cursor::Int, lastoption::Int=numoptions(m)) if cursor < lastoption cursor += 1 # move selection down - if m.pagesize + m.pageoffset <= cursor + pagepos = m.pagesize + m.pageoffset + if pagepos <= cursor && pagepos < lastoption m.pageoffset += 1 # scroll page down end elseif scroll_wrap(m)