This commit is contained in:
Giorgio Calderone 2020-04-22 19:09:47 +02:00
parent e3d9d6035e
commit 4405daf088

View File

@ -446,7 +446,7 @@ end
function readTask(gp::GPSession) function readTask(gp::GPSession)
pagerTokens() = ["Press return for more:"] pagerTokens() = ["Press return for more:"]
repeatID = 0 captureID = 0
function gpreadline() function gpreadline()
line = "" line = ""
while true while true
@ -458,16 +458,12 @@ function readTask(gp::GPSession)
if (length(line) == length(token)) && (line == token) if (length(line) == length(token)) && (line == token)
# GNUPLOT_CAPTURE_END maybe lost when pager is # GNUPLOT_CAPTURE_END maybe lost when pager is
# running: send it again. # running: send it again.
repeatID += 1 captureID += 1
write(gp.pin, "\nprint 'GNUPLOT_CAPTURE_END $repeatID'\n") write(gp.pin, "\nprint 'GNUPLOT_CAPTURE_END $(captureID)'\n")
line = "" line = ""
end end
end end
end end
if line == "GNUPLOT_CAPTURE_BEGIN"
repeatID += 1
write(gp.pin, "\nprint 'GNUPLOT_CAPTURE_END $repeatID'\n")
end
return line return line
end end
@ -475,13 +471,15 @@ function readTask(gp::GPSession)
saveOutput = false saveOutput = false
while isopen(gp.perr) while isopen(gp.perr)
line = gpreadline() line = gpreadline()
if line == "GNUPLOT_CAPTURE_BEGIN" if line == "GNUPLOT_CAPTURE_BEGIN"
saveOutput = true saveOutput = true
elseif line == "GNUPLOT_CAPTURE_END $repeatID" elseif line == "GNUPLOT_CAPTURE_END $(captureID)"
saveOutput = false saveOutput = false
put!(gp.channel, "GNUPLOT_CAPTURE_END") put!(gp.channel, "GNUPLOT_CAPTURE_END")
captureID = 0
elseif !isnothing(findfirst("GNUPLOT_CAPTURE_END", line)) elseif !isnothing(findfirst("GNUPLOT_CAPTURE_END", line))
continue # old GNUPLOT_CAPTURE_END, ignore it ;# old GNUPLOT_CAPTURE_END, ignore it
else else
if line != "" if line != ""
if options.verbose || !saveOutput if options.verbose || !saveOutput
@ -620,6 +618,10 @@ function writeread(gp::GPSession, str::AbstractString)
options.verbose = verbose options.verbose = verbose
write(gp, str) write(gp, str)
options.verbose = false
write(gp, "print 'GNUPLOT_CAPTURE_END 0'")
options.verbose = verbose
out = Vector{String}() out = Vector{String}()
while true while true
l = take!(gp.channel) l = take!(gp.channel)