Hi Collin,

> POSIX 2024 added these two functions in termios.h, tcgetwinsize and
> tcsetwinsize. They get and set the terminal size respectively.
> 
> As far as I can tell only NetBSD has them implemented [1]. They seem
> pretty useful and are easy to implement. I've attached two files that
> should work on Linux and BSDs (and any other system with ioctl,
> TIOCGWINSZ, TIOCSWINSZ).
> 
> Any thoughts on adding them?

I would only add tcgetwinsize, for two reasons:
  - The man page that you cite says "In general, the tcsetwinsize function
    is best avoided except by applications responsible for actually
    implementing terminal windows."
  - How would you write a unit test for tcsetwinsize? Also, so much
    of its effects is unspecified.

Terminal stuff is generally a portability pain — see tests/test-openpty.c.
Therefore I would limit myself to the functionality that applications
actually need.

> Windows should be able to support them too [2].

This needs thought first, because where on the Unix side you have
two concepts:
  - winsize from the OS,
  - lines and columns from the terminfo description of $TERM,
    and the LINES and COLUMNS environment variables,
on the Windows side you have only the Consoles.

How are these concepts delimited (on the Unix side)?

How do these concepts map to each other?

Bruno




Reply via email to