File tree 5 files changed +40
-5
lines changed
5 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
22
22
Crayons = " 4"
23
23
Crossterm = " 0.5"
24
24
InlineTest = " 0.2"
25
- KiwiConstraintSolver = " 1"
26
25
LoggingExtras = " 1"
27
26
LoggingFormats = " 1"
28
27
ReTest = " 0.3"
Original file line number Diff line number Diff line change 1
1
[deps ]
2
+ DataFrames = " a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
2
3
PalmerPenguins = " 8b842266-38fa-440a-9b57-31493939ab85"
4
+ Tables = " bd369af6-aec1-5ad0-b16a-f7cc5008161c"
3
5
TerminalUserInterfaces = " 408767e4-586b-40c7-9657-f9758988469a"
Original file line number Diff line number Diff line change
1
+ using TerminalUserInterfaces
2
+ const TUI = TerminalUserInterfaces
3
+ using DataFrames
4
+ using PalmerPenguins
5
+ using Tables
6
+
7
+ @kwdef mutable struct Model <: TUI.Model
8
+ df = DataFrame (PalmerPenguins. load ())
9
+ quit = false
10
+ end
11
+
12
+ function TUI. view (m:: Model )
13
+ columnnames = Tables. columnnames (Tables. columns (m. df))
14
+ N = length (columnnames)
15
+ header = TUI. Row (; data = [TUI. Datum (; content = string (col)) for col in columnnames])
16
+ rows = map (Tables. rows (m. df)) do row
17
+ TUI. Row (; data = [TUI. Datum (; content = string (item)) for item in row])
18
+ end
19
+ widths = [TUI. Percent (100 ÷ N) for _ in 1 : N]
20
+ TUI. Table (; rows, widths, header)
21
+ end
22
+
23
+ function TUI. update! (m:: Model , evt:: TUI.KeyEvent )
24
+ if TUI. keypress (evt) == " q"
25
+ m. quit = true
26
+ end
27
+ end
28
+
29
+ function main ()
30
+ TUI. app (Model ())
31
+ end
32
+
33
+ main ()
34
+
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ using TextWrap
7
7
using Unicode
8
8
using InlineTest
9
9
using KiwiConstraintSolver
10
+ using Tables
10
11
11
12
export Terminal
12
13
Original file line number Diff line number Diff line change 11
11
12
12
total_height (row:: Row ) = row. height + row. bottom_margin
13
13
14
-
15
14
@kwdef mutable struct TableState
16
- offset:: Int
17
- selected:: Union{Int,Nothing}
15
+ offset:: Int = 1
16
+ selected:: Union{Int,Nothing} = nothing
18
17
end
19
18
20
19
@kwdef struct Table
21
20
rows:: Vector{Row}
22
21
widths:: Vector{Constraint}
23
- state:: TableState = TableState (; offset = 1 , selected = nothing )
22
+ state:: TableState = TableState ()
24
23
block:: Union{Nothing,Block} = Block ()
25
24
style:: Crayon = Crayon ()
26
25
column_spacing:: Int = 0
You can’t perform that action at this time.
0 commit comments