[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why doesn't ncurses use my Terminfo file's `cols` and `lines`?
From: |
Thomas Dickey |
Subject: |
Re: Why doesn't ncurses use my Terminfo file's `cols` and `lines`? |
Date: |
Thu, 22 Jun 2023 15:02:43 -0400 |
On Thu, Jun 22, 2023 at 10:11:09AM -0400, Stefan Monnier wrote:
> > It's in the manpage - setupterm:
>
> Thanks.
>
> > The terminfo variables lines and columns are initialized by
> > setupterm
> > as follows:
> >
> > • If use_env(FALSE) has been called, values for lines and
> > columns
> > specified in terminfo are used.
> >
> > • Otherwise, if the environment variables LINES and COLUMNS
> > exist,
> > their values are used. If these environment variables do not
> > exist
> > and the program is running in a window, the current window size
> > is
> > used. Otherwise, if the environment variables do not exist,
> > the
> > values for lines and columns specified in the terminfo database
> > are
> > used.
>
> The program is running in a real terminal started from getty started
> from systemd.
>
> > Also, use_tioctl and use_env. But aside from adding use_tioctl in 2012
>
> Aha! Last time I used that terminal was around year 2000.
>
> > https://invisible-island.net/ncurses/NEWS.html#t20120714
> >
> > the rules for initialization haven't changed for a long time (barring bugs
> > of course). That "current window size" refers to information from a
> > TIOCGWINSZ ioctl.
>
> In the `strace tput lines` I see that the right terminfo file is read
> and it ends with:
>
> ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IXOFF|IUTF8,
> c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR,
> c_cflag=B19200|CS8|CREAD|HUPCL|CLOCAL,
> c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE, ...}) = 0
> ioctl(0, TIOCGWINSZ, {ws_row=24, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0
> statx(1, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH,
> STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID,
> stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=6357, ...}) = 0
> write(1, "24\n", 324
> ) = 3
> exit_group(0) = ?
> +++ exited with 0 +++
>
> So, IIUC this line:
>
> ioctl(0, TIOCGWINSZ, {ws_row=24, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0
>
> says that `tput` queried the kernel about TIOCGWINSZ and the kernel
> replied with 80x24. So, IIUC this is a kernel bug?
no - it's a default value, and nothing comes along to improve it.
Actually, given the description
Human Designed Systems HDS3200 model 20; VT220 7bits; 50x132;
auto-wrap=no
I'd expect that you could use "resize" to get the window size updated.
> I see that's what `stty cols NN rows MM` can override this, so, I should
> figure out how to get systemd/getty to do that setup to work around
> the problem.
>
> > In a quick check, if I disable the TIOCGWINSZ call in ncurses, and test
> > your terminfo, ncurses does set lines/cols as you expect. If your terminal
> > is connected directly to a serial port, I would not expect stty to give a
> > size -- but if it's through some intermediate application (even something
> > such as ssh, which "should" not helpfully provide a size), then that could
> > be providing a size.
>
> Indeed, it's weird that the kernel returns 80x24 for a real terminal
> connected via a USB<->RS232 adapter. Then again, I guess such setups
> are getting extremely rare.
>
> Thanks,
>
>
> Stefan
>
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
signature.asc
Description: PGP signature