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
(attributed-string style-map text)Create a JLine AttributedString with the given style applied.
This avoids the ANSI parse/unparse cycle when building content that will be rendered directly via JLine's Display.
For single lines without layout (padding, border, margin): (attributed-string my-style "Hello!")
For multiple parts with different styles: (-> (AttributedStringBuilder.) (.styled (style->attributed-style style1) "part1") (.styled (style->attributed-style style2) "part2") (.toAttributedString))
Create a JLine AttributedString with the given style applied.
This avoids the ANSI parse/unparse cycle when building content
that will be rendered directly via JLine's Display.
For single lines without layout (padding, border, margin):
(attributed-string my-style "Hello!")
For multiple parts with different styles:
(-> (AttributedStringBuilder.)
(.styled (style->attributed-style style1) "part1")
(.styled (style->attributed-style style2) "part2")
(.toAttributedString))(frame-size {:keys [padding margin border]})Calculate the frame size (padding + border + margin) of a style. Returns [width height].
Calculate the frame size (padding + border + margin) of a style. Returns [width height].
(render style & strings)Render text with a style applied.
(render style "text") (render style "multiple" "strings")
Render text with a style applied. (render style "text") (render style "multiple" "strings")
(style & {:as opts})Create a style map.
Options: ;; Colors :fg - Foreground color :bg - Background color
;; Text attributes :bold - Bold text :italic - Italic text :underline - Underline text :blink - Blinking text :faint - Faint/dim text :reverse - Reverse video
;; Dimensions :width - Fixed width (pads/truncates) :height - Fixed height
;; Alignment :align - Horizontal alignment (:left :center :right) :valign - Vertical alignment (:top :center :bottom)
;; Spacing :padding - Padding [top right bottom left] or single value :margin - Margin [top right bottom left] or single value
;; Border :border - Border style (from charm.style.border) :border-fg - Border foreground color :border-bg - Border background color
;; Rendering :inline - Remove newlines when true
Create a style map. Options: ;; Colors :fg - Foreground color :bg - Background color ;; Text attributes :bold - Bold text :italic - Italic text :underline - Underline text :blink - Blinking text :faint - Faint/dim text :reverse - Reverse video ;; Dimensions :width - Fixed width (pads/truncates) :height - Fixed height ;; Alignment :align - Horizontal alignment (:left :center :right) :valign - Vertical alignment (:top :center :bottom) ;; Spacing :padding - Padding [top right bottom left] or single value :margin - Margin [top right bottom left] or single value ;; Border :border - Border style (from charm.style.border) :border-fg - Border foreground color :border-bg - Border background color ;; Rendering :inline - Remove newlines when true
(style->attributed-style {:keys [fg bg bold italic underline blink faint
reverse]})Convert style map to JLine AttributedStyle.
Useful for direct AttributedString construction: (AttributedString. text (style->attributed-style my-style))
Convert style map to JLine AttributedStyle. Useful for direct AttributedString construction: (AttributedString. text (style->attributed-style my-style))
(styled text & style-opts)Apply style directly to text. Shorthand for (render (style opts...) text).
(styled "hello" :fg (rgb 255 0 0) :bold true)
Apply style directly to text. Shorthand for (render (style opts...) text). (styled "hello" :fg (rgb 255 0 0) :bold true)
(with-align s align)Set horizontal alignment.
Set horizontal alignment.
(with-margin s margin)Set margin. Accepts [t r b l] or single value.
Set margin. Accepts [t r b l] or single value.
(with-padding s padding)Set padding. Accepts [t r b l] or single value.
Set padding. Accepts [t r b l] or single value.
(with-valign s valign)Set vertical alignment.
Set vertical alignment.
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 |