Open bjarthur opened 1 year ago
Good idea! I see no problem with Q
.
Enter
quits everything and returns the item you're on. That's normally fine for your use case unless the item returns a particularly hairy output.
i didn't know about Enter
! maybe it needs to be added to the help that is printed at the top of the output of eye
?
it doesn't seem to work with S
though on Dicts. in the example below, the last thing i input is three Enter
in a row. it takes me back to the previous display the first two times, and then exists and returns the value of the top-level Dict:
julia> using Eyeball
julia> ^C
julia> using Eyeball, DataStructures
julia> foo=Dict("a"=>Dict("b"=>Dict("c"=>1)))
Dict{String, Dict{String, Dict{String, Int64}}} with 1 entry:
"a" => Dict("b"=>Dict("c"=>1))
julia> bar = eye(foo)
[f] fields [d] docs [e] expand [m/M] methodswith [o] open [r] tree [s] show [S] Sort [t] typeof [z] summarize [q] quit
: Dict{String, Dict{String, Dict{String, Int64}}} Dict("a"=>Dict("b"=>Dict("c"=>1)))
> a: Dict{String, Dict{String, Int64}} Dict("b"=>Dict("c"=>1))
b: Dict{String, Int64} Dict("c"=>1)
c: Int64 1
Opening sort(`a`) ...
[f] fields [d] docs [e] expand [m/M] methodswith [o] open [r] tree [s] show [S] Sort [t] typeof [z] summarize [q] quit
: OrderedDict{String, Dict{String, Int64}} OrderedDict("b"=>Dict("c"=>1))
> b: Dict{String, Int64} Dict("c"=>1)
c: Int64 1
Opening sort(`b`) ...
[f] fields [d] docs [e] expand [m/M] methodswith [o] open [r] tree [s] show [S] Sort [t] typeof [z] summarize [q] quit
: OrderedDict{String, Int64} OrderedDict("c"=>1)
: OrderedDict{String, Dict{String, Int64}} OrderedDict("b"=>Dict("c"=>1))
: Dict{String, Dict{String, Dict{String, Int64}}} Dict("a"=>Dict("b"=>Dict("c"=>1)))
> a: Dict{String, Dict{String, Int64}} Dict("b"=>Dict("c"=>1))
b: Dict{String, Int64} Dict("c"=>1)
c: Int64 1
Dict{String, Dict{String, Int64}} with 1 entry:
"b" => Dict("c"=>1)
Hmmm. Looks like S
and o
are working differently. To make this work for S
, something like this logic from o
is needed. returnfun
controls what is returned. The return true
means that the menu exits.
Also, here is a version of Q
:
elseif i == Int('Q')
returnfun = x -> 0
menu.chosen = true
return true
if one descends into a hierarchy of dicts with e.g.
S
, thenq
backs out one level. it would be convenient to have a way to back all the way out to the REPL with one keystroke. maybeQ
?