Test
This commit is contained in:
parent
e33b74bf6d
commit
993633886a
@ -216,11 +216,11 @@ Base.@kwdef mutable struct Options
|
|||||||
default::Symbol = :default
|
default::Symbol = :default
|
||||||
term::String = ""
|
term::String = ""
|
||||||
mime::Dict{DataType, String} = Dict(
|
mime::Dict{DataType, String} = Dict(
|
||||||
MIME"image/svg+xml" => "svg background rgb 'white' dynamic",
|
MIME"image/svg+xml" => "svg enhanced background rgb 'white' dynamic",
|
||||||
MIME"image/png" => "pngcairo",
|
MIME"image/png" => "pngcairo enhanced",
|
||||||
MIME"image/jpeg" => "jpeg",
|
MIME"image/jpeg" => "jpeg enhanced",
|
||||||
MIME"application/pdf" => "pdfcairo",
|
MIME"application/pdf" => "pdfcairo enhanced",
|
||||||
MIME"text/html" => "canvas mousing",
|
MIME"text/html" => "svg enhanced dynamic", # canvas mousing
|
||||||
MIME"text/plain" => "dumb")
|
MIME"text/plain" => "dumb")
|
||||||
init::Vector{String} = Vector{String}()
|
init::Vector{String} = Vector{String}()
|
||||||
verbose::Bool = false
|
verbose::Bool = false
|
||||||
@ -447,38 +447,38 @@ pagerTokens() = ["Press return for more:"]
|
|||||||
|
|
||||||
function GPSession(sid::Symbol)
|
function GPSession(sid::Symbol)
|
||||||
function readTask(sid, stream, channel)
|
function readTask(sid, stream, channel)
|
||||||
function gpreadline(stream)
|
# function gpreadline(stream)
|
||||||
line = ""
|
# line = ""
|
||||||
while true
|
# while true
|
||||||
c = read(stream, Char)
|
# c = read(stream, Char)
|
||||||
(c == '\r') && continue
|
# (c == '\r') && continue
|
||||||
(c == '\n') && break
|
# (c == '\n') && break
|
||||||
if c == Char(0x1b) # sixel
|
# if c == Char(0x1b) # sixel
|
||||||
buf = Vector{UInt8}()
|
# buf = Vector{UInt8}()
|
||||||
push!(buf, UInt8(c))
|
# push!(buf, UInt8(c))
|
||||||
while true
|
# while true
|
||||||
c = read(stream, Char)
|
# c = read(stream, Char)
|
||||||
push!(buf, UInt8(c))
|
# push!(buf, UInt8(c))
|
||||||
(c == Char(0x1b)) && break
|
# (c == Char(0x1b)) && break
|
||||||
end
|
# end
|
||||||
c = read(stream, Char)
|
# c = read(stream, Char)
|
||||||
push!(buf, UInt8(c))
|
# push!(buf, UInt8(c))
|
||||||
write(stdout, buf)
|
# write(stdout, buf)
|
||||||
continue
|
# continue
|
||||||
end
|
# end
|
||||||
line *= c
|
# line *= c
|
||||||
for token in pagerTokens() # handle pager interaction
|
# for token in pagerTokens() # handle pager interaction
|
||||||
if (length(line) == length(token)) && (line == token)
|
# if (length(line) == length(token)) && (line == token)
|
||||||
return line
|
# return line
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
return line
|
# return line
|
||||||
end
|
# end
|
||||||
|
|
||||||
saveOutput = false
|
saveOutput = false
|
||||||
while isopen(stream)
|
while isopen(stream)
|
||||||
line = gpreadline(stream)
|
line = readline(stream)
|
||||||
if line == "GNUPLOT_CAPTURE_BEGIN"
|
if line == "GNUPLOT_CAPTURE_BEGIN"
|
||||||
saveOutput = true
|
saveOutput = true
|
||||||
elseif line == "GNUPLOT_CAPTURE_END"
|
elseif line == "GNUPLOT_CAPTURE_END"
|
||||||
@ -512,7 +512,7 @@ function GPSession(sid::Symbol)
|
|||||||
pin = Base.Pipe()
|
pin = Base.Pipe()
|
||||||
pout = Base.Pipe()
|
pout = Base.Pipe()
|
||||||
perr = Base.Pipe()
|
perr = Base.Pipe()
|
||||||
proc = run(pipeline(`$(options.cmd)`, stdin=pin, stdout=pout, stderr=perr), wait=false)
|
proc = run(pipeline(`$(options.cmd)`, stdin=pin, stdout=stdout, stderr=perr), wait=false)
|
||||||
chan = Channel{String}(32)
|
chan = Channel{String}(32)
|
||||||
|
|
||||||
# Close unused sides of the pipes
|
# Close unused sides of the pipes
|
||||||
@ -523,7 +523,7 @@ function GPSession(sid::Symbol)
|
|||||||
Base.start_reading(perr.out)
|
Base.start_reading(perr.out)
|
||||||
|
|
||||||
# Start reading tasks
|
# Start reading tasks
|
||||||
@async readTask(sid, pout, chan)
|
#@async readTask(sid, pout, chan, :out)
|
||||||
@async readTask(sid, perr, chan)
|
@async readTask(sid, perr, chan)
|
||||||
|
|
||||||
out = GPSession(getfield.(Ref(session), fieldnames(DrySession))...,
|
out = GPSession(getfield.(Ref(session), fieldnames(DrySession))...,
|
||||||
@ -934,7 +934,7 @@ function execall(gp::GPSession; term::AbstractString="", output::AbstractString=
|
|||||||
gpexec(gp, s)
|
gpexec(gp, s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
(length(gp.plots) > 1) && gpexec(gp, "unset multiplot")
|
gpexec(gp, "unset multiplot")
|
||||||
(output != "") && gpexec(gp, "set output")
|
(output != "") && gpexec(gp, "set output")
|
||||||
if term != ""
|
if term != ""
|
||||||
gpexec(gp, "set term $former_term $former_opts")
|
gpexec(gp, "set term $former_term $former_opts")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user