Skip to content
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

Add line field to Termios struct #1805

Merged
merged 1 commit into from Aug 22, 2022
Merged

Conversation

tertsdiepraam
Copy link
Contributor

Fixes #1802

I have to admit I'm not really sure how to test this properly, so if that's necessary I require some help :)

@tertsdiepraam tertsdiepraam force-pushed the termios-line branch 2 times, most recently from 376b677 to e83ab05 Compare August 21, 2022 13:08
@@ -181,6 +181,16 @@ pub struct Termios {
pub local_flags: LocalFlags,
/// Control characters (see `termios.c_cc` documentation)
pub control_chars: [libc::cc_t; NCCS],
/// Line number (see `termios.c_line` documentation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c_line is described on Linux as "line discipline", not "line number". I'm guessing it's the same for other platforms.

There's an enumeration of the disciplines on Linux here. I don't think we need to add them to Nix necessarily, but I do see that they are also missing from https://github.com/rust-lang/libc; you might consider adding them there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah of course. I'll update the PR. Shall I add the possible values to the docstring instead of making an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And do you think the field should be called line_discipline given that the other fields also have more descriptive names than libc?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think line_discipline is a better name.

I don't have a strong preference between using a numeric type vs. an enum. If you want to go the enum route, we'd want to derive our enum values from the libc definition, which we do using the libc_bitflags! macro. This would necessitate adding them to libc before introducing them here. I'll leave that choice up to you.

If you're sticking with a numeric type, I don't see a need to enumerate them fully in Nix's documentation. I think referring users to their platform-specific documentation is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll stick with numbers for now. In existing stty implementations the number is also used directly. Thank you for your feedback!

@tertsdiepraam tertsdiepraam force-pushed the termios-line branch 2 times, most recently from 326ae90 to 2b91f51 Compare August 21, 2022 19:16
CHANGELOG.md Outdated
@@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased] - ReleaseDate
### Added

- Added `line` field to `Termios` on Linux, Android and Haiku
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to line_discipline?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise things LGTM.

Copy link
Collaborator

@rtzoeller rtzoeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Termios c_line field
2 participants