feat: move provider beside bottom cursor position

This commit is contained in:
Valdemar Lorenzen
2026-10-19 16:19:29 +02:00
parent 2ea3d53c2e
commit fccdfff2cd
3 changed files with 39 additions and 6 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
- [x] adopt vamp-style top and bottom bars with a fixed layout, not vamp's configurable segment/tab system. - [x] adopt vamp-style top and bottom bars with a fixed layout, not vamp's configurable segment/tab system.
- [x] render full-width bars in the outer shell (`src/connection.rs`) before splitting explorer/content; remove the old content-only header (`src/app.rs`, see above). - [x] render full-width bars in the outer shell (`src/connection.rs`) before splitting explorer/content; remove the old content-only header (`src/app.rs`, see above).
- [x] top: `dbdash` badge with vamp-style `▓░` trailing edge; retain provider and READ ONLY information without tab numbering. - [x] top: `dbdash` badge with vamp-style `▓░` trailing edge; retain READ ONLY information without tab numbering.
- [x] bottom-left: current mode badge with `▓░` trailing edge, followed by the connected database name; bottom-right: focused input's one-based `line:column` with `░▓` leading edge. - [x] bottom-left: current mode badge with `▓░` trailing edge, followed by the connected database name; bottom-right: database provider followed by the focused input's one-based `line:column` (or N/A) with `░▓` leading edge.
- [x] capture a safe database display name on successful saved-profile and CLI connections, including SQLite; use the connected database, not explorer selection or `Database::name()` (which returns the provider). Never expose raw connection strings/passwords; show a clear disconnected state and retain the previous identity after a failed switch. - [x] capture a safe database display name on successful saved-profile and CLI connections, including SQLite; use the connected database, not explorer selection or `Database::name()` (which returns the provider). Never expose raw connection strings/passwords; show a clear disconnected state and retain the previous identity after a failed switch.
- [x] add Normal/Insert query editing with mode-aware key routing; define entry/navigation keys and make Esc leave Insert before returning to the explorer. Preserve query execution, multiline editing, paste, and focus cycling. - [x] add Normal/Insert query editing with mode-aware key routing; define entry/navigation keys and make Esc leave Insert before returning to the explorer. Preserve query execution, multiline editing, paste, and focus cycling.
- [x] keep connection/password forms direct-entry for now; make the mode indicator reflect the focused surface rather than a stale query mode. - [x] keep connection/password forms direct-entry for now; make the mode indicator reflect the focused surface rather than a stale query mode.
@@ -20,5 +20,5 @@
- [x] remove the path from the database entry in the sidebar (can be viewed in the info panel) - [x] remove the path from the database entry in the sidebar (can be viewed in the info panel)
- [x] info panel should also pop up when pressing `i` on a child entry of that database entry in the sidebar (instead of only when the parent/database connection is hovered) - [x] info panel should also pop up when pressing `i` on a child entry of that database entry in the sidebar (instead of only when the parent/database connection is hovered)
- [x] `line:col` indicator in the bottom-right status bar should never disappear but instead display "N/A" in that case. - [x] `line:col` indicator in the bottom-right status bar should never disappear but instead display "N/A" in that case.
- [ ] database type indicator should be moved down just left of the "line:col" indicator like in the attached image - [x] database type indicator should be moved down just left of the "line:col" indicator like in the attached image
- [ ] introduce vim navigation inside the query input field. - [ ] introduce vim navigation inside the query input field.
+34 -2
View File
@@ -429,7 +429,7 @@ fn draw_bars(
Paragraph::new(Line::from(vec![ Paragraph::new(Line::from(vec![
Span::styled(" dbdash ", badge), Span::styled(" dbdash ", badge),
Span::styled("▓░", edge), Span::styled("▓░", edge),
Span::raw(format!(" {provider} · READ ONLY")), Span::raw(" READ ONLY"),
])) ]))
.style(base), .style(base),
top, top,
@@ -439,9 +439,12 @@ fn draw_bars(
let position = position.as_deref().unwrap_or(" N/A "); let position = position.as_deref().unwrap_or(" N/A ");
let position_width = (position.len() as u16 + 2).min(bottom.width); let position_width = (position.len() as u16 + 2).min(bottom.width);
let mode_width = bottom.width.saturating_sub(position_width).min(10); 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::Length(mode_width),
Constraint::Min(0), Constraint::Min(0),
Constraint::Length(provider_width),
Constraint::Length(position_width), Constraint::Length(position_width),
]) ])
.areas(bottom); .areas(bottom);
@@ -454,6 +457,10 @@ fn draw_bars(
mode, mode,
); );
frame.render_widget(Paragraph::new(format!(" {name}")).style(base), name_area); 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( frame.render_widget(
Paragraph::new(Line::from(vec![ Paragraph::new(Line::from(vec![
Span::styled("░▓", edge), Span::styled("░▓", edge),
@@ -1169,6 +1176,31 @@ mod tests {
Ok(()) 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] #[test]
fn shell_keeps_position_when_name_is_long_and_yields_on_short_screens() -> Result<()> { 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))?; let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(24, 8))?;
+2 -1
View File
@@ -46,7 +46,8 @@ Navigation:
Enter on the connected database collapses/expands it without reconnecting. Enter on the connected database collapses/expands it without reconnecting.
Keybindings float above the workspace; Up/Down/jk scroll, Home/End/g/G jump. 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. 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. 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.