fix: add COLUMNS/LINES env var fallback in backend-size
When all ioctl methods return rows=0 (SBCL process context), try / from the shell environment. These are set by bash and may survive SBCL's env filtering in some configurations.
This commit is contained in:
@@ -205,6 +205,16 @@ as a fallback when a keyword is not in *named-colors*.")
|
|||||||
(rows (sb-alien:deref winsize 0)))
|
(rows (sb-alien:deref winsize 0)))
|
||||||
(values cols rows)))))
|
(values cols rows)))))
|
||||||
(sb-unix:unix-close tty-fd)))))
|
(sb-unix:unix-close tty-fd)))))
|
||||||
|
;; $COLUMNS/$LINES env vars — set by bash, may be available
|
||||||
|
;; even when ioctl fails (SBCL strips them in some contexts
|
||||||
|
;; but not all).
|
||||||
|
(ignore-errors
|
||||||
|
(let* ((cstr (sb-ext:posix-getenv "COLUMNS"))
|
||||||
|
(rstr (sb-ext:posix-getenv "LINES"))
|
||||||
|
(cols (when cstr (parse-integer cstr :junk-allowed t)))
|
||||||
|
(rows (when rstr (parse-integer rstr :junk-allowed t))))
|
||||||
|
(when (and cols rows (> cols 0) (> rows 0))
|
||||||
|
(values cols rows))))
|
||||||
(values 80 24)))
|
(values 80 24)))
|
||||||
|
|
||||||
(defmethod backend-write ((b modern-backend) string)
|
(defmethod backend-write ((b modern-backend) string)
|
||||||
|
|||||||
@@ -63,6 +63,14 @@
|
|||||||
(sb-alien:deref winsize 0))))
|
(sb-alien:deref winsize 0))))
|
||||||
(sb-alien:free-alien winsize))
|
(sb-alien:free-alien winsize))
|
||||||
(sb-unix:unix-close tty-fd)))))
|
(sb-unix:unix-close tty-fd)))))
|
||||||
|
;; $COLUMNS/$LINES env vars
|
||||||
|
(ignore-errors
|
||||||
|
(let* ((cstr (sb-ext:posix-getenv "COLUMNS"))
|
||||||
|
(rstr (sb-ext:posix-getenv "LINES"))
|
||||||
|
(cols (when cstr (parse-integer cstr :junk-allowed t)))
|
||||||
|
(rows (when rstr (parse-integer rstr :junk-allowed t))))
|
||||||
|
(when (and cols rows (> cols 0) (> rows 0))
|
||||||
|
(values cols rows))))
|
||||||
(values 80 24)))
|
(values 80 24)))
|
||||||
|
|
||||||
(defmethod backend-write ((b simple-backend) string)
|
(defmethod backend-write ((b simple-backend) string)
|
||||||
|
|||||||
Reference in New Issue
Block a user