From 89dffb3022e5a522da47c0a14c0c45ab895a4dc4 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 11 Jul 2023 11:28:07 +0200 Subject: [PATCH] display fixes (#3057) * 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 --- GLMakie/src/screen.jl | 2 +- docs/documentation/fonts.md | 1 - docs/examples/plotting_functions/text.md | 4 +--- src/display.jl | 11 +++++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/GLMakie/src/screen.jl b/GLMakie/src/screen.jl index 61021022490..1e364ffdaa5 100644 --- a/GLMakie/src/screen.jl +++ b/GLMakie/src/screen.jl @@ -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...) diff --git a/docs/documentation/fonts.md b/docs/documentation/fonts.md index 95276b39812..e9d8ec0d6df 100644 --- a/docs/documentation/fonts.md +++ b/docs/documentation/fonts.md @@ -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) diff --git a/docs/examples/plotting_functions/text.md b/docs/examples/plotting_functions/text.md index 020916670ea..582e4466f67 100644 --- a/docs/examples/plotting_functions/text.md +++ b/docs/examples/plotting_functions/text.md @@ -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), @@ -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( @@ -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( diff --git a/src/display.jl b/src/display.jl index 9ad073b222d..f3d61b8ef1c 100644 --- a/src/display.jl +++ b/src/display.jl @@ -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 @@ -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! @@ -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) @@ -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)