-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a TTYDimensions type, and display buffered input in bottom …
…right corner.
- Loading branch information
1 parent
eb7e116
commit 2d11dee
Showing
5 changed files
with
139 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
pub const DEFAULT_WIDTH: u16 = 80; | ||
pub const DEFAULT_HEIGHT: u16 = 24; | ||
pub const STATUS_BAR_HEIGHT: u16 = 2; | ||
|
||
#[derive(Copy, Clone, Debug)] | ||
pub struct TTYDimensions { | ||
pub width: u16, | ||
pub height: u16, | ||
} | ||
|
||
impl TTYDimensions { | ||
pub fn from_size(size: (u16, u16)) -> TTYDimensions { | ||
TTYDimensions { | ||
width: size.0, | ||
height: size.1, | ||
} | ||
} | ||
|
||
pub fn without_status_bar(&self) -> TTYDimensions { | ||
TTYDimensions { | ||
width: self.width, | ||
height: if self.height < STATUS_BAR_HEIGHT { | ||
0 | ||
} else { | ||
self.height - STATUS_BAR_HEIGHT | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl Default for TTYDimensions { | ||
fn default() -> TTYDimensions { | ||
TTYDimensions { | ||
width: DEFAULT_WIDTH, | ||
height: DEFAULT_HEIGHT, | ||
} | ||
} | ||
} |
Oops, something went wrong.