- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Initial implementation of stty
#3672
Conversation
wahou, amazing :) |
@tertsdiepraam can we use crossterm for this (or are we using it ?) Maybe we will have to use shell scripts for that TTY issue. https://docs.rs/crossterm/latest/crossterm/index.html Wahou indeed (pardon my french interjections ;) |
I'm not currently using |
@tertsdiepraam I thought so as well, but maybe it could be an inspiration for which calls we should use. |
I've ignored the tests that need to be run from a |
Apparently it needs some work on mac. It will take me a while to fix it though. If someone else wants to fix it up for mac, feel free to do so in the meantime. |
@tertsdiepraam I belive mac os has no support for the cline field in termios. Hence, should we ignore it ? I believe the same problem is the cause for the other errors |
Yeah I think that makes sense. The other issue with mac is that the baudrate is represented with a u32 instead of the baudrate enum. |
fn print_terminal_size(termios: &Termios, opts: &Options) -> nix::Result<()> { | ||
let speed = cfgetospeed(termios); | ||
for (text, baud_rate) in BAUD_RATES { | ||
if *baud_rate == speed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if *baud_rate as u32 == speed as u32
seems to work on my system and should fix this issue, unless there are speeds above 32 bits unsigned integers ??
6ef0967
to
678fa8b
Compare
39d1770
to
a8d8228
Compare
546e24c
to
a1250ec
Compare
Okay, so I think it's correct now. I can't test with mac, but I get the correct speed on FreeBSD. There are of course some minor issues and missing functionality with this implementation, but I think we can merge this and I can start opening issues for those. |
sounds good, let's wait for the CI :) |
I'm not sure what's going on with the |
Bravo ! |
Yes, I'll start working on it! |
I got annoyed that there was no
stty
yet, so I started working on it :)In this initial version:
Only binary flags are implemented (i.e. attributes that are enabled and disabled). This means that attributes likeThis is now supported.tabN
whereN
is a number between0
and3
is missing.--all
is implemented.-F/--file
and-g/--save
are ignored.nix
crate is used (notlibc
). Sadly, here are already some attributes that seem to be missing innix
.The tests are broken on my machine with the error:
So the stdout in
cargo test
does not seem to be a tty with terminal attributes. This might mean that we can't teststty
at all? I'd like to try to find a workaround though.