Liking cljdoc? Tell your friends :D

charm.components.list

Scrollable list component with item selection.

Usage: (def my-list (item-list ["Apple" "Banana" "Cherry"]))

;; In update function: (list-update my-list msg)

;; In view function: (list-view my-list)

Scrollable list component with item selection.

Usage:
  (def my-list (item-list ["Apple" "Banana" "Cherry"]))

  ;; In update function:
  (list-update my-list msg)

  ;; In view function:
  (list-view my-list)
raw docstring

cursor-downclj

(cursor-down lst)

Move cursor down.

Move cursor down.
sourceraw docstring

cursor-upclj

(cursor-up lst)

Move cursor up.

Move cursor up.
sourceraw docstring

filter-itemsclj

(filter-items lst pred)

Filter items by a predicate function. Returns a new list with only matching items.

Filter items by a predicate function.
Returns a new list with only matching items.
sourceraw docstring

find-itemclj

(find-item lst pred)

Find the first item matching a predicate. Returns the index or nil.

Find the first item matching a predicate.
Returns the index or nil.
sourceraw docstring

go-to-endclj

(go-to-end lst)

Move cursor to end.

Move cursor to end.
sourceraw docstring

go-to-startclj

(go-to-start lst)

Move cursor to start.

Move cursor to start.
sourceraw docstring

item-countclj

(item-count lst)

Get the number of items.

Get the number of items.
sourceraw docstring

item-listclj

(item-list items
           &
           {:keys [height width cursor title show-title cursor-style item-style
                   title-style cursor-prefix item-prefix show-descriptions
                   infinite-scroll id]
            :or {show-title true
                 height 0
                 infinite-scroll false
                 item-prefix "  "
                 show-descriptions false
                 width 0
                 cursor 0
                 cursor-prefix "> "
                 id (rand-int 1000000)}})

Create a list component.

Items can be strings, maps with :title/:description, or any type implementing the ListItem protocol.

Options: :height - Visible height in lines (0 = show all) :width - Width constraint (0 = unlimited) :cursor - Initial cursor position (default 0) :title - Optional list title :show-title - Show title (default true if title provided) :cursor-style - Style for selected item :item-style - Style for unselected items :title-style - Style for title :cursor-prefix - Prefix for selected item (default "> ") :item-prefix - Prefix for unselected items (default " ") :show-descriptions - Show item descriptions (default false) :infinite-scroll - Wrap around at ends (default false) :id - Unique ID

Create a list component.

Items can be strings, maps with :title/:description, or any type
implementing the ListItem protocol.

Options:
  :height           - Visible height in lines (0 = show all)
  :width            - Width constraint (0 = unlimited)
  :cursor           - Initial cursor position (default 0)
  :title            - Optional list title
  :show-title       - Show title (default true if title provided)
  :cursor-style     - Style for selected item
  :item-style       - Style for unselected items
  :title-style      - Style for title
  :cursor-prefix    - Prefix for selected item (default "> ")
  :item-prefix      - Prefix for unselected items (default "  ")
  :show-descriptions - Show item descriptions (default false)
  :infinite-scroll  - Wrap around at ends (default false)
  :id               - Unique ID
sourceraw docstring

itemsclj

(items lst)

Get all items in the list.

Get all items in the list.
sourceraw docstring

list-initclj

(list-init lst)

Initialize the list, returns [list cmd]. Currently just returns the list with no command.

Initialize the list, returns [list cmd].
Currently just returns the list with no command.
sourceraw docstring

list-updateclj

(list-update lst msg)

Update list state based on a message. Returns [new-list cmd] or [list nil] if message not handled.

Update list state based on a message.
Returns [new-list cmd] or [list nil] if message not handled.
sourceraw docstring

list-viewclj

(list-view lst)

Render the list to a string.

Render the list to a string.
sourceraw docstring

ListItemcljprotocol

Protocol for items in a list.

Protocol for items in a list.

item-descriptionclj

(item-description item)

Get an optional description for the item.

Get an optional description for the item.

item-titleclj

(item-title item)

Get the display title for the item.

Get the display title for the item.
sourceraw docstring

page-downclj

(page-down lst)

Move cursor down by one page.

Move cursor down by one page.
sourceraw docstring

page-upclj

(page-up lst)

Move cursor up by one page.

Move cursor up by one page.
sourceraw docstring

selectclj

(select lst index)

Select an item by index.

Select an item by index.
sourceraw docstring

select-first-matchclj

(select-first-match lst pred)

Select the first item matching a predicate.

Select the first item matching a predicate.
sourceraw docstring

selected-indexclj

(selected-index lst)

Get the currently selected index.

Get the currently selected index.
sourceraw docstring

selected-itemclj

(selected-item lst)

Get the currently selected item, or nil if list is empty.

Get the currently selected item, or nil if list is empty.
sourceraw docstring

set-heightclj

(set-height lst height)

Set the visible height.

Set the visible height.
sourceraw docstring

set-itemsclj

(set-items lst new-items)

Set the items, adjusting cursor if needed.

Set the items, adjusting cursor if needed.
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