Scrollable text area component.
Displays a window into pre-rendered (possibly styled) text content.
Usage: (def vp (viewport "Long text content..." :height 10))
;; In update function: (viewport-update vp msg)
;; In view function: (viewport-view vp)
Scrollable text area component. Displays a window into pre-rendered (possibly styled) text content. Usage: (def vp (viewport "Long text content..." :height 10)) ;; In update function: (viewport-update vp msg) ;; In view function: (viewport-view vp)
(scroll-down vp)(scroll-down vp n)Scroll down by n lines (default 1).
Scroll down by n lines (default 1).
(scroll-half-page-down vp)Scroll down by half the viewport height.
Scroll down by half the viewport height.
(scroll-half-page-up vp)Scroll up by half the viewport height.
Scroll up by half the viewport height.
(scroll-page-down vp)Scroll down by one full page.
Scroll down by one full page.
(scroll-page-up vp)Scroll up by one full page.
Scroll up by one full page.
(scroll-to-bottom vp)Scroll to the bottom.
Scroll to the bottom.
(scroll-up vp)(scroll-up vp n)Scroll up by n lines (default 1).
Scroll up by n lines (default 1).
(viewport content
&
{:keys [width height y-offset keys id]
:or {width 0 height 0 y-offset 0 id (rand-int 1000000)}})Create a viewport component.
Content is a string (may contain ANSI escape sequences).
Options: :width - Display width (0 = no constraint) :height - Visible height in lines (0 = show all) :y-offset - Initial scroll position (default 0) :keys - Custom key bindings :id - Unique ID
Create a viewport component. Content is a string (may contain ANSI escape sequences). Options: :width - Display width (0 = no constraint) :height - Visible height in lines (0 = show all) :y-offset - Initial scroll position (default 0) :keys - Custom key bindings :id - Unique ID
(viewport-at-bottom? vp)Check if the viewport is scrolled to the bottom.
Check if the viewport is scrolled to the bottom.
(viewport-at-top? vp)Check if the viewport is scrolled to the top.
Check if the viewport is scrolled to the top.
(viewport-content vp)Get the raw content string.
Get the raw content string.
(viewport-init vp)Initialize the viewport, returns [viewport cmd].
Initialize the viewport, returns [viewport cmd].
(viewport-line-count vp)Get the total number of lines in the content.
Get the total number of lines in the content.
(viewport-scroll-percent vp)Get the current scroll position as a percentage (0.0-1.0).
Get the current scroll position as a percentage (0.0-1.0).
(viewport-scroll-to vp line)Scroll to a specific line number.
Scroll to a specific line number.
(viewport-set-content vp content)Set the content, resetting scroll position.
Set the content, resetting scroll position.
(viewport-set-dimensions vp width height)Set the viewport width and height.
Set the viewport width and height.
(viewport-update vp msg)Update viewport state based on a message. Returns [new-viewport cmd] or [viewport nil] if message not handled.
Update viewport state based on a message. Returns [new-viewport cmd] or [viewport nil] if message not handled.
(viewport-view vp)Render the viewport to a string.
Shows only the visible lines based on y-offset and height. If width is set, lines are padded/truncated to fit.
Render the viewport to a string. Shows only the visible lines based on y-offset and height. If width is set, lines are padded/truncated to fit.
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 |