fix: add one-column margins around footer access badge

This commit is contained in:
Valdemar Lorenzen
2026-10-20 16:58:57 +02:00
parent 35bbb27271
commit d3bb1e0e45
2 changed files with 20 additions and 6 deletions
+17 -3
View File
@@ -564,7 +564,7 @@ fn draw_bars(
Some(AccessMode::ReadWrite) => " read write ", Some(AccessMode::ReadWrite) => " read write ",
None => "", None => "",
}; };
let access_width = (access.len() as u16) let access_width = (access.len() as u16 + if access.is_empty() { 0 } else { 2 })
.min(bottom.width.saturating_sub(position_width + mode_width)); .min(bottom.width.saturating_sub(position_width + mode_width));
let provider_width = (Span::raw(provider).width() as u16 + 2) let provider_width = (Span::raw(provider).width() as u16 + 2)
.min(bottom.width.saturating_sub(position_width + mode_width + access_width)); .min(bottom.width.saturating_sub(position_width + mode_width + access_width));
@@ -589,7 +589,16 @@ fn draw_bars(
Paragraph::new(provider).centered().style(base), Paragraph::new(provider).centered().style(base),
provider_area, provider_area,
); );
frame.render_widget(Paragraph::new(access).style(badge), access_area); if !access.is_empty() {
frame.render_widget(
Paragraph::new(Line::from(vec![
Span::raw(" "),
Span::styled(access, badge),
Span::raw(" "),
])).style(base),
access_area,
);
}
frame.render_widget( frame.render_widget(
Paragraph::new(Line::from(vec![ Paragraph::new(Line::from(vec![
Span::styled("░▓", edge), Span::styled("░▓", edge),
@@ -1623,9 +1632,14 @@ mod tests {
}; };
assert!(footer.ends_with(expected), "{footer}"); assert!(footer.ends_with(expected), "{footer}");
if access.is_some() { if access.is_some() {
let x = footer.find("read ").unwrap() as u16; let x = Line::raw(&footer[..footer.find("read ").unwrap()]).width() as u16;
assert_eq!(buffer[(x, 5)].bg, Color::Cyan); assert_eq!(buffer[(x, 5)].bg, Color::Cyan);
assert_eq!(buffer[(x, 5)].fg, Color::Black); assert_eq!(buffer[(x, 5)].fg, Color::Black);
assert_eq!(buffer[(x - 1, 5)].bg, Color::Cyan);
assert_eq!(buffer[(x - 2, 5)].bg, Color::Reset);
let end = x + access.map_or("", AccessMode::label).len() as u16;
assert_eq!(buffer[(end, 5)].bg, Color::Cyan);
assert_eq!(buffer[(end + 1, 5)].bg, Color::Reset);
} }
} }
Ok(()) Ok(())
+1 -1
View File
@@ -85,7 +85,7 @@ Navigation:
Full-width bars show dbdash above and mode/database below. Full-width bars show dbdash above and mode/database below.
Saved PostgreSQL connections show database · user@host:port beside the mode, Saved PostgreSQL connections show database · user@host:port beside the mode,
regardless of custom sidebar names; passwords are never included. regardless of custom sidebar names; passwords are never included.
The footer shows provider, a flat lowercase access badge, then the position badge. The footer shows provider, a flat lowercase access badge with one-column outer margins, then position.
Only badges have colored backgrounds; the remaining bar area uses terminal defaults. Only badges have colored backgrounds; the remaining bar area uses terminal defaults.
Focused inputs show one-based line:column (Unicode characters, not screen cells). Focused inputs show one-based line:column (Unicode characters, not screen cells).
The position badge shows N/A outside focused inputs, including in info/help popups. The position badge shows N/A outside focused inputs, including in info/help popups.