Skip to content

Commit 0e87dc9

Browse files
committed
fix: help desc was truncated
Signed-off-by: chang-ning <spiderpower02@gmail.com>
1 parent c2691e3 commit 0e87dc9

2 files changed

Lines changed: 12 additions & 22 deletions

File tree

src/tui/theme.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub struct ThemeColors {
5454
pub status_bg: Color,
5555
pub status_fg: Color,
5656
pub header_fg: Color,
57-
pub group_title: Color,
5857
}
5958

6059
fn default_colors() -> ThemeColors {
@@ -71,7 +70,6 @@ fn default_colors() -> ThemeColors {
7170
status_bg: Color::Green,
7271
status_fg: Color::Black,
7372
header_fg: Color::Cyan,
74-
group_title: Color::Yellow,
7573
}
7674
}
7775

@@ -89,7 +87,6 @@ fn dracula_colors() -> ThemeColors {
8987
status_bg: Color::Rgb(170, 140, 220),
9088
status_fg: Color::Rgb(30, 30, 40),
9189
header_fg: Color::Rgb(150, 210, 240),
92-
group_title: Color::Rgb(220, 220, 160),
9390
}
9491
}
9592

@@ -107,7 +104,6 @@ fn nord_colors() -> ThemeColors {
107104
status_bg: Color::Rgb(130, 165, 195),
108105
status_fg: Color::Rgb(40, 45, 55),
109106
header_fg: Color::Rgb(140, 190, 210),
110-
group_title: Color::Rgb(220, 200, 150),
111107
}
112108
}
113109

@@ -125,7 +121,6 @@ fn monokai_colors() -> ThemeColors {
125121
status_bg: Color::Rgb(220, 160, 70),
126122
status_fg: Color::Rgb(35, 35, 30),
127123
header_fg: Color::Rgb(130, 200, 220),
128-
group_title: Color::Rgb(210, 200, 130),
129124
}
130125
}
131126

@@ -143,6 +138,5 @@ fn gruvbox_colors() -> ThemeColors {
143138
status_bg: Color::Rgb(200, 115, 50),
144139
status_fg: Color::Rgb(35, 35, 35),
145140
header_fg: Color::Rgb(145, 175, 165),
146-
group_title: Color::Rgb(230, 185, 75),
147141
}
148142
}

src/tui/ui.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ const HELP_KEYS: &[(&str, &str)] = &[
3232
("r", "Record Perfetto trace (start/stop)"),
3333
("h", "Toggle this help"),
3434
("q", "Quit"),
35-
("", ""),
36-
("", "── Detail mode ──"),
37-
("↑ / k", "Scroll up"),
38-
("↓ / j", "Scroll down"),
39-
("", "Scroll past end → next device"),
40-
("", "Scroll past top → prev device"),
4135
];
4236

4337
const RDMA_LINK_GBPS: f64 = 100.0;
@@ -1168,8 +1162,14 @@ fn draw_status_bar(frame: &mut Frame, app: &App, area: Rect, tc: &ThemeColors) {
11681162

11691163
fn draw_help_popup(frame: &mut Frame, tc: &ThemeColors) {
11701164
let area = frame.area();
1171-
let w = 50.min(area.width.saturating_sub(4));
1172-
let h = 18.min(area.height.saturating_sub(4));
1165+
// Size the popup to the longest row (16-char key column + description)
1166+
// plus borders, so nothing gets clipped.
1167+
let mut content_w = 0;
1168+
for (_, desc) in HELP_KEYS {
1169+
content_w = content_w.max(16 + desc.chars().count());
1170+
}
1171+
let w = (content_w as u16 + 2).min(area.width.saturating_sub(4));
1172+
let h = (HELP_KEYS.len() as u16 + 2).min(area.height.saturating_sub(4));
11731173
let popup = centered_rect(area, w, h);
11741174

11751175
frame.render_widget(Clear, popup);
@@ -1259,14 +1259,10 @@ fn draw_column_picker(frame: &mut Frame, app: &App, tc: &ThemeColors) {
12591259
}
12601260

12611261
fn help_line(key: &str, desc: &str, tc: &ThemeColors) -> Line<'static> {
1262-
if key.is_empty() {
1263-
Line::from(styled(&format!(" {}", desc), tc.group_title, false))
1264-
} else {
1265-
Line::from(vec![
1266-
styled(&format!(" {:<14}", key), tc.accent, false),
1267-
styled(desc, tc.fg, false),
1268-
])
1269-
}
1262+
Line::from(vec![
1263+
styled(&format!(" {:<14}", key), tc.accent, false),
1264+
styled(desc, tc.fg, false),
1265+
])
12701266
}
12711267

12721268
fn centered_rect(area: Rect, w: u16, h: u16) -> Rect {

0 commit comments

Comments
 (0)