From fccdfff2cd01c270d8d25a0200d9d0a5aa96f52d Mon Sep 17 00:00:00 2001 From: Valdemar Lorenzen Date: Mon, 19 Oct 2026 16:19:29 +0200 Subject: [PATCH] feat: move provider beside bottom cursor position --- TODO.md | 6 +++--- src/connection.rs | 36 ++++++++++++++++++++++++++++++++++-- src/main.rs | 3 ++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 8ba0192..5c16f5e 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,7 @@ - [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] top: `dbdash` badge with vamp-style `▓░` trailing edge; retain provider and 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] 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: 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] 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. @@ -20,5 +20,5 @@ - [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] `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. \ No newline at end of file diff --git a/src/connection.rs b/src/connection.rs index 23ad65f..8b62702 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -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))?; diff --git a/src/main.rs b/src/main.rs index 345ddfa..a2cf7c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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.