fix: clean TUI exit, restore terminal, suppress compiler warnings
passepartout script: - Add (uiop:quit 0) after tui-main so SBCL exits on Ctrl+Q - Remove exec to allow stty restore after sbcl subprocess - Restore icanon echo ixon after TUI exits (terminal stuck raw) channel-tui-view.org: - Remove unused fb/h vars from test-sidebar-not-shown-narrow - Add (declare (ignore w)) to render-styled - Qualify theme-color as passepartout.channel-tui:theme-color (render-styled is in :passepartout package) - Remove dead :url clause from pick in parse-markdown-spans (URLs handled by dedicated branch, not via pick) - Update literate prose for all changes
This commit is contained in:
@@ -322,6 +322,19 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
|||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* v0.7.1 — Markdown Rendering
|
* v0.7.1 — Markdown Rendering
|
||||||
|
|
||||||
|
~render-styled~ accepts a ~(text . plist)~ segment list from the span
|
||||||
|
parser and emits ~draw-text~ calls. The ~w~ parameter is ignored (layout
|
||||||
|
is line-at-a-time, not fixed-width); ~theme-color~ is fully qualified
|
||||||
|
as ~passepartout.channel-tui:theme-color~ since this function lives in
|
||||||
|
the ~passepartout~ package but the theme API is in ~passepartout.channel-tui~.
|
||||||
|
|
||||||
|
The inline span parser (~parse-markdown-spans~) delegates punctuation
|
||||||
|
delimiters (**bold**, `code`, *italic*) to a local ~pick~ helper.
|
||||||
|
URLs are handled directly via ~url-end~ rather than through ~pick~,
|
||||||
|
so the ~:url~ clause was removed from ~pick~'s ~case~ form to avoid
|
||||||
|
dead code.
|
||||||
|
|
||||||
#+BEGIN_SRC lisp :tangle /home/user/.local/share/passepartout/lisp/channel-tui-view.lisp
|
#+BEGIN_SRC lisp :tangle /home/user/.local/share/passepartout/lisp/channel-tui-view.lisp
|
||||||
(in-package :passepartout)
|
(in-package :passepartout)
|
||||||
|
|
||||||
@@ -339,13 +352,12 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
|||||||
(url-s (or https http)))
|
(url-s (or https http)))
|
||||||
(flet ((pick (tag delim)
|
(flet ((pick (tag delim)
|
||||||
(let ((end (search delim text :start2 (+ pos (length delim)))))
|
(let ((end (search delim text :start2 (+ pos (length delim)))))
|
||||||
(when end
|
(when end
|
||||||
(push (cons (subseq text (+ pos (length delim)) end)
|
(push (cons (subseq text (+ pos (length delim)) end)
|
||||||
(case tag (:bold '(:bold t))
|
(case tag (:bold '(:bold t))
|
||||||
(:code '(:code t :bgcolor :dim))
|
(:code '(:code t :bgcolor :dim))
|
||||||
(:underline '(:underline t))
|
(:underline '(:underline t))))
|
||||||
(:url '(:url t))))
|
results)
|
||||||
results)
|
|
||||||
(setf pos (+ end (length delim)))
|
(setf pos (+ end (length delim)))
|
||||||
t)))
|
t)))
|
||||||
(url-end (start)
|
(url-end (start)
|
||||||
@@ -365,6 +377,7 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
|||||||
|
|
||||||
(defun render-styled (fb segments y x w)
|
(defun render-styled (fb segments y x w)
|
||||||
"Render markdown segments to cl-tty backend. Returns next y."
|
"Render markdown segments to cl-tty backend. Returns next y."
|
||||||
|
(declare (ignore w))
|
||||||
(dolist (seg segments)
|
(dolist (seg segments)
|
||||||
(let* ((text (or (car seg) ""))
|
(let* ((text (or (car seg) ""))
|
||||||
(attrs (cdr seg))
|
(attrs (cdr seg))
|
||||||
@@ -373,8 +386,8 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
|||||||
(url (getf attrs :url)))
|
(url (getf attrs :url)))
|
||||||
(declare (ignore code))
|
(declare (ignore code))
|
||||||
(cl-tty.backend:draw-text fb x y text
|
(cl-tty.backend:draw-text fb x y text
|
||||||
(cond (url (theme-color :accent))
|
(cond (url (passepartout.channel-tui:theme-color :accent))
|
||||||
(t (theme-color (or (getf attrs :role) :agent-fg))))
|
(t (passepartout.channel-tui:theme-color (or (getf attrs :role) :agent-fg))))
|
||||||
nil
|
nil
|
||||||
:bold bold)
|
:bold bold)
|
||||||
(incf x (length text))))
|
(incf x (length text))))
|
||||||
@@ -593,10 +606,10 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
|||||||
"Contract v0.8.0: sidebar is skipped in redraw when terminal width < 120."
|
"Contract v0.8.0: sidebar is skipped in redraw when terminal width < 120."
|
||||||
(passepartout.channel-tui::init-state)
|
(passepartout.channel-tui::init-state)
|
||||||
(setf (passepartout.channel-tui::st :sidebar-visible) t)
|
(setf (passepartout.channel-tui::st :sidebar-visible) t)
|
||||||
;; Simulating redraw logic: should not invoke view-sidebar when w < 120.
|
;; Redraw guard: view-sidebar is only called when w >= 60. This
|
||||||
;; If view-sidebar were called with a nil fb it would error; this verifies
|
;; verifies the guard expression evaluates to nil at w=100 when
|
||||||
;; the guard in redraw protects the call.
|
;; sidebar-visible is set but width is below 120 threshold.
|
||||||
(let ((fb nil) (w 100) (h 24))
|
(let ((w 100))
|
||||||
(is (not (and (passepartout.channel-tui::st :sidebar-visible) (>= w 60))))))
|
(is (not (and (passepartout.channel-tui::st :sidebar-visible) (>= w 60))))))
|
||||||
|
|
||||||
(test test-status-bar-tokens
|
(test test-status-bar-tokens
|
||||||
|
|||||||
@@ -405,6 +405,7 @@ case "$COMMAND" in
|
|||||||
(format t "Full backtrace saved to ~~/.cache/passepartout/tui-crash.log~%")
|
(format t "Full backtrace saved to ~~/.cache/passepartout/tui-crash.log~%")
|
||||||
(sleep 3) (finish-output) (uiop:quit 1))))
|
(sleep 3) (finish-output) (uiop:quit 1))))
|
||||||
(passepartout.channel-tui:tui-main))
|
(passepartout.channel-tui:tui-main))
|
||||||
|
(uiop:quit 0)
|
||||||
LISPEOF
|
LISPEOF
|
||||||
# Capture terminal dimensions in non-standard env vars
|
# Capture terminal dimensions in non-standard env vars
|
||||||
# (SBCL strips COLUMNS/LINES but leaves MY_* alone).
|
# (SBCL strips COLUMNS/LINES but leaves MY_* alone).
|
||||||
@@ -415,7 +416,13 @@ LISPEOF
|
|||||||
stty -icanon -echo -ixon 2>/dev/null
|
stty -icanon -echo -ixon 2>/dev/null
|
||||||
# Clear stale cl-tty cache to ensure latest backend-size fixes
|
# Clear stale cl-tty cache to ensure latest backend-size fixes
|
||||||
find ~/.cache/common-lisp -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null
|
find ~/.cache/common-lisp -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null
|
||||||
exec sbcl --noinform --load /tmp/tui-load.lisp
|
sbcl --noinform --load /tmp/tui-load.lisp
|
||||||
|
rc=$?
|
||||||
|
# Restore terminal cooked mode — stty was set to -icanon -echo -ixon
|
||||||
|
# before exec (or sbcl subprocess) to get character-at-a-time input.
|
||||||
|
# Without this restore the terminal stays raw after exit.
|
||||||
|
stty icanon echo ixon 2>/dev/null
|
||||||
|
exit $rc
|
||||||
;;
|
;;
|
||||||
gateway)
|
gateway)
|
||||||
SUBCMD=$1; PLATFORM=$2; TOKEN=$3
|
SUBCMD=$1; PLATFORM=$2; TOKEN=$3
|
||||||
|
|||||||
Reference in New Issue
Block a user