Implement getting terminal size for windows and linux.#77
Implement getting terminal size for windows and linux.#77richard-uk1 wants to merge 4 commits intoStebalien:masterfrom
Conversation
Also use impl Trait
I can't get it to work for TerminfoTerm (mintty) in windows - it reports incorrect information.
Stebalien
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Mind just calling this Dimensions (or Size)?
| fn carriage_return(&mut self) -> Result<()>; | ||
|
|
||
| /// Gets the size of the terminal window, if available | ||
| fn dims(&self) -> Result<Dims>; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
| ti: TermInfo, | ||
| } | ||
|
|
||
| #[cfg(unix)] |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
Not entirely accurate... (to me, this implies that this is all available functionality).
|
Note to self: make sure to look at issue 63 |
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.