mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-30 16:10:23 +00:00
ui: simplify size() to only return width, rename it to term_width()
I'm going to add $COLUMNS override, and it should work even if ioctl() on tty failed. This means that the return type has to be (Option<u16>, Option<u16>). Since we don't use the row count, I decided to drop it.
This commit is contained in:
parent
b6cac0c6aa
commit
afdf9e19f2
2 changed files with 4 additions and 4 deletions
|
@ -63,8 +63,8 @@ impl Progress {
|
|||
}
|
||||
|
||||
let bar_width = ui
|
||||
.size()
|
||||
.map(|(cols, _rows)| usize::from(cols))
|
||||
.term_width()
|
||||
.map(usize::from)
|
||||
.unwrap_or(0)
|
||||
.saturating_sub(self.buffer.len() - control_chars + 2);
|
||||
self.buffer.push('[');
|
||||
|
|
|
@ -288,8 +288,8 @@ impl Ui {
|
|||
rpassword::prompt_password(format!("{prompt}: "))
|
||||
}
|
||||
|
||||
pub fn size(&self) -> Option<(u16, u16)> {
|
||||
crossterm::terminal::size().ok()
|
||||
pub fn term_width(&self) -> Option<u16> {
|
||||
crossterm::terminal::size().ok().map(|(cols, _)| cols)
|
||||
}
|
||||
|
||||
/// Construct a guard object which writes `data` when dropped. Useful for
|
||||
|
|
Loading…
Reference in a new issue