mirror of https://github.com/mpastell/Weave.jl
Removed unsused code
parent
54663179cb
commit
f7e18f45a3
94
src/run.jl
94
src/run.jl
|
@ -114,100 +114,6 @@ function run_code(chunk::CodeChunk, report::Report, SandBox::Module)
|
|||
return results
|
||||
end
|
||||
|
||||
|
||||
function run_block(chunk::CodeChunk, report::Report, SandBox::Module)
|
||||
expressions = parse_input(chunk.content)
|
||||
#@show expressions
|
||||
result_no = 1
|
||||
result_chunks = CodeChunk[ ]
|
||||
input = ""
|
||||
for (str_expr, expr) = expressions
|
||||
reset_report(report)
|
||||
(obj, out) = capture_output(expr, SandBox)
|
||||
|
||||
if rcParams[:plotlib] == "Gadfly" && typeof(obj) == Gadfly.Plot
|
||||
obj != nothing && display(obj)
|
||||
end
|
||||
|
||||
displayed = report.cur_result #Catch output to text display
|
||||
figures = report.figures #Captured figures
|
||||
if strip(out) == "" && isempty(figures) && displayed == ""
|
||||
input *= str_expr
|
||||
else
|
||||
@show input
|
||||
content = "\n" * input * str_expr
|
||||
rchunk = CodeChunk(content, chunk.number, chunk.start_line, chunk.option_AbstractString, copy(chunk.options))
|
||||
input = ""
|
||||
rchunk.result_no = result_no
|
||||
result_no *=1
|
||||
rchunk.figures = report.figures
|
||||
rchunk.output = out * displayed
|
||||
push!(result_chunks, rchunk)
|
||||
end
|
||||
end
|
||||
return result_chunks
|
||||
end
|
||||
|
||||
|
||||
function run_term(chunk::CodeChunk, report::Report, SandBox::Module)
|
||||
expressions = parse_input(chunk.content)
|
||||
#@show expressions
|
||||
result_no = 1
|
||||
result_chunks = CodeChunk[ ]
|
||||
output = ""
|
||||
prompt = "\njulia> "
|
||||
for (str_expr, expr) = expressions
|
||||
reset_report(report)
|
||||
(obj, out) = capture_output(expr, SandBox)
|
||||
obj != nothing && display(obj)
|
||||
displayed = report.cur_result #Catch output to text display
|
||||
figures = report.figures #Captured figures
|
||||
|
||||
if strip(out) == "" && isempty(figures) && displayed == ""
|
||||
output *= prompt * str_expr
|
||||
else
|
||||
content = prompt * output * str_expr
|
||||
rchunk = CodeChunk(content, chunk.number, chunk.start_line, chunk.option_AbstractString, copy(chunk.options))
|
||||
rchunk.output = content * out * displayed
|
||||
@show rchunk.output
|
||||
output = ""
|
||||
rchunk.result_no = result_no
|
||||
result_no *=1
|
||||
rchunk.figures = report.figures
|
||||
push!(result_chunks, rchunk)
|
||||
end
|
||||
end
|
||||
return result_chunks
|
||||
end
|
||||
|
||||
|
||||
function run_term2(code_str, report::Report, SandBox::Module)
|
||||
prompt = "\njulia> "
|
||||
codestart = "\n\n"*report.formatdict[:codestart]
|
||||
|
||||
if haskey(report.formatdict, :indent)
|
||||
prompt = indent(prompt, report.formatdict[:indent])
|
||||
end
|
||||
|
||||
parsed = parse_input(code_str)
|
||||
#Emulate terminal
|
||||
n = length(parsed)
|
||||
pos = 1 #The first character is extra line end
|
||||
while pos < n
|
||||
oldpos = pos
|
||||
code, pos = parse(code_str, pos)
|
||||
|
||||
report.term_state == :fig && (report.cur_result*= codestart)
|
||||
prompts = AbstractString(prompt, rstrip(code_str[oldpos:(pos-1)]), "\n")
|
||||
report.cur_result *= prompts
|
||||
report.term_state = :text
|
||||
s = eval(SandBox, code)
|
||||
s != nothing && display(s)
|
||||
end
|
||||
|
||||
return AbstractString(report.cur_result)
|
||||
end
|
||||
|
||||
function capture_output(expr::Expr, SandBox::Module, term, plotlib)
|
||||
oldSTDOUT = STDOUT
|
||||
out = nothing
|
||||
|
|
Loading…
Reference in New Issue