charm.clj - A Clojure TUI library inspired by Bubble Tea.
This is the main entry point for charm.clj applications.
Example usage:
(require '[charm.core :as charm])
(defn update-fn [state msg]
(cond
(charm/key-match? msg "k") [(update state :count inc) nil]
(charm/key-match? msg "j") [(update state :count dec) nil]
(charm/key-match? msg "q") [state charm/quit-cmd]
:else [state nil]))
(defn view [state]
(str "Count: " (:count state) "\n\n(j/k to change, q to quit)"))
(charm/run {:init {:count 0}
:update update-fn
:view view})
charm.clj - A Clojure TUI library inspired by Bubble Tea.
This is the main entry point for charm.clj applications.
Example usage:
```clojure
(require '[charm.core :as charm])
(defn update-fn [state msg]
(cond
(charm/key-match? msg "k") [(update state :count inc) nil]
(charm/key-match? msg "j") [(update state :count dec) nil]
(charm/key-match? msg "q") [state charm/quit-cmd]
:else [state nil]))
(defn view [state]
(str "Count: " (:count state) "\n\n(j/k to change, q to quit)"))
(charm/run {:init {:count 0}
:update update-fn
:view view})
```(defprogram name & {:keys [init update view] :as opts})Define a TUI program with init, update, and view functions.
Usage: (defprogram my-app :init {:count 0} :update (fn [state msg] ...) :view (fn [state] ...))
Define a TUI program with init, update, and view functions.
Usage:
(defprogram my-app
:init {:count 0}
:update (fn [state msg] ...)
:view (fn [state] ...))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 |