fix: use readonly and readwrite footer labels
This commit is contained in:
+8
-8
@@ -560,8 +560,8 @@ fn draw_bars(
|
|||||||
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 access = match access {
|
let access = match access {
|
||||||
Some(AccessMode::ReadOnly) => " read only ",
|
Some(AccessMode::ReadOnly) => " readonly ",
|
||||||
Some(AccessMode::ReadWrite) => " read write ",
|
Some(AccessMode::ReadWrite) => " readwrite ",
|
||||||
None => "",
|
None => "",
|
||||||
};
|
};
|
||||||
let access_width = (access.len() as u16 + if access.is_empty() { 0 } else { 2 })
|
let access_width = (access.len() as u16 + if access.is_empty() { 0 } else { 2 })
|
||||||
@@ -1608,8 +1608,8 @@ mod tests {
|
|||||||
draw_bars(frame, top, bottom, "SQLite", "data", Some(live.access_mode()), false, None);
|
draw_bars(frame, top, bottom, "SQLite", "data", Some(live.access_mode()), false, None);
|
||||||
})?;
|
})?;
|
||||||
let footer: String = (0..40).map(|x| terminal.backend().buffer()[(x, 5)].symbol()).collect();
|
let footer: String = (0..40).map(|x| terminal.backend().buffer()[(x, 5)].symbol()).collect();
|
||||||
assert!(footer.contains("read write"));
|
assert!(footer.contains("readwrite"));
|
||||||
assert!(!footer.contains("read only"));
|
assert!(!footer.contains("readonly"));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1626,18 +1626,18 @@ mod tests {
|
|||||||
let buffer = terminal.backend().buffer();
|
let buffer = terminal.backend().buffer();
|
||||||
let footer: String = (0..80).map(|x| buffer[(x, 5)].symbol()).collect();
|
let footer: String = (0..80).map(|x| buffer[(x, 5)].symbol()).collect();
|
||||||
let expected = match access {
|
let expected = match access {
|
||||||
Some(AccessMode::ReadOnly) => "SQLite read only ░▓ 1:1 ",
|
Some(AccessMode::ReadOnly) => "SQLite readonly ░▓ 1:1 ",
|
||||||
Some(AccessMode::ReadWrite) => "SQLite read write ░▓ 1:1 ",
|
Some(AccessMode::ReadWrite) => "SQLite readwrite ░▓ 1:1 ",
|
||||||
None => "SQLite ░▓ 1:1 ",
|
None => "SQLite ░▓ 1:1 ",
|
||||||
};
|
};
|
||||||
assert!(footer.ends_with(expected), "{footer}");
|
assert!(footer.ends_with(expected), "{footer}");
|
||||||
if access.is_some() {
|
if access.is_some() {
|
||||||
let x = Line::raw(&footer[..footer.find("read ").unwrap()]).width() as u16;
|
let x = Line::raw(&footer[..footer.find("read").unwrap()]).width() as u16;
|
||||||
assert_eq!(buffer[(x, 5)].bg, Color::Cyan);
|
assert_eq!(buffer[(x, 5)].bg, Color::Cyan);
|
||||||
assert_eq!(buffer[(x, 5)].fg, Color::Black);
|
assert_eq!(buffer[(x, 5)].fg, Color::Black);
|
||||||
assert_eq!(buffer[(x - 1, 5)].bg, Color::Cyan);
|
assert_eq!(buffer[(x - 1, 5)].bg, Color::Cyan);
|
||||||
assert_eq!(buffer[(x - 2, 5)].bg, Color::Reset);
|
assert_eq!(buffer[(x - 2, 5)].bg, Color::Reset);
|
||||||
let end = x + access.map_or("", AccessMode::label).len() as u16;
|
let end = x + access.map_or("", AccessMode::label).len() as u16 - 1;
|
||||||
assert_eq!(buffer[(end, 5)].bg, Color::Cyan);
|
assert_eq!(buffer[(end, 5)].bg, Color::Cyan);
|
||||||
assert_eq!(buffer[(end + 1, 5)].bg, Color::Reset);
|
assert_eq!(buffer[(end + 1, 5)].bg, Color::Reset);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ Navigation:
|
|||||||
Full-width bars show dbdash above and mode/database below.
|
Full-width bars show dbdash above and mode/database below.
|
||||||
Saved PostgreSQL connections show database · user@host:port beside the mode,
|
Saved PostgreSQL connections show database · user@host:port beside the mode,
|
||||||
regardless of custom sidebar names; passwords are never included.
|
regardless of custom sidebar names; passwords are never included.
|
||||||
The footer shows provider, a flat lowercase access badge with one-column outer margins, then position.
|
The footer shows provider, a readonly/readwrite badge with one-column outer margins, then position.
|
||||||
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user