Skip to content

Commit

Permalink
REPL: reference the global MIState as a LineEditREPL field (JuliaLang…
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet authored and evetion committed Dec 12, 2017
1 parent 1045264 commit 8a3b742
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract type ModeState end
export run_interface, Prompt, ModalInterface, transition, reset_state, edit_insert, keymap

struct ModalInterface <: TextInterface
modes::Array{Base.LineEdit.TextInterface,1}
modes::Vector{TextInterface}
end

mutable struct Prompt <: TextInterface
Expand Down Expand Up @@ -2166,8 +2166,8 @@ function init_state(terminal, m::ModalInterface)
s
end

function run_interface(terminal, m::ModalInterface)
s::MIState = init_state(terminal, m)

function run_interface(terminal::TextTerminal, m::ModalInterface, s::MIState=init_state(terminal, m))
while !s.aborted
buf, ok, suspend = prompt!(terminal, m, s)
while suspend
Expand Down Expand Up @@ -2251,7 +2251,7 @@ keymap_data(s::PromptState, prompt::Prompt) = prompt.repl
keymap(ms::MIState, m::ModalInterface) = keymap(state(ms), mode(ms))
keymap_data(ms::MIState, m::ModalInterface) = keymap_data(state(ms), mode(ms))

function prompt!(term, prompt, s = init_state(term, prompt))
function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_state(term, prompt))
Base.reseteof(term)
raw!(term, true)
enable_bracketed_paste(term)
Expand Down
9 changes: 6 additions & 3 deletions base/repl/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import ..LineEdit:
history_last,
history_search,
accept_result,
terminal
terminal,
MIState

abstract type AbstractREPL end

Expand Down Expand Up @@ -275,11 +276,12 @@ mutable struct LineEditREPL <: AbstractREPL
waserror::Bool
specialdisplay::Union{Void,AbstractDisplay}
options::Options
mistate::Union{MIState,Void}
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())
in_help,envcolors,false,nothing, Options(), nothing)
end
outstream(r::LineEditREPL) = r.t
specialdisplay(r::LineEditREPL) = r.specialdisplay
Expand Down Expand Up @@ -987,7 +989,8 @@ function run_frontend(repl::LineEditREPL, backend::REPLBackendRef)
interface = repl.interface
end
repl.backendref = backend
run_interface(repl.t, interface)
repl.mistate = LineEdit.init_state(terminal(repl), interface)
run_interface(terminal(repl), interface, repl.mistate)
dopushdisplay && popdisplay(d)
end

Expand Down

0 comments on commit 8a3b742

Please sign in to comment.