Open TimonPost opened 3 years ago
For terminal size, on Git Bash (which uses MSYS2 behind the scenes), tput cols
and tput lines
seem to work.
Hi @TimonPost
Just wanted to add something to the discussion here - someone might find it useful. (I tried many TUI programs that use the crossterm-rs backend - listed below.)
Most Windows-native, non-MSYS2 apps don't work inside mintty, You need to set the environment variable MSYS
to enable_pcon
, and then launch mintty - to make Windows-native apps work fully. More info can be found in this discussion mintty/wsltty#271.
When using Git Bash, you need to launch the TUI apps with the TERM
variable unset (MSYS2 sets it to xterm-256color
), like so:
alias ttyper='TERM= ttyper'
alias lapin='TERM= lapin'
alias btm='TERM= btm'
alias rusty-rain='TERM= rusty-rain'
alias gping='TERM= gping'
alias pipes-rs='TERM= pipes-rs'
FWIW, in MINGW64, if I build+run my crossterm app with "cargo run", it works great, but if I try to directly run the same generated exe, it creates the console spew outlined above.
Running "./target/debug/myexe.exe | cat" works (but slowly)
In MSYS2 (git bash), directly run exe not works, but run with npm run
or cargo run
works.
trick: when on mintty, try "shell command
" instead of command
, shell in msys2, uses dark magic to make it work better, sometimes, at least on windows 8 where there is no conpty
Describe the bug MSYS, CGWIN, Mintty (e.g. gitbash, windows ssh-terminals) have in common that they are tools that do not have access to the internal WinAPI of windows. This is a problem when they try to do operations that are implemented with system calls (not via ANSI codes). This is the case for retrieving operations like input, terminal size, cursor position. Operations that use ANSI codes work perfectly fine.
According to the creator of winapi rust crate, he said:
So apparently crossterm will have not access to the console handles in the mentioned emulators. And perhaps a workaround is to use read/write file instead for read/write console. But this solution is different for each type of retrieving operation. I am not sure how to go about this, if one has any ideas on the best way to go around this, feel free to leave a comment.
Related issues: