hovered_and_selected for shell

This commit is contained in:
rrveex 2024-02-27 12:39:36 +02:00
parent 82071bd06b
commit bcfd0c927a
4 changed files with 12 additions and 3 deletions

View file

@ -52,4 +52,7 @@ impl Manager {
#[inline] #[inline]
pub fn selected_or_hovered(&self) -> Vec<&Url> { self.tabs.active().selected_or_hovered() } pub fn selected_or_hovered(&self) -> Vec<&Url> { self.tabs.active().selected_or_hovered() }
#[inline]
pub fn hovered_and_selected(&self) -> Vec<&Url> { self.tabs.active().hovered_and_selected() }
} }

View file

@ -26,7 +26,7 @@ impl Tab {
} }
let mut opt = opt.into() as Opt; let mut opt = opt.into() as Opt;
let selected: Vec<_> = self.selected_or_hovered().into_iter().cloned().collect(); let selected: Vec<_> = self.hovered_and_selected().into_iter().cloned().collect();
tokio::spawn(async move { tokio::spawn(async move {
if !opt.confirm || opt.exec.is_empty() { if !opt.confirm || opt.exec.is_empty() {

View file

@ -58,6 +58,12 @@ impl Tab {
} }
} }
pub fn hovered_and_selected(&self) -> Vec<&Url> {
let mut a = self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default();
a.extend(self.selected.iter());
a
}
// --- History // --- History
#[inline] #[inline]
pub fn history_new(&mut self, url: &Url) -> Folder { pub fn history_new(&mut self, url: &Url) -> Folder {

View file

@ -40,8 +40,8 @@ pub fn shell(opt: ShellOpt) -> Result<Child> {
.stdout(opt.stdio()) .stdout(opt.stdio())
.stderr(opt.stdio()) .stderr(opt.stdio())
.arg(opt.cmd) .arg(opt.cmd)
.arg("") // $0 is the command name .arg(&opt.args[0]) // $0 is the hovered file
.args(opt.args) .args(&opt.args[1..])
.kill_on_drop(!opt.orphan) .kill_on_drop(!opt.orphan)
.pre_exec(move || { .pre_exec(move || {
if opt.orphan && libc::setpgid(0i32, 0i32) < 0 { if opt.orphan && libc::setpgid(0i32, 0i32) < 0 {