feat: move provider beside bottom cursor position
This commit is contained in:
+34
-2
@@ -429,7 +429,7 @@ fn draw_bars(
|
||||
Paragraph::new(Line::from(vec![
|
||||
Span::styled(" dbdash ", badge),
|
||||
Span::styled("▓░", edge),
|
||||
Span::raw(format!(" {provider} · READ ONLY")),
|
||||
Span::raw(" READ ONLY"),
|
||||
]))
|
||||
.style(base),
|
||||
top,
|
||||
@@ -439,9 +439,12 @@ fn draw_bars(
|
||||
let position = position.as_deref().unwrap_or(" N/A ");
|
||||
let position_width = (position.len() as u16 + 2).min(bottom.width);
|
||||
let mode_width = bottom.width.saturating_sub(position_width).min(10);
|
||||
let [mode, name_area, cursor] = Layout::horizontal([
|
||||
let provider_width = (Span::raw(provider).width() as u16 + 2)
|
||||
.min(bottom.width.saturating_sub(position_width + mode_width));
|
||||
let [mode, name_area, provider_area, cursor] = Layout::horizontal([
|
||||
Constraint::Length(mode_width),
|
||||
Constraint::Min(0),
|
||||
Constraint::Length(provider_width),
|
||||
Constraint::Length(position_width),
|
||||
])
|
||||
.areas(bottom);
|
||||
@@ -454,6 +457,10 @@ fn draw_bars(
|
||||
mode,
|
||||
);
|
||||
frame.render_widget(Paragraph::new(format!(" {name}")).style(base), name_area);
|
||||
frame.render_widget(
|
||||
Paragraph::new(provider).centered().style(base),
|
||||
provider_area,
|
||||
);
|
||||
frame.render_widget(
|
||||
Paragraph::new(Line::from(vec![
|
||||
Span::styled("░▓", edge),
|
||||
@@ -1169,6 +1176,31 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_sits_before_position_and_displaces_the_database_label() -> Result<()> {
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(32, 8))?;
|
||||
terminal.draw(|frame| {
|
||||
let [top, _, bottom] = shell_areas(frame.area());
|
||||
draw_bars(
|
||||
frame,
|
||||
top,
|
||||
bottom,
|
||||
"PostgreSQL",
|
||||
"a very long database name",
|
||||
false,
|
||||
None,
|
||||
);
|
||||
})?;
|
||||
let buffer = terminal.backend().buffer();
|
||||
let top: String = (0..32).map(|x| buffer[(x, 0)].symbol()).collect();
|
||||
let footer: String = (0..32).map(|x| buffer[(x, 7)].symbol()).collect();
|
||||
assert!(!top.contains("PostgreSQL"));
|
||||
assert!(footer.starts_with(" NORMAL ▓░"));
|
||||
assert!(footer.ends_with(" PostgreSQL ░▓ N/A "));
|
||||
assert_eq!(buffer[(24, 7)].bg, Color::Reset);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shell_keeps_position_when_name_is_long_and_yields_on_short_screens() -> Result<()> {
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(24, 8))?;
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ Navigation:
|
||||
Enter on the connected database collapses/expands it without reconnecting.
|
||||
Keybindings float above the workspace; Up/Down/jk scroll, Home/End/g/G jump.
|
||||
Query Insert mode and connection/password fields keep ? as literal text.
|
||||
Full-width bars show dbdash/provider/READ ONLY above and mode/database below.
|
||||
Full-width bars show dbdash/READ ONLY above and mode/database below.
|
||||
The database provider sits immediately left of the bottom-right position badge.
|
||||
Only badges have colored backgrounds; the remaining bar area uses terminal defaults.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user