Duck tiocgwinsz.

This commit is contained in:
Dominik Pantůček 2023-12-05 22:22:27 +01:00
parent 0b23dd6666
commit fd05ecda88

View file

@ -25,8 +25,11 @@
(declare (unit tiocgwinsz))
(module
(import duck)
(module*
tiocgwinsz
#:doc ("TTY terminal size support.")
(
tiocgwinsz
)
@ -50,7 +53,8 @@ if (ioctl(0, TIOCGWINSZ, &wss) == 0) {
"
))
(define (tiocgwinsz)
(define/doc (tiocgwinsz)
("Returns the number of terminal rows and columns.")
(let ((res (tiocgwinsz-ioctl)))
(values (bitwise-and res #xffff)
(arithmetic-shift res -16))))