microsoft / microsoft/terminal
Neither TIOCGWINSZ nor 14t allow introspection of the window size in pixels
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
Environment
Windows 10 Pro 20H2 (amd64)
Latest Windows Terminal Preview, running either msys2 or wsl
Steps to reproduce
compile and run the following code
#include <sys/ioctl.h>
#include <stdio.h>
int main (void)
{
struct winsize ws;
ioctl(1, TIOCGWINSZ, &ws);
printf("rows: %d cols: %d xpixel: %d ypixel: %d\n", ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
}
Separately, send the xterm 14t sequence as documented in https://www.xfree86.org/current/ctlseqs.html :
P s = 1 4 → Report xterm window in pixels as CSI 4 ; height ; width t
You can do that from a shell with:
echo -en "\033[14t\033\\"
Expected behavior
Both should work and return identical non 0 values
On mintty for example:
$ /d/wingetsize.exe
rows: 27 cols: 88 xpixel: 1056 ypixel: 729
This means the terminal is 729x1056
On wsltty running debian (WSL) for example:
$ echo -en "\033[14t\033\\"
^[[4;480;880t
This means the terminal is 880x480
Actual behavior
On a Windows Terminal running msys2:
$ /d/wingetsize.exe
rows: 25 cols: 98 xpixel: 0 ypixel: 0
The problem is not related to msys2 but purely Windows Terminal, as the above was obtained on a Windows Terminal running the exact same binaries and bash environment.
The absence of msys2 doesn't help: on a Windows Terminal running an official debian image (WSL) :
$ /mnt/d/wingetsize
rows: 21 cols: 84 xpixel: 0 ypixel: 0
To ignore any API issues, you can also try to send the specific xterm control sequence that should return the window size in pixels, and notice it returns nothing.
$ echo -en "\033[14t\033\\"
This properly returns the size on wsltty running debian-slim in WSL, so the problem is not related to WSL either:
This issue may be related to #3718 (querying the colors via OSC) if you only consider the xterm control sequence. However the 0 values in TIOCGWINSZ is a tty ioctl, making this a wider problem, so I believe this is a separate issue.
At least one of these methods should work: introspection is required by some software to adjust their rendering to the actual space available on the terminal.
The absence of TIOCGWINSZ also impacts issue #448, as explained more precisely in https://github.com/microsoft/Terminal/issues/448#issuecomment-639003989 and illustrated in https://github.com/microsoft/Terminal/issues/448#issuecomment-707765406 : the screen size, along with the number of row and columns would allow inferring the font size, to avoid sixel images being stretched, squizzed, or a fraction of the correct size by sending them to the right size (in pixels) for their placeholder (in characters)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows Terminal behavior with the provided TIOCGWINSZ sample and the CSI 14t shell sequence on Windows 10, comparing the zero or missing pixel dimensions with mintty or wsltty. Trace the terminal handling for these two entry points; done means at least one supported method reports valid nonzero pixel dimensions consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100