You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, TPUT is used in cases were /dev/tty fails us. TPUT was introduced in #283 because crossterm was unable to fetch the terminal size in a subshell. However, this was a temporary solution and should be removed in a future version. The idea of TPUT was first discussed in #276 and further communicated in discord.
Why
TPUT works but should be removed because:
Is a subprocess
Is used for terminal resize events, async executors would have to wait too long.
(unresearched claim, but in another thread, it was mentioned ncurses was called by it)
(unresearched claim, but in another thread, it was mentioned that the binary size would decrease after removing this)
Current Implementation
The current implementation tries to use /dev/tty in all possible cases where it is possible. If this is not possible it uses STDOUT_FILENO.
let file = File::open("/dev/tty").map(|file| (FileDesc::new(file.into_raw_fd(),true)));let fd = ifletOk(file) = &file {
file.raw_fd()}else{// Fallback to libc::STDOUT_FILENO if /dev/tty is missingSTDOUT_FILENO};
Then it will try to use the normal ioctl to fetch the terminal size with the handle from above. If this is not possible 'then' it will use TPUT for it.
The new scenario works on macOS and Linux and is able to run in both a subshell and normal terminal. If this succeeds the new approach can be merged and released.
The text was updated successfully, but these errors were encountered:
Senario
Currently, TPUT is used in cases were
/dev/tty
fails us. TPUT was introduced in #283 because crossterm was unable to fetch the terminal size in a subshell. However, this was a temporary solution and should be removed in a future version. The idea of TPUT was first discussed in #276 and further communicated in discord.Why
TPUT works but should be removed because:
Current Implementation
The current implementation tries to use
/dev/tty
in all possible cases where it is possible. If this is not possible it usesSTDOUT_FILENO
.Then it will try to use the normal
ioctl
to fetch the terminal size with the handle from above. If this is not possible 'then' it will use TPUT for it.(https://github.com/crossterm-rs/crossterm/blob/master/src/terminal/sys/unix.rs#L26)
Example Code
Some code that fetches terminal size using different file descriptors. It could be useful in the search for a new approach.
Updated sample code
Improved Scenario
The new scenario works on macOS and Linux and is able to run in both a subshell and normal terminal. If this succeeds the new approach can be merged and released.
The text was updated successfully, but these errors were encountered: