feat(tui): improve tab navigation
This commit is contained in:
1 parent
6c92c6132a
commit
09d548272b
7 files changed
+224
-94
No files matched your search
@@ -89,12 +89,15 @@ impl Widget for ConfirmPopup {
|
||||
}
|
||||
|
||||
pub fn confirm_popup_area(frame_area: Rect, name: &str) -> Rect {
|
||||
use super::{centered_rect, word_wrap_size};
|
||||
use super::word_wrap_size;
|
||||
use ratatui::layout::Constraint;
|
||||
const MAX_W: usize = 48;
|
||||
const BODY: &str = "This will permanently remove the instance";
|
||||
let title_w = name.len() + 12;
|
||||
let (body_w, _) = word_wrap_size(BODY, MAX_W);
|
||||
let inner_w = title_w.max(body_w).min(MAX_W);
|
||||
let (_, lines) = word_wrap_size(BODY, inner_w);
|
||||
centered_rect(frame_area, inner_w, lines)
|
||||
let popup_w = ((inner_w + 2) as u16).min(frame_area.width.saturating_sub(4));
|
||||
let popup_h = ((lines + 2) as u16).min(frame_area.height.saturating_sub(4));
|
||||
frame_area.centered(Constraint::Length(popup_w), Constraint::Length(popup_h))
|
||||
}
|
||||
@@ -39,13 +39,6 @@ pub fn word_wrap_size(text: &str, max_inner_width: usize) -> (usize, usize) {
|
||||
(widest_line, lines)
|
||||
}
|
||||
|
||||
pub fn centered_rect(frame: Rect, inner_w: usize, inner_h: usize) -> Rect {
|
||||
let popup_w = ((inner_w + 2) as u16).min(frame.width.saturating_sub(4));
|
||||
let popup_h = ((inner_h + 2) as u16).min(frame.height.saturating_sub(4));
|
||||
use ratatui::layout::Constraint;
|
||||
frame.centered(Constraint::Length(popup_w), Constraint::Length(popup_h))
|
||||
}
|
||||
|
||||
pub fn top_right_rect(frame: Rect, inner_w: usize, inner_h: usize) -> Rect {
|
||||
let popup_w = (inner_w + 2) as u16;
|
||||
let popup_h = (inner_h + 2) as u16;
|
||||
|
||||
Reference in new issue
Block a user