mirror of
https://github.com/danog/ytop.git
synced 2024-11-30 04:29:10 +01:00
parent
74f697f6dc
commit
a3d13cedf8
@ -1,4 +1,5 @@
|
|||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use std::cmp;
|
||||||
use tui::buffer::Buffer;
|
use tui::buffer::Buffer;
|
||||||
use tui::layout::Rect;
|
use tui::layout::Rect;
|
||||||
use tui::widgets::{Paragraph, Text, Widget};
|
use tui::widgets::{Paragraph, Text, Widget};
|
||||||
@ -58,10 +59,10 @@ impl HelpMenu<'_> {
|
|||||||
|
|
||||||
pub fn get_rect(&self, area: Rect) -> Rect {
|
pub fn get_rect(&self, area: Rect) -> Rect {
|
||||||
Rect {
|
Rect {
|
||||||
x: (area.width - TEXT_WIDTH) / 2,
|
x: area.width.checked_sub(TEXT_WIDTH).unwrap_or_default() / 2,
|
||||||
y: (area.height - TEXT_HEIGHT) / 2,
|
y: area.height.checked_sub(TEXT_HEIGHT).unwrap_or_default() / 2,
|
||||||
width: TEXT_WIDTH,
|
width: cmp::min(TEXT_WIDTH, area.width),
|
||||||
height: TEXT_HEIGHT,
|
height: cmp::min(TEXT_HEIGHT, area.height),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user