Added styling to footer
This commit is contained in:
parent
3d1d9819b6
commit
b8dbca09bb
48
src/tui.rs
48
src/tui.rs
|
@ -19,6 +19,10 @@ pub struct Renderer {
|
||||||
table_rows: Vec<Vec<Span<'static>>>,
|
table_rows: Vec<Vec<Span<'static>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn command<'c>(key: &'c str, text: &'c str) -> Vec<Span<'c>> {
|
||||||
|
vec![key.bold().light_cyan(), " ".into(), text.dim()]
|
||||||
|
}
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
// NOTE: This needs to be a separate function as the render functions can not be async
|
// NOTE: This needs to be a separate function as the render functions can not be async
|
||||||
pub async fn update(
|
pub async fn update(
|
||||||
|
@ -39,24 +43,24 @@ impl Renderer {
|
||||||
|
|
||||||
let commands = if self.table_state.selected().is_some() {
|
let commands = if self.table_state.selected().is_some() {
|
||||||
vec![
|
vec![
|
||||||
"(q) quit",
|
command("q", "quit"),
|
||||||
"(↓/j) move down",
|
command("esc", "deselect"),
|
||||||
"(↑/k) move up",
|
command("↓/j", "move down"),
|
||||||
"(esc) deselect",
|
command("↑/k", "move up"),
|
||||||
"",
|
vec![],
|
||||||
"(p) make private",
|
command("p", "make private"),
|
||||||
"(ctrl-p) make protected",
|
command("ctrl-p", "make protected"),
|
||||||
"(shift-p) make public",
|
command("shift-p", "make public"),
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
vec![
|
vec![
|
||||||
"(q) quit",
|
command("q", "quit"),
|
||||||
"(↓/j) select first",
|
command("↓/j", "select first"),
|
||||||
"(↑/k) select last",
|
command("↑/k", "select last"),
|
||||||
"",
|
vec![],
|
||||||
"(p) make all private",
|
command("p", "make all private"),
|
||||||
"(ctrl-p) make all protected",
|
command("ctrl-p", "make all protected"),
|
||||||
"(shift-p) make all public",
|
command("shift-p", "make all public"),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,11 +68,17 @@ impl Renderer {
|
||||||
let mut line = Line::default();
|
let mut line = Line::default();
|
||||||
let sep = " | ";
|
let sep = " | ";
|
||||||
for command in commands {
|
for command in commands {
|
||||||
if !command.is_empty() && line.width() == 0 {
|
let command_width: usize = command.iter().map(|span| span.width()).sum();
|
||||||
line.push_span(command);
|
|
||||||
} else if !command.is_empty() && line.width() + sep.width() + command.width() <= width {
|
if command_width > 0 && line.width() == 0 {
|
||||||
|
for span in command {
|
||||||
|
line.push_span(span);
|
||||||
|
}
|
||||||
|
} else if command_width > 0 && line.width() + sep.width() + command_width <= width {
|
||||||
line.push_span(sep);
|
line.push_span(sep);
|
||||||
line.push_span(command);
|
for span in command {
|
||||||
|
line.push_span(span);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
text.push_line(line);
|
text.push_line(line);
|
||||||
line = Line::from(command);
|
line = Line::from(command);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user