Skip to content

Add line field to Termios struct#1805

Merged
bors[bot] merged 1 commit intonix-rust:masterfrom
tertsdiepraam:termios-line
Aug 22, 2022
Merged

Add line field to Termios struct#1805
bors[bot] merged 1 commit intonix-rust:masterfrom
tertsdiepraam:termios-line

Conversation

@tertsdiepraam
Copy link
Copy Markdown
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
Comment thread src/sys/termios.rs Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread CHANGELOG.md Outdated
## [Unreleased] - ReleaseDate
### Added

- Added `line` field to `Termios` on Linux, Android and Haiku
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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