fix: nil guards on w and h in all view functions
Prevents crash when backend-size returns nil for height. Defaults to 80x24 if dimensions are nil or invalid.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user