Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store the frontend task object in the REPL struct. #48400

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,15 @@ end
mutable struct BasicREPL <: AbstractREPL
terminal::TextTerminal
waserror::Bool
frontend_task::Task
BasicREPL(t) = new(t, false)
end

outstream(r::BasicREPL) = r.terminal
hascolor(r::BasicREPL) = hascolor(r.terminal)

function run_frontend(repl::BasicREPL, backend::REPLBackendRef)
repl.frontend_task = current_task()
d = REPLDisplay(repl)
dopushdisplay = !in(d,Base.Multimedia.displays)
dopushdisplay && pushdisplay(d)
Expand Down Expand Up @@ -462,6 +464,7 @@ mutable struct LineEditREPL <: AbstractREPL
last_shown_line_infos::Vector{Tuple{String,Int}}
interface::ModalInterface
backendref::REPLBackendRef
frontend_task::Task
function LineEditREPL(t,hascolor,prompt_color,input_color,answer_color,shell_color,help_color,history_file,in_shell,in_help,envcolors)
opts = Options()
opts.hascolor = hascolor
Expand Down Expand Up @@ -1281,6 +1284,7 @@ function setup_interface(
end

function run_frontend(repl::LineEditREPL, backend::REPLBackendRef)
repl.frontend_task = current_task()
d = REPLDisplay(repl)
dopushdisplay = repl.specialdisplay === nothing && !in(d,Base.Multimedia.displays)
dopushdisplay && pushdisplay(d)
Expand All @@ -1306,6 +1310,7 @@ mutable struct StreamREPL <: AbstractREPL
input_color::String
answer_color::String
waserror::Bool
frontend_task::Task
StreamREPL(stream,pc,ic,ac) = new(stream,pc,ic,ac,false)
end
StreamREPL(stream::IO) = StreamREPL(stream, Base.text_colors[:green], Base.input_color(), Base.answer_color())
Expand Down Expand Up @@ -1364,6 +1369,7 @@ ends_with_semicolon(code::Union{String,SubString{String}}) =
contains(_rm_strings_and_comments(code), r";\s*$")

function run_frontend(repl::StreamREPL, backend::REPLBackendRef)
repl.frontend_task = current_task()
have_color = hascolor(repl)
Base.banner(repl.stream)
d = REPLDisplay(repl)
Expand Down