-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get window size on more Windows terminals. #6010
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Nice! To confirm, this is bypassing Additionally, this means that if an msys terminal is resized it could produce some garbled output, right? (resized below 79 cols that is). I guess there's no way for us to actually learn the size of the console? |
When Cargo's stderr is connected to a pipe or redirected, If you mean when just stdout is piped (not stderr), then you get a progress bar, but that's true on all platforms. I initially did both You are correct, on mintty terminals you will get weird wrapping when it is less than 79. AFAIK, there is no way to get the correct information. As I mentioned in the issue, it is plumbed inside the guts of cygwin, and there's no sane way to get to it from a non-cygwin binary. I'm unsure how much of an issue that would be. It would be interesting to know how common different shell/terminal combinations are. Unfortunately I fear that "Git Bash" (which is mintty) from "Git for Windows" is probably pretty common, so it is somewhat risky. If its any consolation, git's progress bar wraps funny when the screen is too small (<~65). |
Ah ok cool, makes sense! Given that we check For MSYS though perhaps we could clamp to 60 or so columns as a conservative estimate? There's not really any real need to use the maximal terminal width other than it can look better |
That sounds like a good idea, i'll try to update this to do that soon. |
This is an alternate approach to determining the window size that works on more Windows terminals. Terminals with accurate width detection: Normal Windows console, cmder, ConEmu, VS Code, Hyper, etc. mintty-based terminals will always be 60 characters wide. Cygwin in a command console is ok, but running under x-windows will also always be 60. Tested on Windows 8 and Windows 10. Closes rust-lang#5124.
Updated with a different approach. I was reluctant to copy all the code from atty to detect msys terminals specifically, since it doesn't buy a whole lot. |
@bors: r+ Looks good to me! |
📌 Commit 5b139d1 has been approved by |
Get window size on more Windows terminals. This is an alternate approach to determining the window size that works on more Windows terminals. Terminals with accurate width detection: Normal Windows console, cmder, ConEmu, VS Code, Hyper, etc. mintty-based terminals will always be 60 characters wide. Cygwin in a command console is ok, but running under x-windows will also always be 60. Tested on Windows 8 and Windows 10. Closes #5124.
☀️ Test successful - status-appveyor, status-travis |
This is an alternate approach to determining the window size that works on more Windows terminals.
Terminals with accurate width detection: Normal Windows console, cmder, ConEmu, VS Code, Hyper, etc.
mintty-based terminals will always be 60 characters wide. Cygwin in a command console is ok, but
running under x-windows will also always be 60.
Tested on Windows 8 and Windows 10.
Closes #5124.