diff --git a/org/channel-tui-view.org b/org/channel-tui-view.org index 97daf45..a7254a1 100644 --- a/org/channel-tui-view.org +++ b/org/channel-tui-view.org @@ -59,7 +59,9 @@ Returns a list of strings, one per line." (nreverse lines))) (defun view-status (fb w h) - (let* ((bg (theme-color :status-bg)) + (let* ((w (or (and (numberp w) (> w 0) w) 80)) + (h (or (and (numberp h) (> h 0) h) 24)) + (bg (theme-color :status-bg)) (fg (theme-color :status-fg)) (ver (st :daemon-version)) (ver-str (if ver (format nil " v~a" ver) "")) @@ -94,7 +96,9 @@ Returns a list of strings, one per line." (if (string= result "") content result)))) (defun view-chat (fb w h) - (let* ((msgs (st :messages)) (total (length msgs)) + (let* ((w (or (and (numberp w) (> w 0) w) 80)) + (h (or (and (numberp h) (> h 0) h) 24)) + (msgs (st :messages)) (total (length msgs)) (max-lines (- h 4)) (is-search (st :search-mode)) (y 0)) (when is-search (let* ((matches (st :search-matches)) (idx (st :search-match-idx)) @@ -209,7 +213,9 @@ Returns a list of strings, one per line." ** Input Line #+BEGIN_SRC lisp :tangle /home/user/.local/share/passepartout/lisp/channel-tui-view.lisp (defun view-input (fb w h) - (let* ((text (input-string)) + (let* ((w (or (and (numberp w) (> w 0) w) 80)) + (h (or (and (numberp h) (> h 0) h) 24)) + (text (input-string)) (pos (or (st :cursor-pos) 0)) (display-start (max 0 (- pos (1- w)))) (visible (subseq text display-start (min (length text) (+ display-start w))))) @@ -222,7 +228,9 @@ Returns a list of strings, one per line." #+BEGIN_SRC lisp :tangle /home/user/.local/share/passepartout/lisp/channel-tui-view.lisp (defun view-sidebar (fb w h) "Render the right-side sidebar panel with warm colors." - (let* ((x (- w (or (st :sidebar-width) 30))) + (let* ((w (or (and (numberp w) (> w 0) w) 80)) + (h (or (and (numberp h) (> h 0) h) 24)) + (x (- w (or (st :sidebar-width) 30))) (y 0)) ;; Vertical separator (dotimes (row h) @@ -266,6 +274,8 @@ Returns a list of strings, one per line." ** Redraw (dirty-flag dispatch) #+begin_src lisp (defun redraw (fb w h) + (setq w (or (and (numberp w) (> w 0) w) 80) + h (or (and (numberp h) (> h 0) h) 24)) (destructuring-bind (sd cd id) (st :dirty) (when sd (view-status fb w h)) (when cd (view-chat fb w h)) diff --git a/passepartout b/passepartout index 9ea8b42..f233c4d 100755 --- a/passepartout +++ b/passepartout @@ -406,9 +406,12 @@ case "$COMMAND" in (sleep 3) (finish-output) (uiop:quit 1)))) (passepartout.channel-tui:tui-main)) LISPEOF - # Export terminal dimensions — bash sets COLUMNS/LINES but - # doesn't export them to subprocesses by default. - export COLUMNS LINES + # Set terminal dimensions from stty — bash's $COLUMNS/$LINES + # are often missing or not exported. stty size always works. + local ts=$(stty size 2>/dev/null) + export COLUMNS="${ts#* }" LINES="${ts% *}" + [ -z "$COLUMNS" ] && COLUMNS=80 + [ -z "$LINES" ] && LINES=24 # Clear stale cl-tty cache to ensure latest backend-size fixes find ~/.cache/common-lisp -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null exec sbcl --noinform --load /tmp/tui-load.lisp