Skip to content

Commit

Permalink
REPL: allow tweaking the implicit IOContext of the REPL
Browse files Browse the repository at this point in the history
This adds an `iocontext::Dict{Symbol,Any}` field to `LineEditREPL`,
which can be initialized with `atreplinit`, and updated
interactively, e.g. `Base.active_repl.iocontext[:compact] = true`.

Fixes #20509.
  • Loading branch information
rfourquet committed Sep 17, 2019
1 parent 9096963 commit 5aa66f5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ end
function display(d::REPLDisplay, mime::MIME"text/plain", x)
io = outstream(d.repl)
get(io, :color, false) && write(io, answer_color(d.repl))
show(IOContext(io, :limit => true, :module => Main), mime, x)
if isdefined(d.repl, :iocontext)
# this can override the :limit property set initially
io = foldl(IOContext, d.repl.iocontext, init=IOContext(io, :limit => true, :module => Main))
end
show(io, mime, x)
println(io)
nothing
end
Expand Down Expand Up @@ -328,12 +332,14 @@ mutable struct LineEditREPL <: AbstractREPL
waserror::Bool
specialdisplay::Union{Nothing,AbstractDisplay}
options::Options
# default IOContext settings at the REPL
iocontext::Dict{Symbol,Any}
mistate::Union{MIState,Nothing}
interface::ModalInterface
backendref::REPLBackendRef
LineEditREPL(t,hascolor,prompt_color,input_color,answer_color,shell_color,help_color,history_file,in_shell,in_help,envcolors) =
new(t,true,prompt_color,input_color,answer_color,shell_color,help_color,history_file,in_shell,
in_help,envcolors,false,nothing, Options(), nothing)
in_help,envcolors,false,nothing, Options(), Dict{Symbol,Any}(), nothing)
end
outstream(r::LineEditREPL) = r.t
specialdisplay(r::LineEditREPL) = r.specialdisplay
Expand Down

0 comments on commit 5aa66f5

Please sign in to comment.