#41 Add `window` argument to `electrondisplay`

Open Takafumi Arakaki tkf
Coverage Reach
ElectronDisplay.jl vega.jl

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 2 files from the diff.
Other files ignored by Codecov
test/runtests.jl has changed.

@@ -34,10 +34,12 @@
Loading
34 34
35 35
struct ElectronDisplayType <: Base.AbstractDisplay
36 36
    config::ElectronDisplayConfig
37 +
    window::Union{Window, Nothing}
37 38
end
38 39
39 -
ElectronDisplayType() = ElectronDisplayType(CONFIG)
40 -
newdisplay(; config...) = ElectronDisplayType(setconfig(CONFIG; config...))
40 +
ElectronDisplayType() = ElectronDisplayType(CONFIG, nothing)
41 +
newdisplay(window::Union{Window, Nothing} = nothing; config...) =
42 +
    ElectronDisplayType(setconfig(CONFIG; config...), window)
41 43
42 44
electron_showable(m, x) =
43 45
    m ∉ ("application/vnd.dataresource+json", "text/html", "text/markdown") &&
@@ -80,8 +82,8 @@
Loading
80 82
end
81 83
82 84
function displayhtml(d::ElectronDisplayType, payload; options::Dict=Dict{String,Any}())
83 -
    if d.config.single_window
84 -
        w = _getglobalwindow()
85 +
    if d.window !== nothing || d.config.single_window
86 +
        w = d.window !== nothing ? d.window : _getglobalwindow()
85 87
        load(w, payload)
86 88
        showfun = get(options, "show", d.config.focus) ? "show" : "showInactive"
87 89
        run(w.app, "BrowserWindow.fromId($(w.id)).$showfun()")
@@ -297,18 +299,26 @@
Loading
297 299
end
298 300
299 301
"""
300 -
    electrondisplay([mime,] x; config...)
302 +
    electrondisplay([window,] [mime,] x; config...)
301 303
302 -
Show `x` in Electron window.  Use MIME `mime` if specified.  The keyword
304 +
Show `x` in Electron `window`.  Use MIME `mime` if specified.  The keyword
303 305
arguments can be used to override [`ElectronDisplay.CONFIG`](@ref) without
304 306
mutating it.
305 307
306 308
# Examples
307 309
```julia
308 -
electrondisplay(@doc reduce; single_window=true, focus=false)
310 +
w = electrondisplay(@doc reduce; single_window=true, focus=false)
311 +
electrondisplay(w, @doc mapreduce)
309 312
```
310 313
"""
311 -
electrondisplay(mime, x; config...) = display(newdisplay(; config...), mime, x)
314 +
electrondisplay(mime, x; config...) =
315 +
    _electrondisplay(nothing, mime, x; config...)
316 +
electrondisplay(window::Window, mime, x; config...) =
317 +
    _electrondisplay(window, mime, x; config...)
318 +
_electrondisplay(window, mime, x; config...) =
319 +
    display(newdisplay(window; config...), mime, x)
320 +
# `_electrondisplay` is for not exposing implementation detail that
321 +
# `window = nothing` means the default window.
312 322
313 323
struct DataresourceTableTraitsWrapper{T}
314 324
    source::T
@@ -328,8 +338,10 @@
Loading
328 338
329 339
Base.showable(::MIME"application/vnd.dataresource+json", dt::CachedDataResourceString) = true
330 340
331 -
function electrondisplay(x; config...)
332 -
    d = newdisplay(; showable=showable, config...)
341 +
electrondisplay(x; config...) = _electrondisplay(nothing, x; config...)
342 +
electrondisplay(window::Window, x; config...) = _electrondisplay(window, x; config...)
343 +
function _electrondisplay(window, x; config...)
344 +
    d = newdisplay(window; showable=showable, config...)
333 345
    if TableTraits.isiterabletable(x)!==false
334 346
        if showable("application/vnd.dataresource+json", x)
335 347
            display(d, x)

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
src 0.62% 82.76%
Project Totals (2 files) 82.76%
Loading