fix: close defun on-key with missing paren, complete cl-tty TUI migration

- Added missing closing paren for defun on-key in org/channel-tui-main.org
  line 616 (was 7 trailing ), now 8)
- Replaced #\) character literal with (code-char 41) to avoid reader
  ambiguity with paren-delimiter counting
- All 3 TUI org files tangled and verified compilable
- passepartout/tui loads without errors under SBCL 2.5.2
This commit is contained in:
Hermes
2026-05-12 21:35:14 +00:00
parent d77d41f3a8
commit 757541c83b
9 changed files with 658 additions and 286 deletions

View File

@@ -2606,3 +2606,136 @@ World models, temporal reasoning, goal persistence across restarts.
- World models: Predictive models of user behavior, project dynamics, system state.
- Temporal reasoning: Scheduling, deadlines, elapsed duration awareness.
- Goal persistence: Goals survive restarts. Long-term projects in memory-objects.
* v0.7.3: cl-tty TUI Migration
** Summary
Replace Croatoan (ncurses CFFI) with cl-tty (pure CL, no FFI) as the
terminal rendering backend for the TUI channels. Original rationale:
Croatoan is broken, cl-tty was purpose-built for this use case.
** Architecture decisions
1. Keep passepartout's state model (plist via ~st~/~(setf st)~) and
event dispatch (~on-key~, ~on-daemon-msg~) unchanged. Only the
output path changes.
2. Use cl-tty's framebuffer-backend for rendering: draw to framebuffer
cells, then diff+flush to the real backend. This gives minimal
terminal writes for free (only changed cells are sent).
3. Main loop: ~cl-tty.input:with-raw-terminal~ + ~cl-tty.backend:with-terminal~
replaces ~croatoan:with-screen~.
4. Input: ~cl-tty.input:read-event~ with ~:timeout 0~ replaces
~croatoan:get-char~ + ~code-key~/~key-name~ conversion.
5. Resize: cl-tty's SIGWINCH handler + ~:resize~ event replaces
Croatoan's KEY_RESIZE (410).
6. Markdown rendering: drop passepartout's hand-rolled ~render-styled~
(no longer called from view-chat). Wire cl-tty's built-in markdown
renderer as a follow-up.
** Remaining work (in order)
*** DONE Update .asd: swap :croatoan for :cl-tty
The ~:passepartout/tui~ system no longer depends on ~:croatoan~.
Depends on ~:cl-tty~ instead.
*** DONE Remove Croatoan from package (state.org)
~:use :cl :croatoan ...~~:use :cl ...~. Export list unchanged.
~theme-color~ returns hex strings (cl-tty compatible) instead of
Croatoan color keywords.
*** DONE Rewrite main loop (main.org)
~tui-main~ now uses ~with-raw-terminal~ + ~with-terminal~ + framebuffer.
Key dispatch uses ~read-event~ returning structured events instead of
raw Croatoan codes / ~code-key~ conversion. Resize handled by cl-tty's
~:resize~ event type.
*** DONE Rewrite view functions (view.org)
~view-status~, ~view-chat~, ~view-input~, ~redraw~ all rewritten to
take a framebuffer-backend and use ~cl-tty.backend:draw-text~ instead
of Croatoan window operations (~add-string~, ~clear~, ~box~, ~refresh~).
*** TODO Fix render-styled (view.org)
~render-styled~ (Implementation section, v0.7.1 Markdown Rendering block)
still uses Croatoan's ~add-string~ and ~height~. This function is no
longer called from ~view-chat~ (replaced with plain ~draw-text~), but
it still exists in the source and causes a compile error because the
Croatoan package is no longer loaded.
Fix: Either (a) replace ~add-string~/~height~ with cl-tty equivalents
and keep the function for future styled markdown, or (b) remove it
entirely since it's dead code. Option (a) is preferred for
forward-compatibility.
Also remove ~height~ window dimension access (only used in
~render-styled~). Remove ~parse-markdown-spans~ if it's only called
from ~render-styled~ (it's not — it's used in the old view-chat
Croatoan code which has been replaced).
*** TODO Clean up render-styled's Croatoan references
~parse-markdown-spans~, ~syntax-highlight~, ~parse-markdown-blocks~,
and ~gate-trace-lines~ are all pure CL utility functions that don't
depend on Croatoan. Only ~render-styled~ itself uses Croatoan window
operations.
Concrete changes to ~render-styled~:
src="org/channel-tui-view.org" lang="diff"
-(defun render-styled (win segments y x w)
- "Render markdown segments to Croatoan window. Returns next y."
- (dolist (seg segments)
- (when (>= y (height win)) (return y))
- (let* ((text (or (car seg) ""))
- (attrs (cdr seg))
- (bold (getf attrs :bold))
- (code (getf attrs :code))
- (underline (getf attrs :underline))
- (url (getf attrs :url)))
- (add-string win text :y y :x x :n (max 1 (- w x))
- :bold bold :underline underline
- :bgcolor (when code (theme-color :dim))
- :fgcolor (cond (url (theme-color :highlight))
- (t (theme-color (or (getf attrs :role) :agent)))))
- (incf x (length text))))
- y)
+(defun render-styled (fb segments y x w)
+ "Render markdown segments to framebuffer. Returns next y."
+ (dolist (seg segments)
+ (let* ((text (or (car seg) ""))
+ (attrs (cdr seg))
+ (bold (getf attrs :bold))
+ (code (getf attrs :code))
+ (url (getf attrs :url)))
+ (cl-tty.backend:draw-text fb x y text
+ (cond (url (theme-color :highlight))
+ (t (theme-color (or (getf attrs :role) :agent))))
+ nil :bold bold)
+ (incf x (length text))))
+ y)
"""
*** TODO Tangled view.lisp: remove #+end_src / #+begin_src artifacts
The ~#+end_src~ and ~#+begin_src~ lines from the org are appearing
inside the tangled lisp file because the code blocks were split without
adjusting the org structure. Clean up any org artifacts in the generated
.lisp files.
*** TODO Verify compilation
1. ~cl-tty.input:with-raw-terminal~ resolves (stty-based, defined in
text-input.org → input.lisp, exported from cl-tty.input package)
2. ~cl-tty.backend:draw-text~ resolves on framebuffer-backend
3. ~cl-tty.rendering:flush-framebuffer~, ~make-framebuffer~ resolve
4. ~cl-tty.input:read-event~ returns structured events
5. ~cl-tty.input:*terminal-resized-p*~ exported
6. ~cl-tty.rendering:backend-clear~ dispatches on framebuffer-backend
*** TODO Push branch and let user test