Liking cljdoc? Tell your friends :D

charm.components.table

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)
raw docstring

cursor-downclj

(cursor-down tbl)

Move cursor down.

Move cursor down.
sourceraw docstring

cursor-upclj

(cursor-up tbl)

Move cursor up.

Move cursor up.
sourceraw docstring

go-to-endclj

(go-to-end tbl)

Move cursor to end.

Move cursor to end.
sourceraw docstring

go-to-startclj

(go-to-start tbl)

Move cursor to start.

Move cursor to start.
sourceraw docstring

page-downclj

(page-down tbl)

Move cursor down by one page.

Move cursor down by one page.
sourceraw docstring

page-upclj

(page-up tbl)

Move cursor up by one page.

Move cursor up by one page.
sourceraw docstring

tableclj

(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
sourceraw docstring

table-cursorclj

(table-cursor tbl)

Get the cursor position (row index or nil).

Get the cursor position (row index or nil).
sourceraw docstring

table-initclj

(table-init tbl)

Initialize the table, returns [table cmd].

Initialize the table, returns [table cmd].
sourceraw docstring

table-row-countclj

(table-row-count tbl)

Get the number of rows.

Get the number of rows.
sourceraw docstring

table-rowsclj

(table-rows tbl)

Get all rows.

Get all rows.
sourceraw docstring

table-selected-rowclj

(table-selected-row tbl)

Get the currently selected row data, or nil.

Get the currently selected row data, or nil.
sourceraw docstring

table-set-cursorclj

(table-set-cursor tbl idx)

Set the cursor position.

Set the cursor position.
sourceraw docstring

table-set-rowsclj

(table-set-rows tbl new-rows)

Set the rows, adjusting cursor if needed.

Set the rows, adjusting cursor if needed.
sourceraw docstring

table-updateclj

(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.
sourceraw docstring

table-viewclj

(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 "  ")
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close