Skip to content

Commit

Permalink
Merge pull request #1232 from bjarthur/bja/termext
Browse files Browse the repository at this point in the history
support TerminalExtensions.jl
  • Loading branch information
bjarthur authored Mar 5, 2019
2 parents cfc5c85 + 5ace17b commit 2cbd6d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export Plot, Layer, Theme, Col, Row, Scale, Coord, Geom, Guide, Stat, Shape, ren
export SVGJS, SVG, PGF, PNG, PS, PDF, draw, inch, mm, cm, px, pt, color, @colorant_str, vstack, hstack, title, gridstack


function link_terminalextensions()
@debug "Loading TerminalExtensions support into Gadfly"
include("terminalextensions.jl")
end

function __init__()
# Define an XML namespace for custom attributes
Compose.xmlns["gadfly"] = "http://www.gadflyjl.org/ns"
Expand All @@ -58,6 +63,7 @@ function __init__()
pushdisplay(GadflyDisplay())

@require DataFrames="a93c6f00-e57d-5684-b7b6-d8193f3e46c0" link_dataframes()
@require TerminalExtensions="d3a6a179-465e-5219-bd3e-0137f7fd17c7" link_terminalextensions()
end


Expand Down
2 changes: 1 addition & 1 deletion src/mapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,6 @@ function evalmapping!(mapping::Dict, data_source, data::Data)
end

function link_dataframes()
@info "Loading DataFrames support into Gadfly.jl"
@debug "Loading DataFrames support into Gadfly"
include("dataframes.jl")
end
17 changes: 17 additions & 0 deletions src/terminalextensions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using .TerminalExtensions

function putatend(idisplay, display::iTerm2.InlineDisplay)
iterm2display = splice!(Base.Multimedia.displays, idisplay)
push!(Base.Multimedia.displays, iterm2display)
true
end
putatend(idisplay, display) = false

for (idisplay, display) in enumerate(Base.Multimedia.displays)
putatend(idisplay, display) && break
end

function display(d::iTerm2.InlineDisplay, p::Union{Plot,Compose.Context})
draw(PNG(), p)
print("\r")
end

0 comments on commit 2cbd6d4

Please sign in to comment.