Skip to content

Commit

Permalink
Fix double display on IJulia
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Jun 13, 2020
1 parent 619895d commit a23875f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/drawings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,21 @@ current_bufferdata() = getfield(CURRENTDRAWING[1], :bufferdata)
# are shortcuts to file-based drawings.) When a drawing is
# finished, you go `finish()` (that's the last line of the
# @... macros.). Then, if you want to actually see it, you
# go `preview()`.
# go `preview()`, which returns the current drawing.

# Then the code has to decide where you're working, and what
# type of file it is, then sends it to the right place,
# depending on the OS.

function Base.show(io::IO, ::MIME"text/plain", d::Drawing)
returnvalue = d.filename
# When the caller of `show` wants a short description,
# we only print the filename.
if get(io, :limit, false)
print(io, returnvalue)
return
end
# otherwise, we open the image file
if Sys.isapple()
run(`open $(returnvalue)`)
elseif Sys.iswindows()
Expand All @@ -98,8 +105,6 @@ function Base.show(io::IO, ::MIME"text/plain", d::Drawing)
elseif Sys.isunix()
run(`xdg-open $(returnvalue)`)
end
# print(io, returnvalue)
nothing
end

function tidysvg(m::MIME"image/svg+xml", fname)
Expand Down Expand Up @@ -547,7 +552,7 @@ macro draw(body, width=600, height=600)
sethue("black")
$(esc(body))
finish()
CURRENTDRAWING[1]
preview()
end
end

Expand Down

0 comments on commit a23875f

Please sign in to comment.