Skip to content

Commit 5659400

Browse files
authored
Merge pull request #573 from JamesWrigley/ijulia
Add IJulia extension to detect IJulia being loaded
2 parents e0d5311 + 997556e commit 5659400

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

Project.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GR"
22
uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
3-
author = ["Josef Heinen (@jheinen)"]
43
version = "0.73.18"
4+
author = ["Josef Heinen (@jheinen)"]
55

66
[deps]
77
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
@@ -15,21 +15,28 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1515
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1616
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1717
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
18+
Qt6Wayland_jll = "e99dba38-086e-5de3-a5b1-6e4c66e897c3"
1819
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1920
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
2021
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
2122
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
2223
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
2324
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2425
p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
25-
Qt6Wayland_jll = "e99dba38-086e-5de3-a5b1-6e4c66e897c3"
26+
27+
[weakdeps]
28+
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
29+
30+
[extensions]
31+
GRIJuliaExt = "IJulia"
2632

2733
[compat]
2834
Artifacts = "1"
2935
DelimitedFiles = "1"
3036
Downloads = "1"
3137
GR_jll = "=0.73.18"
3238
HTTP = "0.8, 0.9, 1"
39+
IJulia = ">=1"
3340
JSON = "0.20, 0.21, 1"
3441
Pkg = "1"
3542
Preferences = "1"

ext/GRIJuliaExt.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module GRIJuliaExt
2+
3+
import GR
4+
import IJulia
5+
6+
function __init__()
7+
if @ccall(jl_generating_output()::Cint) == 0
8+
GR._ijulia_loaded = true
9+
end
10+
end
11+
12+
end

src/GR.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ const recv_c = Ref(C_NULL)
279279
const text_encoding = Ref(ENCODING_UTF8)
280280
const check_env = Ref(true)
281281

282-
isijulia() = isdefined(Main, :IJulia) && Main.IJulia isa Module && isdefined(Main.IJulia, :clear_output)
282+
_ijulia_loaded::Bool = false
283+
284+
isijulia() = _ijulia_loaded
283285
isatom() = isdefined(Main, :Atom) && Main.Atom isa Module && Main.Atom.isconnected() && (isdefined(Main.Atom, :PlotPaneEnabled) ? Main.Atom.PlotPaneEnabled[] : true)
284286
ispluto() = isdefined(Main, :PlutoRunner) && Main.PlutoRunner isa Module
285287
isvscode() = isdefined(Main, :VSCodeServer) && Main.VSCodeServer isa Module && (isdefined(Main.VSCodeServer, :PLOT_PANE_ENABLED) ? Main.VSCodeServer.PLOT_PANE_ENABLED[] : true)

0 commit comments

Comments
 (0)