Skip to content

Commit 9ec4c8c

Browse files
authored
Merge pull request #19 from pdeffebach/newwindow
Add `newwindow` keyword argument
2 parents 6cbae5f + a86da6a commit 9ec4c8c

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/FloatingTableView.jl

+15-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using TableView
55

66
export browse, showtable
77

8-
# Method for keeping current window active borrowed
8+
# Method for keeping current window active borrowed
99
# from Plots.jl
1010
mutable struct CurrentWin
1111
nullablewin::Union{Window, Nothing}
@@ -28,18 +28,21 @@ end
2828
current(win::Window) = (CURRENT_WIN.nullablewin = win)
2929

3030
"""
31-
browse(t; kwargs)
31+
browse(t; newwindow = false, kwargs...)
3232
33-
Browse data source in a new Blink window using
34-
Tables.jl's `showtable` function.
33+
Browse data source in a new Blink window using
34+
Tables.jl's `showtable` function.
3535
3636
# Arguments
3737
38-
- `t`, a Tables.jl-compatible data source,
39-
for example a `DataFrame` or a `NamedTuple`
38+
- `t`, a Tables.jl-compatible data source,
39+
for example a `DataFrame` or a `NamedTuple`
4040
of `Vector`s
41-
- `kwargs`, keyword arguments passed to the
42-
`showtable` command from TableView.jl to
41+
- `newwindow`, boolean keyword argument to view the data
42+
in a new `Blink` window instead of over-writing.
43+
Viewing in a new window will be slower than over-writing.
44+
- `kwargs...`, keyword arguments passed to the
45+
`showtable` command from TableView.jl to
4346
control the details of the new data viewer.
4447
See [`showtable`](@ref) for details.
4548
@@ -59,8 +62,10 @@ julia> browse(t, dark = true)
5962
6063
See also: [`showtable`](@ref)
6164
"""
62-
function browse(df; height = "100vh", kwargs...)
63-
if iswinnull() || !active(current())
65+
function browse(df; height = "100vh", newwindow::Bool = false, kwargs...)
66+
if newwindow == true
67+
body!(Window(), showtable(df; height = height, kwargs...))
68+
elseif iswinnull() || !active(current())
6469
w = Window()
6570
current(w)
6671
body!(current(), showtable(df; height = height, kwargs...))

test/runtests.jl

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const W = FloatingTableView.TableView.WebIO
2222
t = [1 3; 3 4]
2323
@test showtable(t) isa W.Scope
2424
@test browse(t) === nothing
25+
26+
t = [(a = 1, b = 2), (a = 3, b = 4)]
27+
@test browse(t; newwindow=true) === nothing
2528
end
2629

2730
end

0 commit comments

Comments
 (0)