Table component with aligned columns, optional borders, and row cursor.
Usage: (def tbl (table [{:title "Name" :width 20} {:title "Value" :width 30}] [["foo" "bar"] ["baz" "qux"]] :cursor 0))
;; In update function: (table-update tbl msg)
;; In view function: (table-view tbl)
Table component with aligned columns, optional borders, and row cursor.
Usage:
(def tbl (table [{:title "Name" :width 20} {:title "Value" :width 30}]
[["foo" "bar"] ["baz" "qux"]]
:cursor 0))
;; In update function:
(table-update tbl msg)
;; In view function:
(table-view tbl)(page-down tbl)Move cursor down by one page.
Move cursor down by one page.
(table columns
rows
&
{:keys [cursor height header? header-style row-style cursor-style keys
id]
:or {height 0 header? true id (rand-int 1000000)}})Create a table component.
Columns is a vector of column definitions: [{:title "Name" :width 20} {:title "Value" :width 30}]
Rows is a vector of row vectors (each row has one value per column): [["foo" "bar"] ["baz" "qux"]]
Options: :cursor - Row cursor position (nil = not interactive, int = selected row) :height - Visible height in rows (0 = show all rows) :header? - Show header row (default true) :header-style - Style for header text :row-style - Style for normal row text :cursor-style - Style for selected row text :keys - Custom key bindings :id - Unique ID
Create a table component.
Columns is a vector of column definitions:
[{:title "Name" :width 20} {:title "Value" :width 30}]
Rows is a vector of row vectors (each row has one value per column):
[["foo" "bar"] ["baz" "qux"]]
Options:
:cursor - Row cursor position (nil = not interactive, int = selected row)
:height - Visible height in rows (0 = show all rows)
:header? - Show header row (default true)
:header-style - Style for header text
:row-style - Style for normal row text
:cursor-style - Style for selected row text
:keys - Custom key bindings
:id - Unique ID(table-cursor tbl)Get the cursor position (row index or nil).
Get the cursor position (row index or nil).
(table-init tbl)Initialize the table, returns [table cmd].
Initialize the table, returns [table cmd].
(table-row-count tbl)Get the number of rows.
Get the number of rows.
(table-selected-row tbl)Get the currently selected row data, or nil.
Get the currently selected row data, or nil.
(table-set-cursor tbl idx)Set the cursor position.
Set the cursor position.
(table-set-rows tbl new-rows)Set the rows, adjusting cursor if needed.
Set the rows, adjusting cursor if needed.
(table-update tbl msg)Update table state based on a message. Returns [new-table cmd] or [table nil] if message not handled.
Update table state based on a message. Returns [new-table cmd] or [table nil] if message not handled.
(table-view tbl)(table-view tbl {:keys [separator] :or {separator " "}})Render the table to a string.
Options can be passed to override the separator: :separator - String between columns (default " ")
Render the table to a string. Options can be passed to override the separator: :separator - String between columns (default " ")
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |