|
|
|
|
@ -53,65 +53,3 @@ function limitstringmime(mime::MIME, x)
|
|
|
|
|
end
|
|
|
|
|
return String(take!(buf))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for mime in ipy_mime
|
|
|
|
|
@eval begin
|
|
|
|
|
function display(d::InlineDisplay, ::MIME{Symbol($mime)}, x)
|
|
|
|
|
send_ipython(publish[],
|
|
|
|
|
msg_pub(execute_msg, "display_data",
|
|
|
|
|
Dict(
|
|
|
|
|
"metadata" => metadata(x), # optional
|
|
|
|
|
"data" => Dict($mime => limitstringmime(MIME($mime), x)))))
|
|
|
|
|
end
|
|
|
|
|
displayable(d::InlineDisplay, ::MIME{Symbol($mime)}) = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# deal with annoying application/x-latex == text/latex synonyms
|
|
|
|
|
display(d::InlineDisplay, m::MIME"application/x-latex", x) = display(d, MIME("text/latex"), limitstringmime(m, x))
|
|
|
|
|
|
|
|
|
|
# deal with annoying text/javascript == application/javascript synonyms
|
|
|
|
|
display(d::InlineDisplay, m::MIME"text/javascript", x) = display(d, MIME("application/javascript"), limitstringmime(m, x))
|
|
|
|
|
|
|
|
|
|
# If the user explicitly calls display("foo/bar", x), we send
|
|
|
|
|
# the display message, also sending text/plain for text data.
|
|
|
|
|
displayable(d::InlineDisplay, M::MIME) = istextmime(M)
|
|
|
|
|
function display(d::InlineDisplay, M::MIME, x)
|
|
|
|
|
sx = limitstringmime(M, x)
|
|
|
|
|
d = Dict(string(M) => sx)
|
|
|
|
|
if istextmime(M)
|
|
|
|
|
d["text/plain"] = sx # directly show text data, e.g. text/csv
|
|
|
|
|
end
|
|
|
|
|
send_ipython(publish[],
|
|
|
|
|
msg_pub(execute_msg, "display_data",
|
|
|
|
|
Dict("metadata" => metadata(x), # optional
|
|
|
|
|
"data" => d)))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# override display to send IPython a dictionary of all supported
|
|
|
|
|
# output types, so that IPython can choose what to display.
|
|
|
|
|
function display(d::InlineDisplay, x)
|
|
|
|
|
undisplay(x) # dequeue previous redisplay(x)
|
|
|
|
|
send_ipython(publish[],
|
|
|
|
|
msg_pub(execute_msg, "display_data",
|
|
|
|
|
Dict("metadata" => metadata(x), # optional
|
|
|
|
|
"data" => display_dict(x))))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# we overload redisplay(d, x) to add x to a queue of objects to display,
|
|
|
|
|
# with the actual display occuring when display() is called or when
|
|
|
|
|
# an input cell has finished executing.
|
|
|
|
|
|
|
|
|
|
function redisplay(d::InlineDisplay, x)
|
|
|
|
|
if !in(x,displayqueue)
|
|
|
|
|
push!(displayqueue, x)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function display()
|
|
|
|
|
q = copy(displayqueue)
|
|
|
|
|
empty!(displayqueue) # so that undisplay in display(x) is no-op
|
|
|
|
|
for x in q
|
|
|
|
|
display(x)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|