ANSI escape sequence parsing.
Parses ANSI escape sequences into structured data for processing.
ANSI escape sequence parsing. Parses ANSI escape sequences into structured data for processing.
Text width calculation for terminal display.
Handles:
Text width calculation for terminal display. Handles: - ANSI escape sequences (zero width) - Wide characters (CJK, emojis = 2 cells) - Combining characters (zero width) - Grapheme clusters (emoji sequences)
Help component for displaying key bindings.
Usage: (def bindings [{:key "j/k" :desc "up/down"} {:key "q" :desc "quit"}]) (def my-help (help bindings))
;; In view function: (help-view my-help)
Help component for displaying key bindings.
Usage:
(def bindings [{:key "j/k" :desc "up/down"}
{:key "q" :desc "quit"}])
(def my-help (help bindings))
;; In view function:
(help-view my-help)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)
Pagination component for displaying page indicators.
Usage: (def pager (paginator :total-pages 5))
;; In update function: (paginator-update pager msg)
;; In view function: (paginator-view pager)
Pagination component for displaying page indicators. Usage: (def pager (paginator :total-pages 5)) ;; In update function: (paginator-update pager msg) ;; In view function: (paginator-view pager)
Progress bar component.
Usage: (def my-progress (progress-bar :width 40))
;; Update progress (0.0 to 1.0): (set-progress my-progress 0.5)
;; In view function: (progress-view my-progress)
Progress bar component. Usage: (def my-progress (progress-bar :width 40)) ;; Update progress (0.0 to 1.0): (set-progress my-progress 0.5) ;; In view function: (progress-view my-progress)
Animated spinner component.
Usage: (def my-spinner (spinner :dots))
;; In update function: (spinner-update my-spinner msg)
;; In view function: (spinner-view my-spinner)
Animated spinner component. Usage: (def my-spinner (spinner :dots)) ;; In update function: (spinner-update my-spinner msg) ;; In view function: (spinner-view my-spinner)
Text input component with cursor movement and editing.
Usage: (def my-input (text-input :prompt "Name: "))
;; In update function: (text-input-update my-input msg)
;; In view function: (text-input-view my-input)
Text input component with cursor movement and editing. Usage: (def my-input (text-input :prompt "Name: ")) ;; In update function: (text-input-update my-input msg) ;; In view function: (text-input-view my-input)
Countdown timer component.
Usage: (def my-timer (timer :timeout 60000)) ; 60 seconds
;; In update function: (timer-update my-timer msg)
;; In view function: (timer-view my-timer)
Countdown timer component. Usage: (def my-timer (timer :timeout 60000)) ; 60 seconds ;; In update function: (timer-update my-timer msg) ;; In view function: (timer-view my-timer)
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})
```Terminal input handling.
Reads raw terminal input and converts it to structured key and mouse events.
Terminal input handling. Reads raw terminal input and converts it to structured key and mouse events.
JLine KeyMap-based escape sequence handling.
Uses JLine's KeyMap for efficient O(1) escape sequence lookup with terminal capability awareness.
JLine KeyMap-based escape sequence handling. Uses JLine's KeyMap for efficient O(1) escape sequence lookup with terminal capability awareness.
Key sequence definitions and parsing.
Maps terminal escape sequences to key types and provides utilities for key identification.
For escape sequence lookup, see charm.input.keymap which uses JLine's KeyMap for efficient terminal-aware sequence matching.
Key sequence definitions and parsing. Maps terminal escape sequences to key types and provides utilities for key identification. For escape sequence lookup, see charm.input.keymap which uses JLine's KeyMap for efficient terminal-aware sequence matching.
Mouse event parsing for terminal input.
Supports:
Mouse event parsing for terminal input. Supports: - X10 mouse encoding (CSI M followed by 3 bytes) - SGR mouse encoding (CSI < params M/m)
Message types for charm.clj TUI applications.
Messages are plain maps with a :type key for easy pattern matching. Use factory functions to create messages and predicates to check types.
Message types for charm.clj TUI applications. Messages are plain maps with a :type key for easy pattern matching. Use factory functions to create messages and predicates to check types.
The Elm Architecture event loop for TUI applications.
A program consists of:
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.
Terminal renderer using JLine's Display for efficient diffing.
Provides a high-level rendering API that efficiently updates the terminal by only redrawing changed content.
Terminal renderer using JLine's Display for efficient diffing. Provides a high-level rendering API that efficiently updates the terminal by only redrawing changed content.
ANSI control sequences for terminal features without JLine capability equivalents.
For cursor movement, screen clearing, and alt screen, use charm.terminal which uses JLine's capability-based approach for better terminal compatibility.
ANSI control sequences for terminal features without JLine capability equivalents. For cursor movement, screen clearing, and alt screen, use charm.terminal which uses JLine's capability-based approach for better terminal compatibility.
Border rendering for styled boxes.
Provides predefined border styles and functions for rendering borders around text content.
Border rendering for styled boxes. Provides predefined border styles and functions for rendering borders around text content.
Terminal color handling.
Supports:
Terminal color handling. Supports: - ANSI 16 basic colors (0-15) - ANSI 256 extended palette (0-255) - True color RGB (24-bit)
Main styling API.
Create styles as maps and apply them to text.
Example: (def my-style (style :fg (rgb 255 0 0) :bold true :padding [1 2])) (render my-style "Hello!") ; => styled text
Main styling API. Create styles as maps and apply them to text. Example: (def my-style (style :fg (rgb 255 0 0) :bold true :padding [1 2])) (render my-style "Hello!") ; => styled text
Layout utilities: padding, margin, alignment, and joining.
Layout utilities: padding, margin, alignment, and joining.
JLine terminal wrapper for charm.clj
JLine terminal wrapper for charm.clj
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 |