Skip to content

Commit

Permalink
display fixes (#3057)
Browse files Browse the repository at this point in the history
* vscode prefers juliavscode/html...sometimes

* enable display(plot; inline=false)

* Make GLMakie by default open a window

* these inlines shouldn't be necessary anymore

* fix pluto
  • Loading branch information
SimonDanisch authored Jul 11, 2023
1 parent 83fc003 commit 89dffb3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mutable struct ScreenConfig
end
end

const LAST_INLINE = Ref{Union{Makie.Automatic, Bool}}(Makie.automatic)
const LAST_INLINE = Ref{Union{Makie.Automatic, Bool}}(false)

"""
GLMakie.activate!(; screen_config...)
Expand Down
1 change: 0 additions & 1 deletion docs/documentation/fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Here's an example:
```julia
using CairoMakie
CairoMakie.activate!() # hide
Makie.inline!(true) # hide

f = Figure(fontsize = 24, fonts = (; regular = "Dejavu", weird = "Blackchancery"))
Axis(f[1, 1], title = "A title", xlabel = "An x label", xlabelfont = :weird)
Expand Down
4 changes: 1 addition & 3 deletions docs/examples/plotting_functions/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ ax3 = Axis(f[2, 1:2], limits = (9, 10, 11, 12))
for (ax, label) in zip([ax1, ax2, ax3], ["A", "B", "C"])
text!(
ax, 0, 1,
text = label,
text = label,
font = :bold,
align = (:left, :top),
offset = (4, -2),
Expand Down Expand Up @@ -249,7 +249,6 @@ The top-level settings for font, color, etc. are taken from the `text` attribute
```julia
using CairoMakie
CairoMakie.activate!() # hide
Makie.inline!(true) # hide

f = Figure(fontsize = 30)
Label(
Expand Down Expand Up @@ -284,7 +283,6 @@ You can use the `offset` value for rich text to shift glyphs by an amount propor
```julia
using CairoMakie
CairoMakie.activate!() # hide
Makie.inline!(true) # hide

f = Figure(fontsize = 30)
Label(
Expand Down
11 changes: 7 additions & 4 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ end

can_show_inline(::Missing) = false # no backend
function can_show_inline(Backend)
for mime in [MIME"text/html"(), MIME"image/png"(), MIME"image/svg+xml"()]
for mime in [MIME"juliavscode/html"(), MIME"text/html"(), MIME"image/png"(), MIME"image/svg+xml"()]
if backend_showable(Backend.Screen, mime)
return has_mime_display(mime)
end
Expand All @@ -128,7 +128,8 @@ see `?Backend.Screen` or `Base.doc(Backend.Screen)` for applicable options.
`backend` accepts Makie backend modules, e.g.: `backend = GLMakie`, `backend = CairoMakie`, etc.
"""
function Base.display(figlike::FigureLike; backend=current_backend(), update=true, screen_config...)
function Base.display(figlike::FigureLike; backend=current_backend(),
inline=ALWAYS_INLINE_PLOTS[], update = true, screen_config...)
if ismissing(backend)
error("""
No backend available!
Expand All @@ -138,7 +139,7 @@ function Base.display(figlike::FigureLike; backend=current_backend(), update=tru
In that case, try `]build GLMakie` and watch out for any warnings.
""")
end
inline = ALWAYS_INLINE_PLOTS[]

# We show inline if explicitely requested or if automatic and we can actually show something inline!
if (inline === true || inline === automatic) && can_show_inline(backend)
Core.invoke(display, Tuple{Any}, figlike)
Expand Down Expand Up @@ -190,7 +191,9 @@ const MIME_TO_TRICK_VSCODE = MIME"application/vnd.julia-vscode.diagnostics"

function _backend_showable(mime::MIME{SYM}) where SYM
if ALWAYS_INLINE_PLOTS[] == false
return mime isa MIME_TO_TRICK_VSCODE
if mime isa MIME_TO_TRICK_VSCODE
return true
end
end
Backend = current_backend()
if ismissing(Backend)
Expand Down

0 comments on commit 89dffb3

Please sign in to comment.