bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: Adding tcgetwinsize and tcsetwinsize.


From: Collin Funk
Subject: Re: RFC: Adding tcgetwinsize and tcsetwinsize.
Date: Mon, 27 May 2024 22:18:08 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Bruno Haible <bruno@clisp.org> writes:
>> > 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)?
>
> IMO the documentation should tell the application writer:
>   - when should tcgetwinsize be used?
>   - when should $TERM be used?
>   - when should $LINES, $COLUMNS be used?
> Three concepts. Which to use in which situations?

Sure, perhaps I will write a texinfo page for that function before
anything else.

Section 8.3 "Other Environment Variables" has a decent description [1].
The newest draft is better since it mentions tcgetwinsize & tcsetwinsize.

The process goes something like:

1. If $LINES and $COLUMNS are set to positive decimal numbers use them.
   - POSIX recommends users leave these unset unless there is a reason
     to override system behavior (e.g. output narrower than the actual
     window).
2. If they are unset (or invalid) use a system interface such as
   tcgetwinsize or ioctl to query the terminal window size. Use that
   size or smaller.
3. If those interfaces fail or do not exist on your system then pick a
   small size appropriate for a terminal window. POSIX recommends
   scaling with the baud rate, but I feel like it is standard practice
   to assume things work and use 80x24 if not.

I think bash updates $LINES and $COLUMNS after every command by default,
but I'm not sure how other shells behave.

Collin

[1] https://pubs.opengroup.org/onlinepubs/9699919799/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]