Skip to content

Instantly share code, notes, and snippets.

@tkelman
Created July 16, 2014 01:01
Show Gist options
  • Select an option

  • Save tkelman/bf8627f8143d276c5ce0 to your computer and use it in GitHub Desktop.

Select an option

Save tkelman/bf8627f8143d276c5ce0 to your computer and use it in GitHub Desktop.
type FakeTerminal <: Base.Terminals.UnixTerminal
in_stream::Base.IO
out_stream::Base.IO
err_stream::Base.IO
hascolor::Bool
raw::Bool
FakeTerminal(stdin,stdout,stderr,hascolor=true) =
new(stdin,stdout,stderr,hascolor,false)
end
Base.Terminals.hascolor(t::FakeTerminal) = t.hascolor
Base.Terminals.raw!(t::FakeTerminal, raw::Bool) = t.raw = raw
Base.Terminals.size(t::FakeTerminal) = (24, 80)
stdin_read,stdin_write = (Base.Pipe(C_NULL), Base.Pipe(C_NULL))
stdout_read,stdout_write = (Base.Pipe(C_NULL), Base.Pipe(C_NULL))
stderr_read,stderr_write = (Base.Pipe(C_NULL), Base.Pipe(C_NULL))
Base.link_pipe(stdin_read,true,stdin_write,true)
Base.link_pipe(stdout_read,true,stdout_write,true)
Base.link_pipe(stderr_read,true,stderr_write,true)
repl = Base.REPL.LineEditREPL(FakeTerminal(stdin_read, stdout_write, stderr_write))
repl.specialdisplay = Base.REPL.REPLDisplay(repl)
repl.no_history_file = true
repltask = @async begin
Base.REPL.run_repl(repl)
end
sendrepl(cmd) = write(stdin_write,"inc || wait(b); r = $cmd; notify(c); r\r")
inc = false
b = Condition()
c = Condition()
sendrepl("\"Hello REPL\"")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment