feat: support right-click to open files (#1232)

This commit is contained in:
三咲雅 · Misaki Masa 2024-06-29 11:25:45 +08:00 committed by GitHub
parent 9961251248
commit 1a1da216ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -45,7 +45,7 @@ impl CommandPub {
pub(super) fn receiver(&self) -> Result<u64> {
if let Some(receiver) = self.receiver {
Ok(receiver)
} else if let Ok(s) = std::env::var("YAZI_ID") {
} else if let Some(s) = std::env::var("YAZI_PID").ok().filter(|s| !s.is_empty()) {
Ok(s.parse()?)
} else {
bail!("No receiver ID provided, also no YAZI_ID environment variable found.")

View File

@ -42,6 +42,9 @@ pub fn init() {
USERS_CACHE.with(Default::default);
// Env
if let Some(s) = std::env::var("YAZI_ID").ok().filter(|s| !s.is_empty()) {
std::env::set_var("YAZI_PID", s);
}
std::env::set_var("YAZI_ID", ID.to_string());
std::env::set_var(
"YAZI_LEVEL",

View File

@ -44,13 +44,18 @@ function Current:render(area)
end
function Current:click(event, up)
if up or not event.is_left then
if up or event.is_middle then
return
end
local f = Folder:by_kind(Folder.CURRENT)
if event.y <= #f.window and f.hovered then
ya.manager_emit("arrow", { event.y + f.offset - f.hovered.idx })
if event.y > #f.window or not f.hovered then
return
end
ya.manager_emit("arrow", { event.y + f.offset - f.hovered.idx })
if event.is_right then
ya.manager_emit("open", { hovered = true })
end
end