feat: position results context on top-right border

This commit is contained in:
Valdemar Lorenzen
2026-10-19 15:41:02 +02:00
parent 59796d9ab0
commit c75c6654f1
3 changed files with 23 additions and 10 deletions
+15 -6
View File
@@ -360,8 +360,7 @@ impl App {
let relation = &self.relations[index];
if self.show_schema {
format!(
" {} [{}] · {} columns · fields {}–{}/5",
relation.label,
" [{}] · {} columns · fields {}–{}/5",
relation.kind,
self.columns.len(),
self.column_offset + 1,
@@ -375,8 +374,7 @@ impl App {
};
let end = self.page_index * PAGE_SIZE + self.page.rows.len();
format!(
" {} [{}] · rows {start}–{end} · page {}{} · columns {}–{}/{}",
relation.label,
" [{}] · rows {start}–{end} · page {}{} · columns {}–{}/{}",
relation.kind,
self.page_index + 1,
if self.page.has_next { " (more)" } else { "" },
@@ -388,8 +386,15 @@ impl App {
} else {
" No readable relations. r to refresh.".into()
};
let content_block =
let mut content_block =
panel(title, focus == Focus::Rows).title_bottom(Line::from(description).left_aligned());
if self.query_result.is_none()
&& let Some(index) = self.active
{
content_block = content_block.title_top(
Line::from(format!(" {} ", self.relations[index].label)).right_aligned(),
);
}
let page = self
.query_result
.as_ref()
@@ -720,8 +725,12 @@ mod tests {
terminal.draw(|frame| app.draw(frame, frame.area(), super::Focus::Rows))?;
let buffer = terminal.backend().buffer();
let border: String = (0..100).map(|x| buffer[(x, 19)].symbol()).collect();
assert!(border.starts_with("└ main.comments [table]"), "{border}");
assert!(border.ends_with('┘'), "{border}");
assert!(!border.contains("main.comments"));
assert!((0..19).any(|y| {
let line: String = (0..100).map(|x| buffer[(x, y)].symbol()).collect();
line.ends_with(" main.comments ┐")
}));
assert!(border.contains(if schema {
"fields 1–4/5"
} else {
+2 -2
View File
@@ -46,8 +46,8 @@ Navigation:
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 query editor sits above rows/results; the explorer spans both panes.
Explorer and rows/schema bottom borders align; relation/page/column status
appears in the rows/schema border. Read errors appear above the query editor.
Explorer and rows/schema bottom borders align; table names appear in the
top-right border, with page/column status below. Read errors appear above the query editor.
Query editor starts in NORMAL: i/a/I/A enters INSERT; hjkl/arrows move.
In INSERT, type SQL; Enter inserts a newline. Arrow keys, Home/End,
Backspace/Delete, Ctrl-U (clear), and multiline pasting are supported.