fix: set both dimensions from stty, add tput fallback, export shell vars
- stty size returns 'rows cols'. Old code set only one dimension when both env vars were missing; new code sets both. - Added tput cols/lines as final env-var fallback for systems where COLUMNS/LINES are not exported and stty is unavailable. - Added 'export COLUMNS LINES' to the passepartout script so SBCL can read them from the environment.
This commit is contained in:
@@ -46,10 +46,21 @@
|
||||
(parts (and out (uiop:split-string
|
||||
(string-trim '(#\newline #\space) out)))))
|
||||
(when (and parts (= (length parts) 2))
|
||||
(let ((a (parse-integer (first parts) :junk-allowed t))
|
||||
(b (parse-integer (second parts) :junk-allowed t)))
|
||||
(when (and a b (> a 0) (> b 0))
|
||||
(if cols (setf rows b) (setf cols a)))))))
|
||||
(let ((stty-rows (parse-integer (first parts) :junk-allowed t))
|
||||
(stty-cols (parse-integer (second parts) :junk-allowed t)))
|
||||
(when (and stty-rows stty-cols (> stty-rows 0) (> stty-cols 0))
|
||||
(unless cols (setf cols stty-cols))
|
||||
(unless rows (setf rows stty-rows)))))))
|
||||
(unless (and cols rows)
|
||||
(let ((out (uiop:run-program '("sh" "-c" "tput cols 2>/dev/null; tput lines 2>/dev/null")
|
||||
:output :string
|
||||
:ignore-error-status t)))
|
||||
(when out
|
||||
(let* ((parts (uiop:split-string (string-trim '(#\newline #\space) out)))
|
||||
(a (when parts (parse-integer (first parts) :junk-allowed t)))
|
||||
(b (when (cdr parts) (parse-integer (second parts) :junk-allowed t))))
|
||||
(when a (setf cols a))
|
||||
(when b (setf rows b))))))
|
||||
(when (and cols rows (> cols 0) (> rows 0))
|
||||
(values cols rows))))
|
||||
(values 80 24)))
|
||||
|
||||
Reference in New Issue
Block a user