diff --git a/src/backend/modern.lisp b/src/backend/modern.lisp index b9a8450..6cf453a 100644 --- a/src/backend/modern.lisp +++ b/src/backend/modern.lisp @@ -189,6 +189,15 @@ as a fallback when a keyword is not in *named-colors*.") (rstr (sb-ext:posix-getenv "LINES")) (cols (when cstr (parse-integer cstr :junk-allowed t))) (rows (when rstr (parse-integer rstr :junk-allowed t)))) + ;; Some environments set only COLUMNS or only LINES. + ;; If one is missing, try the other from stty. + (when (and cols (null rows)) + (let* ((out (uiop:run-program '("stty" "size") + :output :string + :ignore-error-status t)) + (parts (when out (uiop:split-string (string-trim '(#\newline #\space) out))))) + (setf rows (when (and parts (= (length parts) 2)) + (parse-integer (second parts) :junk-allowed t))))) (when (and cols rows (> cols 0) (> rows 0)) (values cols rows)))) (values w h))))) diff --git a/src/backend/simple.lisp b/src/backend/simple.lisp index e2704a4..dd0bcba 100644 --- a/src/backend/simple.lisp +++ b/src/backend/simple.lisp @@ -48,6 +48,13 @@ (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 (null rows)) + (let* ((out (uiop:run-program '("stty" "size") + :output :string + :ignore-error-status t)) + (parts (when out (uiop:split-string (string-trim '(#\newline #\space) out))))) + (setf rows (when (and parts (= (length parts) 2)) + (parse-integer (second parts) :junk-allowed t))))) (when (and cols rows (> cols 0) (> rows 0)) (values cols rows)))) (values w h)))))