fix: add / env var fallback in backend-size

ioctl on stdout's fd can disagree with the real terminal size when
the process is started with stdout redirected or in some terminal
multiplexer configurations. / are set by every POSIX
shell at process start and reflect the actual terminal dimensions.

Priority: ioctl → env vars → 80x24 fallback.
This covers both initial sizing and dynamic SIGWINCH-driven resize.
This commit is contained in:
2026-05-14 12:57:01 -04:00
parent 7cdb556531
commit 5c8a253171
2 changed files with 21 additions and 3 deletions

View File

@@ -39,6 +39,13 @@
(values (sb-alien:deref winsize 1)
(sb-alien:deref winsize 0)))
(sb-alien:free-alien winsize))))
(ignore-errors
(let ((cols (parse-integer (sb-ext:posix-getenv "COLUMNS")
:junk-allowed t))
(rows (parse-integer (sb-ext:posix-getenv "LINES")
:junk-allowed t)))
(when (and cols rows (> cols 0) (> rows 0))
(values cols rows))))
(values 80 24)))
(defmethod backend-write ((b simple-backend) string)