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

Implement getting terminal size for windows and linux. #77

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

derekdreery
Copy link
Contributor

I can't get it to work for TerminfoTerm on windows (using the windows code reports the wrong values) so it is marked not supported.

Richard Dodd and others added 4 commits October 13, 2017 21:26
Also use impl Trait
I can't get it to work for TerminfoTerm (mintty)
in windows - it reports incorrect information.
Copy link
Owner

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Thanks! I have a few minor changes I'd like to see but this looks good otherwise.

/// A struct representing the number of columns and rows of the terminal, and, if available, the
/// width and height of the terminal in pixels
#[derive(Debug, PartialEq, Hash, Eq, Copy, Clone, Default)]
pub struct Dims {
Copy link
Owner

Choose a reason for hiding this comment

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

Mind just calling this Dimensions (or Size)?

@@ -390,6 +407,9 @@ pub trait Terminal: Write {
/// Returns `Ok(true)` if the deletion code was printed, or `Err(e)` if there was an error.
fn carriage_return(&mut self) -> Result<()>;

/// Gets the size of the terminal window, if available
fn dims(&self) -> Result<Dims>;
Copy link
Owner

Choose a reason for hiding this comment

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

Again, I'd call this either dimensions or size. dim means something else so dims is a bit confusing.

}
}

impl From<libc::winsize> for Dims {
Copy link
Owner

Choose a reason for hiding this comment

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

Any reason to implement this? I can't see users actually needing to call this outside of term. I'd just do this conversion directly (i.e., implement a function or inline the conversion) instead of implementing From.

@@ -283,6 +289,87 @@ pub struct TerminfoTerminal<T> {
ti: TermInfo,
}

#[cfg(unix)]
Copy link
Owner

Choose a reason for hiding this comment

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

You don't actually have to duplicate this entire implementation; you can just cfg out the specific function.

@@ -0,0 +1,13 @@
// An example of the avaiable functionality in term
Copy link
Owner

Choose a reason for hiding this comment

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

Not entirely accurate... (to me, this implies that this is all available functionality).

@derekdreery
Copy link
Contributor Author

Note to self: make sure to look at issue 63

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.

None yet

2 participants