mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: displaying filter shortcut in help menu instead of "{widget}.help"
This commit is contained in:
parent
f024ce03e7
commit
b017ae0f68
2 changed files with 16 additions and 3 deletions
|
|
@ -30,6 +30,18 @@ impl Keymap {
|
||||||
Layer::Which => unreachable!(),
|
Layer::Which => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_shortcut_for_command(&self, cmd_name: &str, layer: Layer) -> Option<String> {
|
||||||
|
let control = self
|
||||||
|
.get(layer)
|
||||||
|
.iter()
|
||||||
|
.find(|&c| c.run.iter().any(|cmd| cmd.name.eq(cmd_name)));
|
||||||
|
|
||||||
|
match control {
|
||||||
|
Some(c) => Some(c.on()),
|
||||||
|
None => None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for Keymap {
|
impl FromStr for Keymap {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use ratatui::{buffer::Buffer, layout::{self, Constraint, Rect}, text::Line, widgets::Widget};
|
use ratatui::{buffer::Buffer, layout::{self, Constraint, Rect}, text::Line, widgets::Widget};
|
||||||
use yazi_config::THEME;
|
use yazi_config::{KEYMAP, THEME};
|
||||||
|
use yazi_shared::Layer;
|
||||||
use super::Bindings;
|
use super::Bindings;
|
||||||
use crate::Ctx;
|
use crate::Ctx;
|
||||||
|
|
||||||
|
|
@ -18,8 +18,9 @@ impl<'a> Widget for Layout<'a> {
|
||||||
yazi_plugin::elements::Clear::default().render(area, buf);
|
yazi_plugin::elements::Clear::default().render(area, buf);
|
||||||
|
|
||||||
let chunks = layout::Layout::vertical([Constraint::Fill(1), Constraint::Length(1)]).split(area);
|
let chunks = layout::Layout::vertical([Constraint::Fill(1), Constraint::Length(1)]).split(area);
|
||||||
|
let filter_key = KEYMAP.get_shortcut_for_command("filter", Layer::Help).unwrap_or_else(|| "[undefined]".into());
|
||||||
Line::styled(
|
Line::styled(
|
||||||
help.keyword().unwrap_or_else(|| format!("{}.help", help.layer)),
|
help.keyword().unwrap_or_else(|| format!("{}.help (press {} to filter)", help.layer, filter_key)),
|
||||||
THEME.help.footer,
|
THEME.help.footer,
|
||||||
)
|
)
|
||||||
.render(chunks[1], buf);
|
.render(chunks[1], buf);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue