utilities.rs: fill and align shortcut table columns
parent
d3e62e3d74
commit
23c2355662
|
@ -1072,6 +1072,8 @@ impl Component for Tabbed {
|
||||||
let mut max_width =
|
let mut max_width =
|
||||||
"Press ? to close, use COMMAND \"search\" to find shortcuts".len() + 3;
|
"Press ? to close, use COMMAND \"search\" to find shortcuts".len() + 3;
|
||||||
|
|
||||||
|
let mut max_first_column_width = 3;
|
||||||
|
|
||||||
for (desc, shortcuts) in children_maps.iter() {
|
for (desc, shortcuts) in children_maps.iter() {
|
||||||
max_length += shortcuts.len() + 3;
|
max_length += shortcuts.len() + 3;
|
||||||
max_width = std::cmp::max(
|
max_width = std::cmp::max(
|
||||||
|
@ -1085,6 +1087,14 @@ impl Component for Tabbed {
|
||||||
.unwrap_or(0),
|
.unwrap_or(0),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
max_first_column_width = std::cmp::max(
|
||||||
|
max_first_column_width,
|
||||||
|
shortcuts
|
||||||
|
.values()
|
||||||
|
.map(|v| v.to_string().len() + 5)
|
||||||
|
.max()
|
||||||
|
.unwrap_or(0),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.help_content =
|
self.help_content =
|
||||||
CellBuffer::new_with_context(max_width, max_length + 2, None, context);
|
CellBuffer::new_with_context(max_width, max_length + 2, None, context);
|
||||||
|
@ -1112,7 +1122,11 @@ impl Component for Tabbed {
|
||||||
idx += 2;
|
idx += 2;
|
||||||
for (k, v) in shortcuts {
|
for (k, v) in shortcuts {
|
||||||
let (x, y) = write_string_to_grid(
|
let (x, y) = write_string_to_grid(
|
||||||
&format!("{:1$}", v, max_width),
|
&format!(
|
||||||
|
"{: >width$}",
|
||||||
|
format!("{}", v),
|
||||||
|
width = max_first_column_width
|
||||||
|
),
|
||||||
&mut self.help_content,
|
&mut self.help_content,
|
||||||
self.theme_default.fg,
|
self.theme_default.fg,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
|
|
Loading…
Reference in New Issue