feat: position results context on top-right border
This commit is contained in:
+15
-6
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user