Liking cljdoc? Tell your friends :D

charm.program

The Elm Architecture event loop for TUI applications.

A program consists of:

  • init: Initial state and optional startup command
  • update: (state, msg) -> [new-state, cmd]
  • view: state -> string

Commands are functions that produce messages asynchronously.

The Elm Architecture event loop for TUI applications.

A program consists of:
- init: Initial state and optional startup command
- update: (state, msg) -> [new-state, cmd]
- view: state -> string

Commands are functions that produce messages asynchronously.
raw docstring

batchclj

(batch & cmds)

Combine multiple commands into one.

Combine multiple commands into one.
sourceraw docstring

cmdclj

(cmd f)

Create a command from a function that returns a message. The function will be called asynchronously.

Create a command from a function that returns a message.
The function will be called asynchronously.
sourceraw docstring

quit-cmdclj

Command that sends a quit message.

Command that sends a quit message.
sourceraw docstring

runclj

(run {:keys [init update view] :as opts})

Run a TUI program.

Options: :init - (fn [] [initial-state cmd]) or initial state value :update - (fn [state msg] [new-state cmd]) :view - (fn [state] string) :alt-screen - Use alternate screen buffer (default: false) :mouse - Mouse mode: nil, :normal, :cell, or :all (default: nil) :focus-reporting - Report focus in/out (default: false) :fps - Frames per second (default: 60) :hide-cursor - Hide cursor (default: true)

The init function should return [initial-state cmd] or just initial-state. The update function receives (state msg) and returns [new-state cmd]. Commands are optional and can be nil.

Run a TUI program.

Options:
  :init          - (fn [] [initial-state cmd]) or initial state value
  :update        - (fn [state msg] [new-state cmd])
  :view          - (fn [state] string)
  :alt-screen    - Use alternate screen buffer (default: false)
  :mouse         - Mouse mode: nil, :normal, :cell, or :all (default: nil)
  :focus-reporting - Report focus in/out (default: false)
  :fps           - Frames per second (default: 60)
  :hide-cursor   - Hide cursor (default: true)

The init function should return [initial-state cmd] or just initial-state.
The update function receives (state msg) and returns [new-state cmd].
Commands are optional and can be nil.
sourceraw docstring

run-simpleclj

(run-simple {:keys [state update view] :as opts})

Run a simple TUI program with minimal setup.

Takes a map with: :state - Initial state :update - (fn [state msg] [new-state cmd]) :view - (fn [state] string)

Example: (run-simple {:state {:count 0} :update (fn [state msg] (if (key-match? msg "q") [state quit-cmd] [(update state :count inc) nil])) :view (fn [state] (str "Count: " (:count state) "\nPress q to quit"))})

Run a simple TUI program with minimal setup.

Takes a map with:
  :state  - Initial state
  :update - (fn [state msg] [new-state cmd])
  :view   - (fn [state] string)

Example:
  (run-simple
    {:state {:count 0}
     :update (fn [state msg]
               (if (key-match? msg "q")
                 [state quit-cmd]
                 [(update state :count inc) nil]))
     :view (fn [state]
             (str "Count: " (:count state) "\nPress q to quit"))})
sourceraw docstring

sequence-cmdsclj

(sequence-cmds & cmds)

Run commands in sequence (each waits for previous to complete).

Run commands in sequence (each waits for previous to complete).
sourceraw docstring

window-size-msgclj

(window-size-msg width height)

Create a window size message.

Create a window size message.
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