Files
cl-tty/demo.lisp
Hermes 5a053b69c6 Fix demo: use correct function signatures and keyword args
- draw-border needs :style keyword before :single/:double
- draw-text needs fg and bg color keywords
- demo renders correctly in a real terminal
- Tested with: (sleep 2; echo q) | script -q -c 'sbcl --script demo.lisp'
2026-05-11 21:33:35 +00:00

73 lines
3.7 KiB
Common Lisp

;;; demo.lisp — cl-tty demo application
;;; Run: sbcl --script demo.lisp
(load "~/quicklisp/setup.lisp")
(ql:register-local-projects)
(ql:quickload :cl-tty :silent t)
;; ─── Demo ───────────────────────────────────────────────────────────────────
(defun run-demo ()
(let ((backend (make-instance 'cl-tty.backend:modern-backend))
(read-fn (symbol-function (find-symbol "READ-RAW-BYTE" :cl-tty.input))))
;; Initialize
(cl-tty.backend:initialize-backend backend)
(cl-tty.backend:backend-clear backend)
(cl-tty.backend:cursor-hide backend)
;; Title box
(cl-tty.backend:draw-border backend 1 1 78 3 :style :double :title " cl-tty Demo ")
(cl-tty.backend:draw-text backend 3 2
"A pure-CL terminal UI framework. No ncurses, no FFI."
:white :default :bold t)
;; Components grid
(cl-tty.backend:draw-border backend 1 5 78 12 :style :single :title " Components ")
(loop for i from 0 below 5
for item = (nth i '((" Box Bordered containers with title and background"
" Text Styled text with word-wrap and spans")
(" ScrollBox Scrollable viewport with scrollbars"
" TabBar Horizontal tab navigation")
(" Select Dropdown with fuzzy filter"
" TextInput / TextArea Single/multi-line input with undo")
(" Markdown Renders markdown with syntax highlighting"
" Dialog / Toast Modal overlays and notifications")
(" Mouse Event handlers and text selection"
" Slot System Named slots for extensible UI")))
do (cl-tty.backend:draw-text backend 3 (+ 7 i) (first item) :white :default)
(cl-tty.backend:draw-text backend 42 (+ 7 i) (second item) :white :default))
;; Backend features table
(cl-tty.backend:draw-border backend 1 18 78 5 :style :single :title " Backend Support ")
(cl-tty.backend:draw-text backend 3 20 "Feature" :bright-white :default :bold t)
(cl-tty.backend:draw-text backend 25 20 "modern" :bright-white :default :bold t)
(cl-tty.backend:draw-text backend 40 20 "simple" :bright-white :default :bold t)
(cl-tty.backend:draw-text backend 3 21 "Truecolor (24-bit)" :white :default)
(cl-tty.backend:draw-text backend 25 21 "yes" :green :default)
(cl-tty.backend:draw-text backend 40 21 "no" :red :default)
(cl-tty.backend:draw-text backend 3 22 "OSC 8 hyperlinks" :white :default)
(cl-tty.backend:draw-text backend 25 22 "yes" :green :default)
(cl-tty.backend:draw-text backend 40 22 "no" :red :default)
;; Footer bar
(cl-tty.backend:draw-rect backend 1 24 78 1 :bg :blue)
(cl-tty.backend:draw-text backend 2 24 " Press q to quit " :bright-white :blue :bold t)
(cl-tty.backend:cursor-show backend)
;; Wait for q keypress
(loop
(let ((ch (funcall read-fn :timeout 1)))
(when ch
(when (or (char= (code-char ch) #\q) (= ch 3))
(return)))))
;; Cleanup
(cl-tty.backend:backend-clear backend)
(cl-tty.backend:shutdown-backend backend)))
;; ─── Run ────────────────────────────────────────────────────────────────────
(when (probe-file "/dev/tty")
(run-demo))