mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
refactor: use Cmd instead of Exec (#604)
This commit is contained in:
parent
9d9d954870
commit
9d912b07aa
101 changed files with 488 additions and 461 deletions
|
|
@ -1 +1 @@
|
||||||
{"language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos"],"flagWords":[],"version":"0.2"}
|
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds"],"language":"en","version":"0.2"}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{borrow::Cow, collections::VecDeque};
|
use std::{borrow::Cow, collections::VecDeque, ops::Deref};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use super::Key;
|
use super::Key;
|
||||||
|
|
||||||
|
|
@ -9,12 +9,13 @@ use super::Key;
|
||||||
pub struct Control {
|
pub struct Control {
|
||||||
pub on: Vec<Key>,
|
pub on: Vec<Key>,
|
||||||
#[serde(deserialize_with = "super::exec_deserialize")]
|
#[serde(deserialize_with = "super::exec_deserialize")]
|
||||||
pub exec: Vec<Exec>,
|
pub exec: Vec<Cmd>,
|
||||||
pub desc: Option<String>,
|
pub desc: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Control {
|
impl Control {
|
||||||
pub fn to_seq(&self) -> VecDeque<Exec> {
|
#[inline]
|
||||||
|
pub fn to_seq(&self) -> VecDeque<Cmd> {
|
||||||
self.exec.iter().map(|e| e.clone_without_data()).collect()
|
self.exec.iter().map(|e| e.clone_without_data()).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -41,3 +42,27 @@ impl Control {
|
||||||
|| self.on().to_lowercase().contains(&s)
|
|| self.on().to_lowercase().contains(&s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum ControlCow {
|
||||||
|
Owned(Control),
|
||||||
|
Borrowed(&'static Control),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&'static Control> for ControlCow {
|
||||||
|
fn from(c: &'static Control) -> Self { Self::Borrowed(c) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Control> for ControlCow {
|
||||||
|
fn from(c: Control) -> Self { Self::Owned(c) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deref for ControlCow {
|
||||||
|
type Target = Control;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
match self {
|
||||||
|
Self::Owned(c) => c,
|
||||||
|
Self::Borrowed(c) => c,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,36 +2,36 @@ use std::fmt;
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use serde::{de::{self, Visitor}, Deserializer};
|
use serde::{de::{self, Visitor}, Deserializer};
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
pub(super) fn exec_deserialize<'de, D>(deserializer: D) -> Result<Vec<Exec>, D::Error>
|
pub(super) fn exec_deserialize<'de, D>(deserializer: D) -> Result<Vec<Cmd>, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
struct ExecVisitor;
|
struct ExecVisitor;
|
||||||
|
|
||||||
fn parse(s: &str) -> Result<Exec> {
|
fn parse(s: &str) -> Result<Cmd> {
|
||||||
let s = shell_words::split(s)?;
|
let s = shell_words::split(s)?;
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
bail!("`exec` cannot be empty");
|
bail!("`exec` cannot be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut exec = Exec { cmd: s[0].clone(), ..Default::default() };
|
let mut cmd = Cmd { name: s[0].clone(), ..Default::default() };
|
||||||
for arg in s.into_iter().skip(1) {
|
for arg in s.into_iter().skip(1) {
|
||||||
if arg.starts_with("--") {
|
if arg.starts_with("--") {
|
||||||
let mut arg = arg.splitn(2, '=');
|
let mut arg = arg.splitn(2, '=');
|
||||||
let key = arg.next().unwrap().trim_start_matches('-');
|
let key = arg.next().unwrap().trim_start_matches('-');
|
||||||
let val = arg.next().unwrap_or("").to_string();
|
let val = arg.next().unwrap_or("").to_string();
|
||||||
exec.named.insert(key.to_string(), val);
|
cmd.named.insert(key.to_string(), val);
|
||||||
} else {
|
} else {
|
||||||
exec.args.push(arg);
|
cmd.args.push(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(exec)
|
Ok(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Visitor<'de> for ExecVisitor {
|
impl<'de> Visitor<'de> for ExecVisitor {
|
||||||
type Value = Vec<Exec>;
|
type Value = Vec<Cmd>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
formatter.write_str("a `exec` string or array of strings within [keymap]")
|
formatter.write_str("a `exec` string or array of strings within [keymap]")
|
||||||
|
|
@ -41,14 +41,14 @@ where
|
||||||
where
|
where
|
||||||
A: de::SeqAccess<'de>,
|
A: de::SeqAccess<'de>,
|
||||||
{
|
{
|
||||||
let mut execs = vec![];
|
let mut cmds = vec![];
|
||||||
while let Some(value) = &seq.next_element::<String>()? {
|
while let Some(value) = &seq.next_element::<String>()? {
|
||||||
execs.push(parse(value).map_err(de::Error::custom)?);
|
cmds.push(parse(value).map_err(de::Error::custom)?);
|
||||||
}
|
}
|
||||||
if execs.is_empty() {
|
if cmds.is_empty() {
|
||||||
return Err(de::Error::custom("`exec` within [keymap] cannot be empty"));
|
return Err(de::Error::custom("`exec` within [keymap] cannot be empty"));
|
||||||
}
|
}
|
||||||
Ok(execs)
|
Ok(cmds)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@ use std::fmt;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::{de::{self, Visitor}, Deserializer};
|
use serde::{de::{self, Visitor}, Deserializer};
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
pub(super) fn exec_deserialize<'de, D>(deserializer: D) -> Result<Exec, D::Error>
|
pub(super) fn exec_deserialize<'de, D>(deserializer: D) -> Result<Cmd, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
struct ExecVisitor;
|
struct ExecVisitor;
|
||||||
|
|
||||||
impl<'de> Visitor<'de> for ExecVisitor {
|
impl<'de> Visitor<'de> for ExecVisitor {
|
||||||
type Value = Exec;
|
type Value = Cmd;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
formatter.write_str("a `exec` string or array of strings")
|
formatter.write_str("a `exec` string or array of strings")
|
||||||
|
|
@ -31,7 +31,7 @@ where
|
||||||
if value.is_empty() {
|
if value.is_empty() {
|
||||||
return Err(de::Error::custom("`exec` within [plugin] cannot be empty"));
|
return Err(de::Error::custom("`exec` within [plugin] cannot be empty"));
|
||||||
}
|
}
|
||||||
Ok(Exec { cmd: value.to_owned(), ..Default::default() })
|
Ok(Cmd { name: value.to_owned(), ..Default::default() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use yazi_shared::{event::Exec, Condition, MIME_DIR};
|
use yazi_shared::{event::Cmd, Condition, MIME_DIR};
|
||||||
|
|
||||||
use crate::{pattern::Pattern, plugin::MAX_PRELOADERS, Preset, Priority, MERGED_YAZI};
|
use crate::{pattern::Pattern, plugin::MAX_PRELOADERS, Preset, Priority, MERGED_YAZI};
|
||||||
|
|
||||||
|
|
@ -18,8 +18,9 @@ pub struct PluginRule {
|
||||||
pub cond: Option<Condition>,
|
pub cond: Option<Condition>,
|
||||||
pub name: Option<Pattern>,
|
pub name: Option<Pattern>,
|
||||||
pub mime: Option<Pattern>,
|
pub mime: Option<Pattern>,
|
||||||
|
#[serde(rename = "exec")]
|
||||||
#[serde(deserialize_with = "super::exec_deserialize")]
|
#[serde(deserialize_with = "super::exec_deserialize")]
|
||||||
pub exec: Exec,
|
pub cmd: Cmd,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub sync: bool,
|
pub sync: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ use crate::Priority;
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PluginProps {
|
pub struct PluginProps {
|
||||||
pub id: u8,
|
pub id: u8,
|
||||||
pub cmd: String,
|
pub name: String,
|
||||||
pub multi: bool,
|
pub multi: bool,
|
||||||
pub prio: Priority,
|
pub prio: Priority,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&PluginRule> for PluginProps {
|
impl From<&PluginRule> for PluginProps {
|
||||||
fn from(rule: &PluginRule) -> Self {
|
fn from(rule: &PluginRule) -> Self {
|
||||||
Self { id: rule.id, cmd: rule.exec.cmd.to_owned(), multi: rule.multi, prio: rule.prio }
|
Self { id: rule.id, name: rule.cmd.name.to_owned(), multi: rule.multi, prio: rule.prio }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::completion::Completion;
|
use crate::completion::Completion;
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
step: isize,
|
step: isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{emit, event::Exec, render, Layer};
|
use yazi_shared::{emit, event::Cmd, render, Layer};
|
||||||
|
|
||||||
use crate::{completion::Completion, input::Input};
|
use crate::{completion::Completion, input::Input};
|
||||||
|
|
||||||
|
|
@ -6,14 +6,14 @@ pub struct Opt {
|
||||||
submit: bool,
|
submit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
fn from(c: Cmd) -> Self { Self { submit: c.named.contains_key("submit") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Completion {
|
impl Completion {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _close() {
|
pub fn _close() {
|
||||||
emit!(Call(Exec::call("close", vec![]), Layer::Completion));
|
emit!(Call(Cmd::new("close"), Layer::Completion));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close(&mut self, opt: impl Into<Opt>) {
|
pub fn close(&mut self, opt: impl Into<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{mem, ops::ControlFlow};
|
use std::{mem, ops::ControlFlow};
|
||||||
|
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::completion::Completion;
|
use crate::completion::Completion;
|
||||||
|
|
||||||
|
|
@ -13,13 +13,13 @@ pub struct Opt {
|
||||||
ticket: usize,
|
ticket: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cache: mem::take(&mut e.args),
|
cache: mem::take(&mut c.args),
|
||||||
cache_name: e.take_name("cache-name").unwrap_or_default(),
|
cache_name: c.take_name("cache-name").unwrap_or_default(),
|
||||||
word: e.take_name("word").unwrap_or_default(),
|
word: c.take_name("word").unwrap_or_default(),
|
||||||
ticket: e.take_name("ticket").and_then(|v| v.parse().ok()).unwrap_or(0),
|
ticket: c.take_name("ticket").and_then(|v| v.parse().ok()).unwrap_or(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{mem, path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR}};
|
use std::{mem, path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR}};
|
||||||
|
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use yazi_shared::{emit, event::Exec, render, Layer};
|
use yazi_shared::{emit, event::Cmd, render, Layer};
|
||||||
|
|
||||||
use crate::completion::Completion;
|
use crate::completion::Completion;
|
||||||
|
|
||||||
|
|
@ -10,11 +10,11 @@ pub struct Opt {
|
||||||
ticket: usize,
|
ticket: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
word: e.take_first().unwrap_or_default(),
|
word: c.take_first().unwrap_or_default(),
|
||||||
ticket: e.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
ticket: c.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ impl Completion {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _trigger(word: &str, ticket: usize) {
|
pub fn _trigger(word: &str, ticket: usize) {
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("trigger", vec![word.to_owned()]).with("ticket", ticket),
|
Cmd::args("trigger", vec![word.to_owned()]).with("ticket", ticket),
|
||||||
Layer::Completion
|
Layer::Completion
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -39,10 +39,7 @@ impl Completion {
|
||||||
|
|
||||||
if self.caches.contains_key(&parent) {
|
if self.caches.contains_key(&parent) {
|
||||||
return self.show(
|
return self.show(
|
||||||
Exec::call("show", vec![])
|
Cmd::new("show").with("cache-name", parent).with("word", child).with("ticket", opt.ticket),
|
||||||
.with("cache-name", parent)
|
|
||||||
.with("word", child)
|
|
||||||
.with("ticket", opt.ticket),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +61,7 @@ impl Completion {
|
||||||
|
|
||||||
if !cache.is_empty() {
|
if !cache.is_empty() {
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("show", cache)
|
Cmd::args("show", cache)
|
||||||
.with("cache-name", parent)
|
.with("cache-name", parent)
|
||||||
.with("word", child)
|
.with("word", child)
|
||||||
.with("ticket", ticket),
|
.with("ticket", ticket),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::{ffi::OsStr, ops::Range};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use regex::bytes::{Regex, RegexBuilder};
|
use regex::bytes::{Regex, RegexBuilder};
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
pub struct Filter {
|
pub struct Filter {
|
||||||
raw: String,
|
raw: String,
|
||||||
|
|
@ -43,9 +43,9 @@ pub enum FilterCase {
|
||||||
Insensitive,
|
Insensitive,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Exec> for FilterCase {
|
impl From<&Cmd> for FilterCase {
|
||||||
fn from(e: &Exec) -> Self {
|
fn from(c: &Cmd) -> Self {
|
||||||
match (e.named.contains_key("smart"), e.named.contains_key("insensitive")) {
|
match (c.named.contains_key("smart"), c.named.contains_key("insensitive")) {
|
||||||
(true, _) => Self::Smart,
|
(true, _) => Self::Smart,
|
||||||
(_, false) => Self::Sensitive,
|
(_, false) => Self::Sensitive,
|
||||||
(_, true) => Self::Insensitive,
|
(_, true) => Self::Insensitive,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::help::Help;
|
use crate::help::Help;
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
step: isize,
|
step: isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<isize> for Opt {
|
impl From<isize> for Opt {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::help::Help;
|
use crate::help::Help;
|
||||||
|
|
||||||
impl Help {
|
impl Help {
|
||||||
pub fn escape(&mut self, _: Exec) {
|
pub fn escape(&mut self, _: Cmd) {
|
||||||
if self.in_filter.is_none() {
|
if self.in_filter.is_none() {
|
||||||
return self.toggle(self.layer);
|
return self.toggle(self.layer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use yazi_config::popup::{Offset, Origin, Position};
|
use yazi_config::popup::{Offset, Origin, Position};
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::{help::Help, input::Input};
|
use crate::{help::Help, input::Input};
|
||||||
|
|
||||||
impl Help {
|
impl Help {
|
||||||
pub fn filter(&mut self, _: Exec) {
|
pub fn filter(&mut self, _: Cmd) {
|
||||||
let mut input = Input::default();
|
let mut input = Input::default();
|
||||||
input.position = Position::new(Origin::BottomLeft, Offset::line());
|
input.position = Position::new(Origin::BottomLeft, Offset::line());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
||||||
under: bool,
|
under: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { under: e.named.contains_key("under") } }
|
fn from(c: Cmd) -> Self { Self { under: c.named.contains_key("under") } }
|
||||||
}
|
}
|
||||||
impl From<bool> for Opt {
|
impl From<bool> for Opt {
|
||||||
fn from(under: bool) -> Self { Self { under } }
|
fn from(under: bool) -> Self { Self { under } }
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, CharKind};
|
use yazi_shared::{event::Cmd, CharKind};
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn backward(&mut self, _: Exec) {
|
pub fn backward(&mut self, _: Cmd) {
|
||||||
let snap = self.snap();
|
let snap = self.snap();
|
||||||
if snap.cursor == 0 {
|
if snap.cursor == 0 {
|
||||||
return self.move_(0);
|
return self.move_(0);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render, InputError};
|
use yazi_shared::{event::Cmd, render, InputError};
|
||||||
|
|
||||||
use crate::{completion::Completion, input::Input};
|
use crate::{completion::Completion, input::Input};
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
||||||
submit: bool,
|
submit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
fn from(c: Cmd) -> Self { Self { submit: c.named.contains_key("submit") } }
|
||||||
}
|
}
|
||||||
impl From<bool> for Opt {
|
impl From<bool> for Opt {
|
||||||
fn from(submit: bool) -> Self { Self { submit } }
|
fn from(submit: bool) -> Self { Self { submit } }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::path::MAIN_SEPARATOR;
|
use std::path::MAIN_SEPARATOR;
|
||||||
|
|
||||||
use yazi_shared::{emit, event::Exec, render, Layer};
|
use yazi_shared::{emit, event::Cmd, render, Layer};
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
|
|
@ -9,11 +9,11 @@ pub struct Opt {
|
||||||
ticket: usize,
|
ticket: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
word: e.take_first().unwrap_or_default(),
|
word: c.take_first().unwrap_or_default(),
|
||||||
ticket: e.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
ticket: c.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ impl From<Exec> for Opt {
|
||||||
impl Input {
|
impl Input {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _complete(word: &str, ticket: usize) {
|
pub fn _complete(word: &str, ticket: usize) {
|
||||||
emit!(Call(Exec::call("complete", vec![word.to_owned()]).with("ticket", ticket), Layer::Input));
|
emit!(Call(Cmd::args("complete", vec![word.to_owned()]).with("ticket", ticket), Layer::Input));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn complete(&mut self, opt: impl Into<Opt>) {
|
pub fn complete(&mut self, opt: impl Into<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::{op::InputOp, Input};
|
use crate::input::{op::InputOp, Input};
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@ pub struct Opt {
|
||||||
insert: bool,
|
insert: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
Self { cut: e.named.contains_key("cut"), insert: e.named.contains_key("insert") }
|
Self { cut: c.named.contains_key("cut"), insert: c.named.contains_key("insert") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::{completion::Completion, input::{op::InputOp, Input, InputMode}};
|
use crate::{completion::Completion, input::{op::InputOp, Input, InputMode}};
|
||||||
|
|
||||||
pub struct Opt;
|
pub struct Opt;
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self }
|
fn from(_: ()) -> Self { Self }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, CharKind};
|
use yazi_shared::{event::Cmd, CharKind};
|
||||||
|
|
||||||
use crate::input::{op::InputOp, Input};
|
use crate::input::{op::InputOp, Input};
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
||||||
end_of_word: bool,
|
end_of_word: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { end_of_word: e.named.contains_key("end-of-word") } }
|
fn from(c: Cmd) -> Self { Self { end_of_word: c.named.contains_key("end-of-word") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::{op::InputOp, Input, InputMode};
|
use crate::input::{op::InputOp, Input, InputMode};
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
||||||
append: bool,
|
append: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { append: e.named.contains_key("append") } }
|
fn from(c: Cmd) -> Self { Self { append: c.named.contains_key("append") } }
|
||||||
}
|
}
|
||||||
impl From<bool> for Opt {
|
impl From<bool> for Opt {
|
||||||
fn from(append: bool) -> Self { Self { append } }
|
fn from(append: bool) -> Self { Self { append } }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::ops::RangeBounds;
|
use std::ops::RangeBounds;
|
||||||
|
|
||||||
use yazi_shared::{event::Exec, render, CharKind};
|
use yazi_shared::{event::Cmd, render, CharKind};
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
||||||
kind: String,
|
kind: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self { Self { kind: e.take_first().unwrap_or_default() } }
|
fn from(mut c: Cmd) -> Self { Self { kind: c.take_first().unwrap_or_default() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::{op::InputOp, snap::InputSnap, Input};
|
use crate::input::{op::InputOp, snap::InputSnap, Input};
|
||||||
|
|
||||||
|
|
@ -8,11 +8,11 @@ pub struct Opt {
|
||||||
in_operating: bool,
|
in_operating: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
in_operating: e.named.contains_key("in-operating"),
|
in_operating: c.named.contains_key("in-operating"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::{input::{op::InputOp, Input}, CLIPBOARD};
|
use crate::{input::{op::InputOp, Input}, CLIPBOARD};
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
||||||
before: bool,
|
before: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { before: e.named.contains_key("before") } }
|
fn from(c: Cmd) -> Self { Self { before: c.named.contains_key("before") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn redo(&mut self, _: Exec) {
|
pub fn redo(&mut self, _: Cmd) {
|
||||||
render!(self.snaps.redo());
|
render!(self.snaps.redo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{emit, event::Exec, render, InputError, Layer};
|
use yazi_shared::{emit, event::Cmd, render, InputError, Layer};
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
|
|
@ -9,16 +9,16 @@ pub struct Opt {
|
||||||
tx: mpsc::UnboundedSender<Result<String, InputError>>,
|
tx: mpsc::UnboundedSender<Result<String, InputError>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> { e.take_data().ok_or(()) }
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> { c.take_data().ok_or(()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn _show(cfg: InputCfg) -> mpsc::UnboundedReceiver<Result<String, InputError>> {
|
pub fn _show(cfg: InputCfg) -> mpsc::UnboundedReceiver<Result<String, InputError>> {
|
||||||
let (tx, rx) = mpsc::unbounded_channel();
|
let (tx, rx) = mpsc::unbounded_channel();
|
||||||
emit!(Call(Exec::call("show", vec![]).with_data(Opt { cfg, tx }), Layer::Input));
|
emit!(Call(Cmd::new("show").with_data(Opt { cfg, tx }), Layer::Input));
|
||||||
rx
|
rx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use yazi_config::keymap::Key;
|
use yazi_config::keymap::Key;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::input::{Input, InputMode};
|
use crate::input::{Input, InputMode};
|
||||||
|
|
||||||
pub struct Opt;
|
pub struct Opt;
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::{Input, InputMode};
|
use crate::input::{Input, InputMode};
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn undo(&mut self, _: Exec) {
|
pub fn undo(&mut self, _: Cmd) {
|
||||||
if !self.snaps.undo() {
|
if !self.snaps.undo() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::{op::InputOp, Input, InputMode};
|
use crate::input::{op::InputOp, Input, InputMode};
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn visual(&mut self, _: Exec) {
|
pub fn visual(&mut self, _: Cmd) {
|
||||||
let snap = self.snap_mut();
|
let snap = self.snap_mut();
|
||||||
if snap.mode != InputMode::Normal {
|
if snap.mode != InputMode::Normal {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::input::{op::InputOp, Input};
|
use crate::input::{op::InputOp, Input};
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn yank(&mut self, _: Exec) {
|
pub fn yank(&mut self, _: Cmd) {
|
||||||
match self.snap().op {
|
match self.snap().op {
|
||||||
InputOp::None => {
|
InputOp::None => {
|
||||||
self.snap_mut().op = InputOp::Yank(self.snap().cursor);
|
self.snap_mut().op = InputOp::Yank(self.snap().cursor);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn close(&mut self, _: Exec, tasks: &Tasks) {
|
pub fn close(&mut self, _: Cmd, tasks: &Tasks) {
|
||||||
if self.tabs.len() > 1 {
|
if self.tabs.len() > 1 {
|
||||||
return self.tabs.close(self.tabs.idx);
|
return self.tabs.close(self.tabs.idx);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::path::{PathBuf, MAIN_SEPARATOR};
|
||||||
|
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{event::Exec, fs::{File, FilesOp, Url}};
|
use yazi_shared::{event::Cmd, fs::{File, FilesOp, Url}};
|
||||||
|
|
||||||
use crate::{input::Input, manager::Manager};
|
use crate::{input::Input, manager::Manager};
|
||||||
|
|
||||||
|
|
@ -10,8 +10,8 @@ pub struct Opt {
|
||||||
force: bool,
|
force: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { force: e.named.contains_key("force") } }
|
fn from(c: Cmd) -> Self { Self { force: c.named.contains_key("force") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use yazi_shared::{emit, event::Exec, fs::Url, render, Layer};
|
use yazi_shared::{emit, event::Cmd, fs::Url, render, Layer};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
||||||
url: Option<Url>,
|
url: Option<Url>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self { Self { url: e.take_first().map(Url::from) } }
|
fn from(mut c: Cmd) -> Self { Self { url: c.take_first().map(Url::from) } }
|
||||||
}
|
}
|
||||||
impl From<Option<Url>> for Opt {
|
impl From<Option<Url>> for Opt {
|
||||||
fn from(url: Option<Url>) -> Self { Self { url } }
|
fn from(url: Option<Url>) -> Self { Self { url } }
|
||||||
|
|
@ -19,7 +19,7 @@ impl Manager {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _hover(url: Option<Url>) {
|
pub fn _hover(url: Option<Url>) {
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("hover", url.map_or_else(Vec::new, |u| vec![u.to_string()])),
|
Cmd::args("hover", url.map_or_else(Vec::new, |u| vec![u.to_string()])),
|
||||||
Layer::Manager
|
Layer::Manager
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@ pub struct Opt {
|
||||||
force: bool,
|
force: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
Self { relative: e.named.contains_key("relative"), force: e.named.contains_key("force") }
|
Self { relative: c.named.contains_key("relative"), force: c.named.contains_key("force") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::ffi::OsString;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
use yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
||||||
use yazi_plugin::isolate;
|
use yazi_plugin::isolate;
|
||||||
use yazi_shared::{emit, event::{EventQuit, Exec}, fs::{File, Url}, Layer, MIME_DIR};
|
use yazi_shared::{emit, event::{Cmd, EventQuit}, fs::{File, Url}, Layer, MIME_DIR};
|
||||||
|
|
||||||
use crate::{manager::Manager, select::Select, tasks::Tasks};
|
use crate::{manager::Manager, select::Select, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -12,11 +12,11 @@ pub struct Opt {
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
targets: e.take_data().unwrap_or_default(),
|
targets: c.take_data().unwrap_or_default(),
|
||||||
interactive: e.named.contains_key("interactive"),
|
interactive: c.named.contains_key("interactive"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ impl Manager {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _open_do(interactive: bool, targets: Vec<(Url, Option<String>)>) {
|
pub fn _open_do(interactive: bool, targets: Vec<(Url, Option<String>)>) {
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("open_do", vec![]).with_bool("interactive", interactive).with_data(targets),
|
Cmd::new("open_do").with_bool("interactive", interactive).with_data(targets),
|
||||||
Layer::Manager
|
Layer::Manager
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@ pub struct Opt {
|
||||||
follow: bool,
|
follow: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
Self { force: e.named.contains_key("force"), follow: e.named.contains_key("follow") }
|
Self { force: c.named.contains_key("force"), follow: c.named.contains_key("follow") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{emit, event::Exec, fs::Url, render, Layer};
|
use yazi_shared::{emit, event::Cmd, fs::Url, render, Layer};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -10,13 +10,13 @@ pub struct Opt {
|
||||||
upper_bound: bool,
|
upper_bound: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
skip: e.take_first().and_then(|s| s.parse().ok()),
|
skip: c.take_first().and_then(|s| s.parse().ok()),
|
||||||
force: e.named.contains_key("force"),
|
force: c.named.contains_key("force"),
|
||||||
only_if: e.take_name("only-if").map(Url::from),
|
only_if: c.take_name("only-if").map(Url::from),
|
||||||
upper_bound: e.named.contains_key("upper-bound"),
|
upper_bound: c.named.contains_key("upper-bound"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@ impl From<bool> for Opt {
|
||||||
impl Manager {
|
impl Manager {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _peek(force: bool) {
|
pub fn _peek(force: bool) {
|
||||||
emit!(Call(Exec::call("peek", vec![]).with_bool("force", force), Layer::Manager));
|
emit!(Call(Cmd::new("peek").with_bool("force", force), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peek(&mut self, opt: impl Into<Opt>) {
|
pub fn peek(&mut self, opt: impl Into<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{emit, event::{EventQuit, Exec}};
|
use yazi_shared::{emit, event::{Cmd, EventQuit}};
|
||||||
|
|
||||||
use crate::{input::Input, manager::Manager, tasks::Tasks};
|
use crate::{input::Input, manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -10,8 +10,8 @@ pub struct Opt {
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self::default() }
|
fn from(_: ()) -> Self { Self::default() }
|
||||||
}
|
}
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { no_cwd_file: e.named.contains_key("no-cwd-file") } }
|
fn from(c: Cmd) -> Self { Self { no_cwd_file: c.named.contains_key("no-cwd-file") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use yazi_shared::{emit, event::Exec, Layer};
|
use yazi_shared::{emit, event::Cmd, Layer};
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _refresh() {
|
pub fn _refresh() {
|
||||||
emit!(Call(Exec::call("refresh", vec![]), Layer::Manager));
|
emit!(Call(Cmd::new("refresh"), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh(&mut self, _: Exec, tasks: &Tasks) {
|
pub fn refresh(&mut self, _: Cmd, tasks: &Tasks) {
|
||||||
env::set_current_dir(self.cwd()).ok();
|
env::set_current_dir(self.cwd()).ok();
|
||||||
env::set_var("PWD", self.cwd());
|
env::set_var("PWD", self.cwd());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -7,11 +7,11 @@ pub struct Opt {
|
||||||
permanently: bool,
|
permanently: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
force: e.named.contains_key("force"),
|
force: c.named.contains_key("force"),
|
||||||
permanently: e.named.contains_key("permanently"),
|
permanently: c.named.contains_key("permanently"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}};
|
||||||
use yazi_config::{popup::InputCfg, OPEN, PREVIEW};
|
use yazi_config::{popup::InputCfg, OPEN, PREVIEW};
|
||||||
use yazi_plugin::external::{self, ShellOpt};
|
use yazi_plugin::external::{self, ShellOpt};
|
||||||
use yazi_scheduler::{Scheduler, BLOCKER};
|
use yazi_scheduler::{Scheduler, BLOCKER};
|
||||||
use yazi_shared::{event::Exec, fs::{max_common_root, File, FilesOp, Url}, term::Term, Defer};
|
use yazi_shared::{event::Cmd, fs::{max_common_root, File, FilesOp, Url}, term::Term, Defer};
|
||||||
|
|
||||||
use crate::{input::Input, manager::Manager};
|
use crate::{input::Input, manager::Manager};
|
||||||
|
|
||||||
|
|
@ -15,12 +15,12 @@ pub struct Opt {
|
||||||
cursor: String,
|
cursor: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
force: e.named.contains_key("force"),
|
force: c.named.contains_key("force"),
|
||||||
empty: e.take_name("empty").unwrap_or_default(),
|
empty: c.take_name("empty").unwrap_or_default(),
|
||||||
cursor: e.take_name("cursor").unwrap_or_default(),
|
cursor: c.take_name("cursor").unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use yazi_config::PLUGIN;
|
use yazi_config::PLUGIN;
|
||||||
use yazi_plugin::isolate;
|
use yazi_plugin::isolate;
|
||||||
use yazi_shared::{event::Exec, render, MIME_DIR};
|
use yazi_shared::{event::Cmd, render, MIME_DIR};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -9,9 +9,9 @@ pub struct Opt {
|
||||||
units: i16,
|
units: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { units: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
Self { units: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,6 +34,6 @@ impl Manager {
|
||||||
};
|
};
|
||||||
|
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
isolate::seek_sync(&previewer.exec, hovered.clone(), opt.units);
|
isolate::seek_sync(&previewer.cmd, hovered.clone(), opt.units);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use yazi_scheduler::Scheduler;
|
use yazi_scheduler::Scheduler;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn suspend(&mut self, _: Exec) {
|
pub fn suspend(&mut self, _: Cmd) {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
Scheduler::app_stop().await;
|
Scheduler::app_stop().await;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::manager::Tabs;
|
use crate::manager::Tabs;
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
idx: usize,
|
idx: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { idx: e.take_first().and_then(|i| i.parse().ok()).unwrap_or(0) }
|
Self { idx: c.take_first().and_then(|i| i.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, fs::Url, render};
|
use yazi_shared::{event::Cmd, fs::Url, render};
|
||||||
|
|
||||||
use crate::{manager::Tabs, tab::Tab};
|
use crate::{manager::Tabs, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -9,12 +9,12 @@ pub struct Opt {
|
||||||
current: bool,
|
current: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
let mut opt = Self { url: None, current: e.named.contains_key("current") };
|
let mut opt = Self { url: None, current: c.named.contains_key("current") };
|
||||||
|
|
||||||
if !opt.current {
|
if !opt.current {
|
||||||
opt.url = Some(e.take_first().map_or_else(|| Url::from("."), Url::from));
|
opt.url = Some(c.take_first().map_or_else(|| Url::from("."), Url::from));
|
||||||
}
|
}
|
||||||
opt
|
opt
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::manager::Tabs;
|
use crate::manager::Tabs;
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
step: isize,
|
step: isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::manager::Tabs;
|
use crate::manager::Tabs;
|
||||||
|
|
||||||
|
|
@ -7,11 +7,11 @@ pub struct Opt {
|
||||||
relative: bool,
|
relative: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||||
relative: e.named.contains_key("relative"),
|
relative: c.named.contains_key("relative"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use yazi_shared::{event::Exec, fs::FilesOp, render};
|
use yazi_shared::{event::Cmd, fs::FilesOp, render};
|
||||||
|
|
||||||
use crate::{folder::Folder, manager::Manager, tab::Tab, tasks::Tasks};
|
use crate::{folder::Folder, manager::Manager, tab::Tab, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -8,12 +8,10 @@ pub struct Opt {
|
||||||
op: FilesOp,
|
op: FilesOp,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> { Ok(Self { op: c.take_data().ok_or(())? }) }
|
||||||
Ok(Self { op: e.take_data().ok_or(())? })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use yazi_plugin::ValueSendable;
|
use yazi_plugin::ValueSendable;
|
||||||
use yazi_shared::{event::Exec, fs::Url, render};
|
use yazi_shared::{event::Cmd, fs::Url, render};
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -9,11 +9,11 @@ pub struct Opt {
|
||||||
data: ValueSendable,
|
data: ValueSendable,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||||
Ok(Self { data: e.take_data().ok_or(())? })
|
Ok(Self { data: c.take_data().ok_or(())? })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{emit, event::Exec, fs::Url, Layer};
|
use yazi_shared::{emit, event::Cmd, fs::Url, Layer};
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
|
|
@ -8,11 +8,11 @@ pub struct Opt {
|
||||||
only_if: Option<Url>,
|
only_if: Option<Url>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
page: e.take_first().and_then(|s| s.parse().ok()),
|
page: c.take_first().and_then(|s| s.parse().ok()),
|
||||||
only_if: e.take_name("only-if").map(Url::from),
|
only_if: c.take_name("only-if").map(Url::from),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,13 +24,13 @@ impl From<()> for Opt {
|
||||||
impl Manager {
|
impl Manager {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _update_paged() {
|
pub fn _update_paged() {
|
||||||
emit!(Call(Exec::call("update_paged", vec![]), Layer::Manager));
|
emit!(Call(Cmd::new("update_paged"), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _update_paged_by(page: usize, only_if: &Url) {
|
pub fn _update_paged_by(page: usize, only_if: &Url) {
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("update_paged", vec![page.to_string()]).with("only-if", only_if.to_string()),
|
Cmd::args("update_paged", vec![page.to_string()]).with("only-if", only_if.to_string()),
|
||||||
Layer::Manager
|
Layer::Manager
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::manager::Manager;
|
use crate::manager::Manager;
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
||||||
cut: bool,
|
cut: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { cut: e.named.contains_key("cut") } }
|
fn from(c: Cmd) -> Self { Self { cut: c.named.contains_key("cut") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::select::Select;
|
use crate::select::Select;
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
step: isize,
|
step: isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::select::Select;
|
use crate::select::Select;
|
||||||
|
|
||||||
|
|
@ -7,8 +7,8 @@ pub struct Opt {
|
||||||
submit: bool,
|
submit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
fn from(c: Cmd) -> Self { Self { submit: c.named.contains_key("submit") } }
|
||||||
}
|
}
|
||||||
impl From<bool> for Opt {
|
impl From<bool> for Opt {
|
||||||
fn from(submit: bool) -> Self { Self { submit } }
|
fn from(submit: bool) -> Self { Self { submit } }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use yazi_config::popup::SelectCfg;
|
use yazi_config::popup::SelectCfg;
|
||||||
use yazi_shared::{emit, event::Exec, render, term::Term, Layer};
|
use yazi_shared::{emit, event::Cmd, render, term::Term, Layer};
|
||||||
|
|
||||||
use crate::select::Select;
|
use crate::select::Select;
|
||||||
|
|
||||||
|
|
@ -10,16 +10,16 @@ pub struct Opt {
|
||||||
tx: oneshot::Sender<Result<usize>>,
|
tx: oneshot::Sender<Result<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> { e.take_data().ok_or(()) }
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> { c.take_data().ok_or(()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Select {
|
impl Select {
|
||||||
pub async fn _show(cfg: SelectCfg) -> Result<usize> {
|
pub async fn _show(cfg: SelectCfg) -> Result<usize> {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
emit!(Call(Exec::call("show", vec![]).with_data(Opt { cfg, tx }), Layer::Select));
|
emit!(Call(Cmd::new("show").with_data(Opt { cfg, tx }), Layer::Select));
|
||||||
rx.await.unwrap_or_else(|_| Term::goodbye(|| false))
|
rx.await.unwrap_or_else(|_| Term::goodbye(|| false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab, Step};
|
use crate::{manager::Manager, tab::Tab, Step};
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
step: Step,
|
step: Step,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or_default() }
|
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or_default() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub struct Opt;
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self }
|
fn from(_: ()) -> Self { Self }
|
||||||
}
|
}
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::{mem, time::Duration};
|
||||||
use tokio::{fs, pin};
|
use tokio::{fs, pin};
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{emit, event::Exec, fs::{expand_path, Url}, render, Debounce, InputError, Layer};
|
use yazi_shared::{emit, event::Cmd, fs::{expand_path, Url}, render, Debounce, InputError, Layer};
|
||||||
|
|
||||||
use crate::{completion::Completion, input::Input, manager::Manager, tab::Tab};
|
use crate::{completion::Completion, input::Input, manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -12,14 +12,14 @@ pub struct Opt {
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
let mut target = Url::from(e.take_first().unwrap_or_default());
|
let mut target = Url::from(c.take_first().unwrap_or_default());
|
||||||
if target.is_regular() {
|
if target.is_regular() {
|
||||||
target.set_path(expand_path(&target))
|
target.set_path(expand_path(&target))
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { target, interactive: e.named.contains_key("interactive") }
|
Self { target, interactive: c.named.contains_key("interactive") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Url> for Opt {
|
impl From<Url> for Opt {
|
||||||
|
|
@ -29,7 +29,7 @@ impl From<Url> for Opt {
|
||||||
impl Tab {
|
impl Tab {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _cd(target: &Url) {
|
pub fn _cd(target: &Url) {
|
||||||
emit!(Call(Exec::call("cd", vec![target.to_string()]), Layer::Manager));
|
emit!(Call(Cmd::args("cd", vec![target.to_string()]), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cd(&mut self, opt: impl Into<Opt>) {
|
pub fn cd(&mut self, opt: impl Into<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
|
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{tab::Tab, CLIPBOARD};
|
use crate::{tab::Tab, CLIPBOARD};
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
||||||
type_: String,
|
type_: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self { Self { type_: e.take_first().unwrap_or_default() } }
|
fn from(mut c: Cmd) -> Self { Self { type_: c.take_first().unwrap_or_default() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab};
|
use crate::{manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pub struct Opt;
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self }
|
fn from(_: ()) -> Self { Self }
|
||||||
}
|
}
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tab::{Mode, Tab};
|
use crate::tab::{Mode, Tab};
|
||||||
|
|
||||||
|
|
@ -13,9 +13,9 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
e.named.iter().fold(Opt::empty(), |acc, (k, _)| match k.as_str() {
|
c.named.iter().fold(Opt::empty(), |acc, (k, _)| match k.as_str() {
|
||||||
"all" => Self::all(),
|
"all" => Self::all(),
|
||||||
"find" => acc | Self::FIND,
|
"find" => acc | Self::FIND,
|
||||||
"visual" => acc | Self::VISUAL,
|
"visual" => acc | Self::VISUAL,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
||||||
use tokio::pin;
|
use tokio::pin;
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{emit, event::Exec, render, Debounce, InputError, Layer};
|
use yazi_shared::{emit, event::Cmd, render, Debounce, InputError, Layer};
|
||||||
|
|
||||||
use crate::{folder::{Filter, FilterCase}, input::Input, manager::Manager, tab::Tab};
|
use crate::{folder::{Filter, FilterCase}, input::Input, manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -14,12 +14,12 @@ pub struct Opt {
|
||||||
pub done: bool,
|
pub done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
query: e.take_first().unwrap_or_default(),
|
query: c.take_first().unwrap_or_default(),
|
||||||
case: FilterCase::from(&e),
|
case: FilterCase::from(&c),
|
||||||
done: e.named.contains_key("done"),
|
done: c.named.contains_key("done"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ impl Tab {
|
||||||
};
|
};
|
||||||
|
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("filter_do", vec![s])
|
Cmd::args("filter_do", vec![s])
|
||||||
.with_bool("smart", opt.case == FilterCase::Smart)
|
.with_bool("smart", opt.case == FilterCase::Smart)
|
||||||
.with_bool("insensitive", opt.case == FilterCase::Insensitive)
|
.with_bool("insensitive", opt.case == FilterCase::Insensitive)
|
||||||
.with_bool("done", done),
|
.with_bool("done", done),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
||||||
use tokio::pin;
|
use tokio::pin;
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_shared::{emit, event::Exec, render, Debounce, InputError, Layer};
|
use yazi_shared::{emit, event::Cmd, render, Debounce, InputError, Layer};
|
||||||
|
|
||||||
use crate::{folder::FilterCase, input::Input, tab::{Finder, Tab}};
|
use crate::{folder::FilterCase, input::Input, tab::{Finder, Tab}};
|
||||||
|
|
||||||
|
|
@ -13,12 +13,12 @@ pub struct Opt {
|
||||||
case: FilterCase,
|
case: FilterCase,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
query: e.take_first(),
|
query: c.take_first(),
|
||||||
prev: e.named.contains_key("previous"),
|
prev: c.named.contains_key("previous"),
|
||||||
case: FilterCase::from(&e),
|
case: FilterCase::from(&c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,8 +27,8 @@ pub struct ArrowOpt {
|
||||||
prev: bool,
|
prev: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for ArrowOpt {
|
impl From<Cmd> for ArrowOpt {
|
||||||
fn from(e: Exec) -> Self { Self { prev: e.named.contains_key("previous") } }
|
fn from(c: Cmd) -> Self { Self { prev: c.named.contains_key("previous") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
@ -42,7 +42,7 @@ impl Tab {
|
||||||
|
|
||||||
while let Some(Ok(s)) | Some(Err(InputError::Typed(s))) = rx.next().await {
|
while let Some(Ok(s)) | Some(Err(InputError::Typed(s))) = rx.next().await {
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("find_do", vec![s])
|
Cmd::args("find_do", vec![s])
|
||||||
.with_bool("previous", opt.prev)
|
.with_bool("previous", opt.prev)
|
||||||
.with_bool("smart", opt.case == FilterCase::Smart)
|
.with_bool("smart", opt.case == FilterCase::Smart)
|
||||||
.with_bool("insensitive", opt.case == FilterCase::Insensitive),
|
.with_bool("insensitive", opt.case == FilterCase::Insensitive),
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab};
|
use crate::{manager::Manager, tab::Tab};
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
pub fn hidden(&mut self, e: Exec) {
|
pub fn hidden(&mut self, c: Cmd) {
|
||||||
self.conf.show_hidden = match e.args.first().map(|s| s.as_str()) {
|
self.conf.show_hidden = match c.args.first().map(|s| s.as_str()) {
|
||||||
Some("show") => true,
|
Some("show") => true,
|
||||||
Some("hide") => false,
|
Some("hide") => false,
|
||||||
_ => !self.conf.show_hidden,
|
_ => !self.conf.show_hidden,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use yazi_plugin::external::{self, FzfOpt, ZoxideOpt};
|
use yazi_plugin::external::{self, FzfOpt, ZoxideOpt};
|
||||||
use yazi_scheduler::{Scheduler, BLOCKER};
|
use yazi_scheduler::{Scheduler, BLOCKER};
|
||||||
use yazi_shared::{event::Exec, fs::ends_with_slash, Defer};
|
use yazi_shared::{event::Cmd, fs::ends_with_slash, Defer};
|
||||||
|
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
|
|
@ -15,10 +15,10 @@ pub enum OptType {
|
||||||
Zoxide,
|
Zoxide,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
type_: match e.args.first().map(|s| s.as_str()) {
|
type_: match c.args.first().map(|s| s.as_str()) {
|
||||||
Some("fzf") => OptType::Fzf,
|
Some("fzf") => OptType::Fzf,
|
||||||
Some("zoxide") => OptType::Zoxide,
|
Some("zoxide") => OptType::Zoxide,
|
||||||
_ => OptType::None,
|
_ => OptType::None,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab};
|
use crate::{manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pub struct Opt;
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self }
|
fn from(_: ()) -> Self { Self }
|
||||||
}
|
}
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
pub fn linemode(&mut self, mut e: Exec) {
|
pub fn linemode(&mut self, mut c: Cmd) {
|
||||||
render!(self.conf.patch(|c| {
|
render!(self.conf.patch(|new| {
|
||||||
let Some(mode) = e.take_first() else {
|
let Some(mode) = c.take_first() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if !mode.is_empty() && mode.len() <= 20 {
|
if !mode.is_empty() && mode.len() <= 20 {
|
||||||
c.linemode = mode;
|
new.linemode = mode;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use yazi_plugin::utils::PreviewLock;
|
use yazi_plugin::utils::PreviewLock;
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
|
|
@ -7,11 +7,11 @@ pub struct Opt {
|
||||||
lock: PreviewLock,
|
lock: PreviewLock,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||||
Ok(Self { lock: e.take_data().ok_or(())? })
|
Ok(Self { lock: c.take_data().ok_or(())? })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{emit, event::Exec, fs::{expand_path, File, FilesOp, Url}, Layer};
|
use yazi_shared::{emit, event::Cmd, fs::{expand_path, File, FilesOp, Url}, Layer};
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab};
|
use crate::{manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
target: Url,
|
target: Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
let mut target = Url::from(e.take_first().unwrap_or_default());
|
let mut target = Url::from(c.take_first().unwrap_or_default());
|
||||||
if target.is_regular() {
|
if target.is_regular() {
|
||||||
target.set_path(expand_path(&target))
|
target.set_path(expand_path(&target))
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ impl From<Url> for Opt {
|
||||||
impl Tab {
|
impl Tab {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn _reveal(target: &Url) {
|
pub fn _reveal(target: &Url) {
|
||||||
emit!(Call(Exec::call("reveal", vec![target.to_string()]), Layer::Manager));
|
emit!(Call(Cmd::args("reveal", vec![target.to_string()]), Layer::Manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reveal(&mut self, opt: impl Into<Opt>) {
|
pub fn reveal(&mut self, opt: impl Into<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use tokio::pin;
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::popup::InputCfg;
|
use yazi_config::popup::InputCfg;
|
||||||
use yazi_plugin::external;
|
use yazi_plugin::external;
|
||||||
use yazi_shared::{event::Exec, fs::FilesOp, render};
|
use yazi_shared::{event::Cmd, fs::FilesOp, render};
|
||||||
|
|
||||||
use crate::{input::Input, manager::Manager, tab::Tab};
|
use crate::{input::Input, manager::Manager, tab::Tab};
|
||||||
|
|
||||||
|
|
@ -41,8 +41,8 @@ pub struct Opt {
|
||||||
pub type_: OptType,
|
pub type_: OptType,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self { Self { type_: e.take_first().unwrap_or_default().into() } }
|
fn from(mut c: Cmd) -> Self { Self { type_: c.take_first().unwrap_or_default().into() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
|
|
||||||
|
|
@ -6,10 +6,10 @@ pub struct Opt {
|
||||||
state: Option<bool>,
|
state: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self {
|
fn from(c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state: match e.named.get("state").map(|s| s.as_str()) {
|
state: match c.named.get("state").map(|s| s.as_str()) {
|
||||||
Some("true") => Some(true),
|
Some("true") => Some(true),
|
||||||
Some("false") => Some(false),
|
Some("false") => Some(false),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
use yazi_config::{open::Opener, popup::InputCfg};
|
use yazi_config::{open::Opener, popup::InputCfg};
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{input::Input, tab::Tab, tasks::Tasks};
|
use crate::{input::Input, tab::Tab, tasks::Tasks};
|
||||||
|
|
||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
cmd: String,
|
exec: String,
|
||||||
block: bool,
|
block: bool,
|
||||||
confirm: bool,
|
confirm: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cmd: e.take_first().unwrap_or_default(),
|
exec: c.take_first().unwrap_or_default(),
|
||||||
block: e.named.contains_key("block"),
|
block: c.named.contains_key("block"),
|
||||||
confirm: e.named.contains_key("confirm"),
|
confirm: c.named.contains_key("confirm"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,16 +25,16 @@ impl Tab {
|
||||||
let selected: Vec<_> = self.selected().into_iter().map(|f| f.url()).collect();
|
let selected: Vec<_> = self.selected().into_iter().map(|f| f.url()).collect();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if !opt.confirm || opt.cmd.is_empty() {
|
if !opt.confirm || opt.exec.is_empty() {
|
||||||
let mut result = Input::_show(InputCfg::shell(opt.block).with_value(opt.cmd));
|
let mut result = Input::_show(InputCfg::shell(opt.block).with_value(opt.exec));
|
||||||
match result.recv().await {
|
match result.recv().await {
|
||||||
Some(Ok(e)) => opt.cmd = e,
|
Some(Ok(e)) => opt.exec = e,
|
||||||
_ => return,
|
_ => return,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tasks::_open(selected, Opener {
|
Tasks::_open(selected, Opener {
|
||||||
exec: opt.cmd,
|
exec: opt.exec,
|
||||||
block: opt.block,
|
block: opt.block,
|
||||||
orphan: false,
|
orphan: false,
|
||||||
desc: Default::default(),
|
desc: Default::default(),
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use yazi_config::manager::SortBy;
|
use yazi_config::manager::SortBy;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{manager::Manager, tab::Tab, tasks::Tasks};
|
use crate::{manager::Manager, tab::Tab, tasks::Tasks};
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
pub fn sort(&mut self, e: Exec, tasks: &Tasks) {
|
pub fn sort(&mut self, c: Cmd, tasks: &Tasks) {
|
||||||
if let Some(by) = e.args.first() {
|
if let Some(by) = c.args.first() {
|
||||||
self.conf.sort_by = SortBy::from_str(by).unwrap_or_default();
|
self.conf.sort_by = SortBy::from_str(by).unwrap_or_default();
|
||||||
}
|
}
|
||||||
self.conf.sort_sensitive = e.named.contains_key("sensitive");
|
self.conf.sort_sensitive = c.named.contains_key("sensitive");
|
||||||
self.conf.sort_reverse = e.named.contains_key("reverse");
|
self.conf.sort_reverse = c.named.contains_key("reverse");
|
||||||
self.conf.sort_dir_first = e.named.contains_key("dir-first");
|
self.conf.sort_dir_first = c.named.contains_key("dir-first");
|
||||||
|
|
||||||
self.apply_files_attrs();
|
self.apply_files_attrs();
|
||||||
Manager::_update_paged();
|
Manager::_update_paged();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tab::{Mode, Tab};
|
use crate::tab::{Mode, Tab};
|
||||||
|
|
||||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
||||||
unset: bool,
|
unset: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(e: Exec) -> Self { Self { unset: e.named.contains_key("unset") } }
|
fn from(c: Cmd) -> Self { Self { unset: c.named.contains_key("unset") } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ impl Preview {
|
||||||
|
|
||||||
self.abort();
|
self.abort();
|
||||||
if previewer.sync {
|
if previewer.sync {
|
||||||
isolate::peek_sync(&previewer.exec, file, self.skip);
|
isolate::peek_sync(&previewer.cmd, file, self.skip);
|
||||||
} else {
|
} else {
|
||||||
self.previewer_ct = Some(isolate::peek(&previewer.exec, file, self.skip));
|
self.previewer_ct = Some(isolate::peek(&previewer.cmd, file, self.skip));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tasks::Tasks;
|
use crate::tasks::Tasks;
|
||||||
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
||||||
step: isize,
|
step: isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self {
|
fn from(mut c: Cmd) -> Self {
|
||||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tasks::Tasks;
|
use crate::tasks::Tasks;
|
||||||
|
|
||||||
impl Tasks {
|
impl Tasks {
|
||||||
pub fn cancel(&mut self, _: Exec) {
|
pub fn cancel(&mut self, _: Cmd) {
|
||||||
let id = self.scheduler.running.lock().get_id(self.cursor);
|
let id = self.scheduler.running.lock().get_id(self.cursor);
|
||||||
if id.map(|id| self.scheduler.cancel(id)) != Some(true) {
|
if id.map(|id| self.scheduler.cancel(id)) != Some(true) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ use std::io::{stdout, Write};
|
||||||
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
|
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
|
||||||
use tokio::{io::{stdin, AsyncReadExt}, select, sync::mpsc, time};
|
use tokio::{io::{stdin, AsyncReadExt}, select, sync::mpsc, time};
|
||||||
use yazi_scheduler::{Scheduler, BLOCKER};
|
use yazi_scheduler::{Scheduler, BLOCKER};
|
||||||
use yazi_shared::{event::Exec, term::Term, Defer};
|
use yazi_shared::{event::Cmd, term::Term, Defer};
|
||||||
|
|
||||||
use crate::tasks::Tasks;
|
use crate::tasks::Tasks;
|
||||||
|
|
||||||
impl Tasks {
|
impl Tasks {
|
||||||
pub fn inspect(&self, _: Exec) {
|
pub fn inspect(&self, _: Cmd) {
|
||||||
let Some(id) = self.scheduler.running.lock().get_id(self.cursor) else {
|
let Some(id) = self.scheduler.running.lock().get_id(self.cursor) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use yazi_config::open::Opener;
|
use yazi_config::open::Opener;
|
||||||
use yazi_shared::{emit, event::Exec, fs::Url, Layer};
|
use yazi_shared::{emit, event::Cmd, fs::Url, Layer};
|
||||||
|
|
||||||
use crate::tasks::Tasks;
|
use crate::tasks::Tasks;
|
||||||
|
|
||||||
|
|
@ -8,15 +8,15 @@ pub struct Opt {
|
||||||
opener: Opener,
|
opener: Opener,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> { e.take_data().ok_or(()) }
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> { c.take_data().ok_or(()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tasks {
|
impl Tasks {
|
||||||
pub fn _open(targets: Vec<Url>, opener: Opener) {
|
pub fn _open(targets: Vec<Url>, opener: Opener) {
|
||||||
emit!(Call(Exec::call("open", vec![]).with_data(Opt { targets, opener }), Layer::Tasks));
|
emit!(Call(Cmd::new("open").with_data(Opt { targets, opener }), Layer::Tasks));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open(&mut self, opt: impl TryInto<Opt>) {
|
pub fn open(&mut self, opt: impl TryInto<Opt>) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use yazi_shared::{event::Exec, render};
|
use yazi_shared::{event::Cmd, render};
|
||||||
|
|
||||||
use crate::tasks::Tasks;
|
use crate::tasks::Tasks;
|
||||||
|
|
||||||
pub struct Opt;
|
pub struct Opt;
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self }
|
fn from(_: ()) -> Self { Self }
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use tracing::debug;
|
||||||
use yazi_config::{manager::SortBy, open::Opener, plugin::{PluginRule, MAX_PRELOADERS}, popup::InputCfg, OPEN, PLUGIN};
|
use yazi_config::{manager::SortBy, open::Opener, plugin::{PluginRule, MAX_PRELOADERS}, popup::InputCfg, OPEN, PLUGIN};
|
||||||
use yazi_plugin::ValueSendable;
|
use yazi_plugin::ValueSendable;
|
||||||
use yazi_scheduler::{Scheduler, TaskSummary};
|
use yazi_scheduler::{Scheduler, TaskSummary};
|
||||||
use yazi_shared::{emit, event::Exec, fs::{File, Url}, term::Term, Layer, MIME_DIR};
|
use yazi_shared::{emit, event::Cmd, fs::{File, Url}, term::Term, Layer, MIME_DIR};
|
||||||
|
|
||||||
use super::{TasksProgress, TASKS_PADDING, TASKS_PERCENT};
|
use super::{TasksProgress, TASKS_PADDING, TASKS_PERCENT};
|
||||||
use crate::{folder::Files, input::Input};
|
use crate::{folder::Files, input::Input};
|
||||||
|
|
@ -36,7 +36,7 @@ impl Tasks {
|
||||||
let new = TasksProgress::from(&*running.lock());
|
let new = TasksProgress::from(&*running.lock());
|
||||||
if last != new {
|
if last != new {
|
||||||
last = new;
|
last = new;
|
||||||
emit!(Call(Exec::call("update_progress", vec![]).with_data(new), Layer::App));
|
emit!(Call(Cmd::new("update_progress").with_data(new), Layer::App));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
use std::mem;
|
use yazi_config::{keymap::{Control, ControlCow, Key}, KEYMAP};
|
||||||
|
|
||||||
use yazi_config::{keymap::{Control, Key}, KEYMAP};
|
|
||||||
use yazi_shared::{emit, render, Layer};
|
use yazi_shared::{emit, render, Layer};
|
||||||
|
|
||||||
pub struct Which {
|
pub struct Which {
|
||||||
layer: Layer,
|
layer: Layer,
|
||||||
pub times: usize,
|
pub times: usize,
|
||||||
pub cands: Vec<&'static Control>,
|
pub cands: Vec<ControlCow>,
|
||||||
|
|
||||||
pub visible: bool,
|
pub visible: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -21,16 +19,28 @@ impl Which {
|
||||||
pub fn show(&mut self, key: &Key, layer: Layer) {
|
pub fn show(&mut self, key: &Key, layer: Layer) {
|
||||||
self.layer = layer;
|
self.layer = layer;
|
||||||
self.times = 1;
|
self.times = 1;
|
||||||
self.cands = KEYMAP.get(layer).iter().filter(|s| s.on.len() > 1 && &s.on[0] == key).collect();
|
self.cands = KEYMAP
|
||||||
|
.get(layer)
|
||||||
|
.iter()
|
||||||
|
.filter(|c| c.on.len() > 1 && &c.on[0] == key)
|
||||||
|
.map(|c| c.into())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
self.visible = true;
|
||||||
|
render!();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn show_with(&mut self, cands: Vec<Control>, layer: Layer) {
|
||||||
|
self.layer = layer;
|
||||||
|
self.times = 0;
|
||||||
|
self.cands = cands.into_iter().map(|c| c.into()).collect();
|
||||||
|
|
||||||
self.visible = true;
|
self.visible = true;
|
||||||
render!();
|
render!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_(&mut self, key: Key) -> bool {
|
pub fn type_(&mut self, key: Key) -> bool {
|
||||||
self.cands = mem::take(&mut self.cands)
|
self.cands.retain(|c| c.on.len() > self.times && c.on[self.times] == key);
|
||||||
.into_iter()
|
|
||||||
.filter(|s| s.on.len() > self.times && s.on[self.times] == key)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
if self.cands.is_empty() {
|
if self.cands.is_empty() {
|
||||||
self.visible = false;
|
self.visible = false;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
use yazi_config::keymap::Key;
|
use yazi_config::keymap::Key;
|
||||||
use yazi_core::input::InputMode;
|
use yazi_core::input::InputMode;
|
||||||
use yazi_shared::{emit, event::{Event, Exec, NEED_RENDER}, term::Term, Layer};
|
use yazi_shared::{emit, event::{Cmd, Event, NEED_RENDER}, term::Term, Layer};
|
||||||
|
|
||||||
use crate::{lives::Lives, Ctx, Executor, Logs, Panic, Router, Signals};
|
use crate::{lives::Lives, Ctx, Executor, Logs, Panic, Router, Signals};
|
||||||
|
|
||||||
|
|
@ -66,12 +66,10 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn dispatch_call(&mut self, exec: Exec, layer: Layer) {
|
fn dispatch_call(&mut self, cmd: Cmd, layer: Layer) { Executor::new(self).execute(cmd, layer); }
|
||||||
Executor::new(self).execute(exec, layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn dispatch_seq(&mut self, mut execs: VecDeque<Exec>, layer: Layer) {
|
fn dispatch_seq(&mut self, mut execs: VecDeque<Cmd>, layer: Layer) {
|
||||||
if let Some(exec) = execs.pop_front() {
|
if let Some(exec) = execs.pop_front() {
|
||||||
Executor::new(self).execute(exec, layer);
|
Executor::new(self).execute(exec, layer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::fmt::Display;
|
||||||
use mlua::{ExternalError, ExternalResult, IntoLua, Table, TableExt, Variadic};
|
use mlua::{ExternalError, ExternalResult, IntoLua, Table, TableExt, Variadic};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use yazi_plugin::{LOADED, LUA};
|
use yazi_plugin::{LOADED, LUA};
|
||||||
use yazi_shared::{emit, event::Exec, Layer};
|
use yazi_shared::{emit, event::Cmd, Layer};
|
||||||
|
|
||||||
use crate::{app::App, lives::Lives};
|
use crate::{app::App, lives::Lives};
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ impl App {
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if LOADED.ensure(&opt.name).await.is_ok() {
|
if LOADED.ensure(&opt.name).await.is_ok() {
|
||||||
emit!(Call(Exec::call("plugin_do", vec![opt.name]).with_data(opt.data), Layer::App));
|
emit!(Call(Cmd::args("plugin_do", vec![opt.name]).with_data(opt.data), Layer::App));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
pub struct Opt;
|
pub struct Opt;
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(_: Exec) -> Self { Self }
|
fn from(_: Cmd) -> Self { Self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use yazi_shared::{event::Exec, term::Term};
|
use yazi_shared::{event::Cmd, term::Term};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub(crate) fn resume(&mut self, _: Exec) {
|
pub(crate) fn resume(&mut self, _: Cmd) {
|
||||||
self.cx.manager.active_mut().preview.reset_image();
|
self.cx.manager.active_mut().preview.reset_image();
|
||||||
self.term = Some(Term::start().unwrap());
|
self.term = Some(Term::start().unwrap());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
|
|
@ -7,8 +7,8 @@ pub struct Opt {
|
||||||
tx: Option<oneshot::Sender<()>>,
|
tx: Option<oneshot::Sender<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Exec> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
fn from(mut e: Exec) -> Self { Self { tx: e.take_data() } }
|
fn from(mut c: Cmd) -> Self { Self { tx: c.take_data() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use ratatui::backend::Backend;
|
use ratatui::backend::Backend;
|
||||||
use yazi_core::tasks::TasksProgress;
|
use yazi_core::tasks::TasksProgress;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::{app::App, components::Progress, lives::Lives};
|
use crate::{app::App, components::Progress, lives::Lives};
|
||||||
|
|
||||||
|
|
@ -8,11 +8,11 @@ pub struct Opt {
|
||||||
progress: TasksProgress,
|
progress: TasksProgress,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||||
Ok(Self { progress: e.take_data().ok_or(())? })
|
Ok(Self { progress: c.take_data().ok_or(())? })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use yazi_core::input::InputMode;
|
use yazi_core::input::InputMode;
|
||||||
use yazi_shared::{event::Exec, Layer};
|
use yazi_shared::{event::Cmd, Layer};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
|
|
@ -12,24 +12,24 @@ impl<'a> Executor<'a> {
|
||||||
pub(super) fn new(app: &'a mut App) -> Self { Self { app } }
|
pub(super) fn new(app: &'a mut App) -> Self { Self { app } }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn execute(&mut self, exec: Exec, layer: Layer) {
|
pub(super) fn execute(&mut self, cmd: Cmd, layer: Layer) {
|
||||||
match layer {
|
match layer {
|
||||||
Layer::App => self.app(exec),
|
Layer::App => self.app(cmd),
|
||||||
Layer::Manager => self.manager(exec),
|
Layer::Manager => self.manager(cmd),
|
||||||
Layer::Tasks => self.tasks(exec),
|
Layer::Tasks => self.tasks(cmd),
|
||||||
Layer::Select => self.select(exec),
|
Layer::Select => self.select(cmd),
|
||||||
Layer::Input => self.input(exec),
|
Layer::Input => self.input(cmd),
|
||||||
Layer::Help => self.help(exec),
|
Layer::Help => self.help(cmd),
|
||||||
Layer::Completion => self.completion(exec),
|
Layer::Completion => self.completion(cmd),
|
||||||
Layer::Which => unreachable!(),
|
Layer::Which => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app(&mut self, exec: Exec) {
|
fn app(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.$name(exec);
|
return self.app.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -42,21 +42,21 @@ impl<'a> Executor<'a> {
|
||||||
on!(resume);
|
on!(resume);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manager(&mut self, exec: Exec) {
|
fn manager(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
(MANAGER, $name:ident $(,$args:expr)*) => {
|
(MANAGER, $name:ident $(,$args:expr)*) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.manager.$name(exec, $($args),*);
|
return self.app.cx.manager.$name(cmd, $($args),*);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(ACTIVE, $name:ident $(,$args:expr)*) => {
|
(ACTIVE, $name:ident $(,$args:expr)*) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.manager.active_mut().$name(exec, $($args),*);
|
return self.app.cx.manager.active_mut().$name(cmd, $($args),*);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(TABS, $name:ident) => {
|
(TABS, $name:ident) => {
|
||||||
if exec.cmd == concat!("tab_", stringify!($name)) {
|
if cmd.name == concat!("tab_", stringify!($name)) {
|
||||||
return self.app.cx.manager.tabs.$name(exec);
|
return self.app.cx.manager.tabs.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -122,27 +122,27 @@ impl<'a> Executor<'a> {
|
||||||
on!(TABS, switch);
|
on!(TABS, switch);
|
||||||
on!(TABS, swap);
|
on!(TABS, swap);
|
||||||
|
|
||||||
match exec.cmd.as_bytes() {
|
match cmd.name.as_bytes() {
|
||||||
// Tasks
|
// Tasks
|
||||||
b"tasks_show" => self.app.cx.tasks.toggle(()),
|
b"tasks_show" => self.app.cx.tasks.toggle(()),
|
||||||
// Help
|
// Help
|
||||||
b"help" => self.app.cx.help.toggle(Layer::Manager),
|
b"help" => self.app.cx.help.toggle(Layer::Manager),
|
||||||
// Plugin
|
// Plugin
|
||||||
b"plugin" => self.app.plugin(exec),
|
b"plugin" => self.app.plugin(cmd),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tasks(&mut self, exec: Exec) {
|
fn tasks(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.tasks.$name(exec);
|
return self.app.cx.tasks.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name:ident, $alias:literal) => {
|
($name:ident, $alias:literal) => {
|
||||||
if exec.cmd == $alias {
|
if cmd.name == $alias {
|
||||||
return self.app.cx.tasks.$name(exec);
|
return self.app.cx.tasks.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -154,17 +154,17 @@ impl<'a> Executor<'a> {
|
||||||
on!(cancel);
|
on!(cancel);
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match exec.cmd.as_str() {
|
match cmd.name.as_str() {
|
||||||
"help" => self.app.cx.help.toggle(Layer::Tasks),
|
"help" => self.app.cx.help.toggle(Layer::Tasks),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select(&mut self, exec: Exec) {
|
fn select(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.select.$name(exec);
|
return self.app.cx.select.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -174,22 +174,22 @@ impl<'a> Executor<'a> {
|
||||||
on!(arrow);
|
on!(arrow);
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match exec.cmd.as_str() {
|
match cmd.name.as_str() {
|
||||||
"help" => self.app.cx.help.toggle(Layer::Select),
|
"help" => self.app.cx.help.toggle(Layer::Select),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input(&mut self, exec: Exec) {
|
fn input(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.input.$name(exec);
|
return self.app.cx.input.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name:ident, $alias:literal) => {
|
($name:ident, $alias:literal) => {
|
||||||
if exec.cmd == $alias {
|
if cmd.name == $alias {
|
||||||
return self.app.cx.input.$name(exec);
|
return self.app.cx.input.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -201,11 +201,11 @@ impl<'a> Executor<'a> {
|
||||||
on!(backward);
|
on!(backward);
|
||||||
on!(forward);
|
on!(forward);
|
||||||
|
|
||||||
if exec.cmd.as_str() == "complete" {
|
if cmd.name.as_str() == "complete" {
|
||||||
return if exec.named.contains_key("trigger") {
|
return if cmd.named.contains_key("trigger") {
|
||||||
self.app.cx.completion.trigger(exec)
|
self.app.cx.completion.trigger(cmd)
|
||||||
} else {
|
} else {
|
||||||
self.app.cx.input.complete(exec)
|
self.app.cx.input.complete(cmd)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ impl<'a> Executor<'a> {
|
||||||
on!(redo);
|
on!(redo);
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match exec.cmd.as_str() {
|
match cmd.name.as_str() {
|
||||||
"help" => self.app.cx.help.toggle(Layer::Input),
|
"help" => self.app.cx.help.toggle(Layer::Input),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
@ -234,11 +234,11 @@ impl<'a> Executor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn help(&mut self, exec: Exec) {
|
fn help(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.help.$name(exec);
|
return self.app.cx.help.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -248,17 +248,17 @@ impl<'a> Executor<'a> {
|
||||||
on!(filter);
|
on!(filter);
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match exec.cmd.as_str() {
|
match cmd.name.as_str() {
|
||||||
"close" => self.app.cx.help.toggle(Layer::Help),
|
"close" => self.app.cx.help.toggle(Layer::Help),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn completion(&mut self, exec: Exec) {
|
fn completion(&mut self, cmd: Cmd) {
|
||||||
macro_rules! on {
|
macro_rules! on {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
if exec.cmd == stringify!($name) {
|
if cmd.name == stringify!($name) {
|
||||||
return self.app.cx.completion.$name(exec);
|
return self.app.cx.completion.$name(cmd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -269,9 +269,9 @@ impl<'a> Executor<'a> {
|
||||||
on!(arrow);
|
on!(arrow);
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match exec.cmd.as_str() {
|
match cmd.name.as_str() {
|
||||||
"help" => self.app.cx.help.toggle(Layer::Completion),
|
"help" => self.app.cx.help.toggle(Layer::Completion),
|
||||||
"close_input" => self.app.cx.input.close(exec),
|
"close_input" => self.app.cx.input.close(cmd),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ impl Widget for Which<'_> {
|
||||||
|
|
||||||
for y in 0..area.height {
|
for y in 0..area.height {
|
||||||
for (x, chunk) in chunks.iter().enumerate() {
|
for (x, chunk) in chunks.iter().enumerate() {
|
||||||
let Some(&cand) = which.cands.get(y as usize * cols + x) else {
|
let Some(cand) = which.cands.get(y as usize * cols + x) else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,19 @@ use tokio::{runtime::Handle, select};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use yazi_config::LAYOUT;
|
use yazi_config::LAYOUT;
|
||||||
use yazi_shared::{emit, event::Exec, Layer};
|
use yazi_shared::{emit, event::Cmd, Layer};
|
||||||
|
|
||||||
use super::slim_lua;
|
use super::slim_lua;
|
||||||
use crate::{bindings::{Cast, File, Window}, elements::Rect, OptData, LOADED, LUA};
|
use crate::{bindings::{Cast, File, Window}, elements::Rect, OptData, LOADED, LUA};
|
||||||
|
|
||||||
pub fn peek(exec: &Exec, file: yazi_shared::fs::File, skip: usize) -> CancellationToken {
|
pub fn peek(cmd: &Cmd, file: yazi_shared::fs::File, skip: usize) -> CancellationToken {
|
||||||
let ct = CancellationToken::new();
|
let ct = CancellationToken::new();
|
||||||
|
|
||||||
let cmd = exec.cmd.to_owned();
|
let name = cmd.name.to_owned();
|
||||||
let (ct1, ct2) = (ct.clone(), ct.clone());
|
let (ct1, ct2) = (ct.clone(), ct.clone());
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
let future = async {
|
let future = async {
|
||||||
LOADED.ensure(&cmd).await.into_lua_err()?;
|
LOADED.ensure(&name).await.into_lua_err()?;
|
||||||
|
|
||||||
let lua = slim_lua()?;
|
let lua = slim_lua()?;
|
||||||
lua.set_hook(
|
lua.set_hook(
|
||||||
|
|
@ -25,7 +25,7 @@ pub fn peek(exec: &Exec, file: yazi_shared::fs::File, skip: usize) -> Cancellati
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let plugin: Table = if let Some(b) = LOADED.read().get(&cmd) {
|
let plugin: Table = if let Some(b) = LOADED.read().get(&name) {
|
||||||
lua.load(b).call(())?
|
lua.load(b).call(())?
|
||||||
} else {
|
} else {
|
||||||
return Err("unloaded plugin".into_lua_err());
|
return Err("unloaded plugin".into_lua_err());
|
||||||
|
|
@ -55,7 +55,7 @@ pub fn peek(exec: &Exec, file: yazi_shared::fs::File, skip: usize) -> Cancellati
|
||||||
ct
|
ct
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peek_sync(exec: &Exec, file: yazi_shared::fs::File, skip: usize) {
|
pub fn peek_sync(cmd: &Cmd, file: yazi_shared::fs::File, skip: usize) {
|
||||||
let data = OptData {
|
let data = OptData {
|
||||||
args: vec![],
|
args: vec![],
|
||||||
cb: Some(Box::new(move |plugin| {
|
cb: Some(Box::new(move |plugin| {
|
||||||
|
|
@ -68,7 +68,7 @@ pub fn peek_sync(exec: &Exec, file: yazi_shared::fs::File, skip: usize) {
|
||||||
tx: None,
|
tx: None,
|
||||||
};
|
};
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("plugin", vec![exec.cmd.to_owned()]).with_bool("sync", true).with_data(data),
|
Cmd::args("plugin", vec![cmd.name.to_owned()]).with_bool("sync", true).with_data(data),
|
||||||
Layer::App
|
Layer::App
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use mlua::TableExt;
|
use mlua::TableExt;
|
||||||
use yazi_config::LAYOUT;
|
use yazi_config::LAYOUT;
|
||||||
use yazi_shared::{emit, event::Exec, Layer};
|
use yazi_shared::{emit, event::Cmd, Layer};
|
||||||
|
|
||||||
use crate::{bindings::{Cast, File}, elements::Rect, OptData, LUA};
|
use crate::{bindings::{Cast, File}, elements::Rect, OptData, LUA};
|
||||||
|
|
||||||
pub fn seek_sync(exec: &Exec, file: yazi_shared::fs::File, units: i16) {
|
pub fn seek_sync(cmd: &Cmd, file: yazi_shared::fs::File, units: i16) {
|
||||||
let data = OptData {
|
let data = OptData {
|
||||||
args: vec![],
|
args: vec![],
|
||||||
cb: Some(Box::new(move |plugin| {
|
cb: Some(Box::new(move |plugin| {
|
||||||
|
|
@ -15,7 +15,7 @@ pub fn seek_sync(exec: &Exec, file: yazi_shared::fs::File, units: i16) {
|
||||||
tx: None,
|
tx: None,
|
||||||
};
|
};
|
||||||
emit!(Call(
|
emit!(Call(
|
||||||
Exec::call("plugin", vec![exec.cmd.to_owned()]).with_bool("sync", true).with_data(data),
|
Cmd::args("plugin", vec![cmd.name.to_owned()]).with_bool("sync", true).with_data(data),
|
||||||
Layer::App
|
Layer::App
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use mlua::{Table, Value};
|
use mlua::{Table, Value};
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use yazi_shared::event::Exec;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use crate::ValueSendable;
|
use crate::ValueSendable;
|
||||||
|
|
||||||
|
|
@ -18,23 +18,23 @@ pub struct OptData {
|
||||||
pub tx: Option<oneshot::Sender<ValueSendable>>,
|
pub tx: Option<oneshot::Sender<ValueSendable>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Exec> for Opt {
|
impl TryFrom<Cmd> for Opt {
|
||||||
type Error = anyhow::Error;
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||||
let Some(name) = e.take_first().filter(|s| !s.is_empty()) else {
|
let Some(name) = c.take_first().filter(|s| !s.is_empty()) else {
|
||||||
bail!("invalid plugin name");
|
bail!("invalid plugin name");
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut data: OptData = e.take_data().unwrap_or_default();
|
let mut data: OptData = c.take_data().unwrap_or_default();
|
||||||
|
|
||||||
if let Some(args) = e.named.get("args") {
|
if let Some(args) = c.named.get("args") {
|
||||||
data.args = shell_words::split(args)?
|
data.args = shell_words::split(args)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| ValueSendable::String(s.into_bytes()))
|
.map(|s| ValueSendable::String(s.into_bytes()))
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self { name, sync: e.named.contains_key("sync"), data })
|
Ok(Self { name, sync: c.named.contains_key("sync"), data })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use mlua::{ExternalError, Lua, Table, Value};
|
use mlua::{ExternalError, Lua, Table, Value};
|
||||||
use yazi_shared::{emit, event::Exec, render, Layer};
|
use yazi_shared::{emit, event::Cmd, render, Layer};
|
||||||
|
|
||||||
use super::Utils;
|
use super::Utils;
|
||||||
use crate::ValueSendable;
|
use crate::ValueSendable;
|
||||||
|
|
@ -29,9 +29,9 @@ impl Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn create_exec(cmd: String, table: Table, data: Option<Value>) -> mlua::Result<Exec> {
|
fn create_cmd(name: String, table: Table, data: Option<Value>) -> mlua::Result<Cmd> {
|
||||||
let (args, named) = Self::parse_args(table)?;
|
let (args, named) = Self::parse_args(table)?;
|
||||||
let mut exec = Exec { cmd, args, named, ..Default::default() };
|
let mut exec = Cmd { name, args, named, ..Default::default() };
|
||||||
|
|
||||||
if let Some(data) = data.and_then(|v| ValueSendable::try_from(v).ok()) {
|
if let Some(data) = data.and_then(|v| ValueSendable::try_from(v).ok()) {
|
||||||
exec = exec.with_data(data);
|
exec = exec.with_data(data);
|
||||||
|
|
@ -50,16 +50,16 @@ impl Utils {
|
||||||
|
|
||||||
ya.set(
|
ya.set(
|
||||||
"app_emit",
|
"app_emit",
|
||||||
lua.create_function(|_, (cmd, table, data): (String, Table, Option<Value>)| {
|
lua.create_function(|_, (name, table, data): (String, Table, Option<Value>)| {
|
||||||
emit!(Call(Self::create_exec(cmd, table, data)?, Layer::App));
|
emit!(Call(Self::create_cmd(name, table, data)?, Layer::App));
|
||||||
Ok(())
|
Ok(())
|
||||||
})?,
|
})?,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
ya.set(
|
ya.set(
|
||||||
"manager_emit",
|
"manager_emit",
|
||||||
lua.create_function(|_, (cmd, table, data): (String, Table, Option<Value>)| {
|
lua.create_function(|_, (name, table, data): (String, Table, Option<Value>)| {
|
||||||
emit!(Call(Self::create_exec(cmd, table, data)?, Layer::Manager));
|
emit!(Call(Self::create_cmd(name, table, data)?, Layer::Manager));
|
||||||
Ok(())
|
Ok(())
|
||||||
})?,
|
})?,
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use mlua::{AnyUserData, IntoLuaMulti, Lua, Table, Value};
|
use mlua::{AnyUserData, IntoLuaMulti, Lua, Table, Value};
|
||||||
use yazi_shared::{emit, event::Exec, Layer, PeekError};
|
use yazi_shared::{emit, event::Cmd, Layer, PeekError};
|
||||||
|
|
||||||
use super::Utils;
|
use super::Utils;
|
||||||
use crate::{bindings::{FileRef, Window}, cast_to_renderable, elements::{Paragraph, RectRef, Renderable}, external::{self, Highlighter}};
|
use crate::{bindings::{FileRef, Window}, cast_to_renderable, elements::{Paragraph, RectRef, Renderable}, external::{self, Highlighter}};
|
||||||
|
|
@ -44,7 +44,7 @@ impl Utils {
|
||||||
};
|
};
|
||||||
lock.data = vec![Box::new(Paragraph { area: *area, text, ..Default::default() })];
|
lock.data = vec![Box::new(Paragraph { area: *area, text, ..Default::default() })];
|
||||||
|
|
||||||
emit!(Call(Exec::call("preview", vec![]).with_data(lock), Layer::Manager));
|
emit!(Call(Cmd::new("preview").with_data(lock), Layer::Manager));
|
||||||
(true, Value::Nil).into_lua_multi(lua)
|
(true, Value::Nil).into_lua_multi(lua)
|
||||||
})?,
|
})?,
|
||||||
)?;
|
)?;
|
||||||
|
|
@ -67,7 +67,7 @@ impl Utils {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})];
|
})];
|
||||||
|
|
||||||
emit!(Call(Exec::call("preview", vec![]).with_data(lock), Layer::Manager));
|
emit!(Call(Cmd::new("preview").with_data(lock), Layer::Manager));
|
||||||
(true, Value::Nil).into_lua_multi(lua)
|
(true, Value::Nil).into_lua_multi(lua)
|
||||||
})?,
|
})?,
|
||||||
)?;
|
)?;
|
||||||
|
|
@ -78,7 +78,7 @@ impl Utils {
|
||||||
let mut lock = PreviewLock::try_from(t)?;
|
let mut lock = PreviewLock::try_from(t)?;
|
||||||
lock.data = widgets.into_iter().filter_map(cast_to_renderable).collect();
|
lock.data = widgets.into_iter().filter_map(cast_to_renderable).collect();
|
||||||
|
|
||||||
emit!(Call(Exec::call("preview", vec![]).with_data(lock), Layer::Manager));
|
emit!(Call(Cmd::new("preview").with_data(lock), Layer::Manager));
|
||||||
Ok(())
|
Ok(())
|
||||||
})?,
|
})?,
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ impl Preload {
|
||||||
match op {
|
match op {
|
||||||
PreloadOp::Rule(task) => {
|
PreloadOp::Rule(task) => {
|
||||||
let urls: Vec<_> = task.targets.iter().map(|f| f.url()).collect();
|
let urls: Vec<_> = task.targets.iter().map(|f| f.url()).collect();
|
||||||
let result = isolate::preload(&task.plugin.cmd, task.targets, task.plugin.multi).await;
|
let result = isolate::preload(&task.plugin.name, task.targets, task.plugin.multi).await;
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
self.fail(task.id, format!("Preload task failed:\n{e}"))?;
|
self.fail(task.id, format!("Preload task failed:\n{e}"))?;
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
|
|
@ -39,7 +39,7 @@ impl Preload {
|
||||||
|
|
||||||
let code = result.unwrap();
|
let code = result.unwrap();
|
||||||
if code & 1 == 0 {
|
if code & 1 == 0 {
|
||||||
error!("Preload task `{}` returned {code}", task.plugin.cmd);
|
error!("Preload task `{}` returned {code}", task.plugin.name);
|
||||||
}
|
}
|
||||||
if code >> 1 & 1 != 0 {
|
if code >> 1 & 1 != 0 {
|
||||||
let mut loaded = self.rule_loaded.write();
|
let mut loaded = self.rule_loaded.write();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use parking_lot::Mutex;
|
||||||
use tokio::{fs, select, sync::{mpsc::{self, UnboundedReceiver}, oneshot}};
|
use tokio::{fs, select, sync::{mpsc::{self, UnboundedReceiver}, oneshot}};
|
||||||
use yazi_config::{open::Opener, plugin::PluginRule, TASKS};
|
use yazi_config::{open::Opener, plugin::PluginRule, TASKS};
|
||||||
use yazi_plugin::ValueSendable;
|
use yazi_plugin::ValueSendable;
|
||||||
use yazi_shared::{emit, event::Exec, fs::{unique_path, Url}, Layer, Throttle};
|
use yazi_shared::{emit, event::Cmd, fs::{unique_path, Url}, Layer, Throttle};
|
||||||
|
|
||||||
use super::{Running, TaskProg, TaskStage};
|
use super::{Running, TaskProg, TaskStage};
|
||||||
use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Preload, PreloadOpRule, PreloadOpSize}, process::{Process, ProcessOpOpen}, TaskKind, TaskOp, HIGH, LOW, NORMAL};
|
use crate::{file::{File, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, preload::{Preload, PreloadOpRule, PreloadOpSize}, process::{Process, ProcessOpOpen}, TaskKind, TaskOp, HIGH, LOW, NORMAL};
|
||||||
|
|
@ -165,12 +165,12 @@ impl Scheduler {
|
||||||
|
|
||||||
pub async fn app_stop() {
|
pub async fn app_stop() {
|
||||||
let (tx, rx) = oneshot::channel::<()>();
|
let (tx, rx) = oneshot::channel::<()>();
|
||||||
emit!(Call(Exec::call("stop", vec![]).with_data(tx), Layer::App));
|
emit!(Call(Cmd::new("stop").with_data(tx), Layer::App));
|
||||||
rx.await.ok();
|
rx.await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn app_resume() {
|
pub fn app_resume() {
|
||||||
emit!(Call(Exec::call("resume", vec![]), Layer::App));
|
emit!(Call(Cmd::new("resume"), Layer::App));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_cut(&self, from: Url, mut to: Url, force: bool) {
|
pub fn file_cut(&self, from: Url, mut to: Url, force: bool) {
|
||||||
|
|
@ -307,7 +307,7 @@ impl Scheduler {
|
||||||
pub fn preload_paged(&self, rule: &PluginRule, targets: Vec<&yazi_shared::fs::File>) {
|
pub fn preload_paged(&self, rule: &PluginRule, targets: Vec<&yazi_shared::fs::File>) {
|
||||||
let id = self.running.lock().add(
|
let id = self.running.lock().add(
|
||||||
TaskKind::Preload,
|
TaskKind::Preload,
|
||||||
format!("Run preloader `{}` with {} target(s)", rule.exec.cmd, targets.len()),
|
format!("Run preloader `{}` with {} target(s)", rule.cmd.name, targets.len()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let plugin = rule.into();
|
let plugin = rule.into();
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,20 @@
|
||||||
use std::{any::Any, collections::BTreeMap, fmt::{self, Display}, mem};
|
use std::{any::Any, collections::BTreeMap, fmt::{self, Display}, mem};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Exec {
|
pub struct Cmd {
|
||||||
pub cmd: String,
|
pub name: String,
|
||||||
pub args: Vec<String>,
|
pub args: Vec<String>,
|
||||||
pub named: BTreeMap<String, String>,
|
pub named: BTreeMap<String, String>,
|
||||||
pub data: Option<Box<dyn Any + Send>>,
|
pub data: Option<Box<dyn Any + Send>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Exec {
|
impl Cmd {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn call(cwd: &str, args: Vec<String>) -> Self {
|
pub fn new(name: &str) -> Self { Self { name: name.to_owned(), ..Default::default() } }
|
||||||
Exec { cmd: cwd.to_owned(), args, ..Default::default() }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn call_named(cwd: &str, named: BTreeMap<String, String>) -> Self {
|
pub fn args(name: &str, args: Vec<String>) -> Self {
|
||||||
Exec { cmd: cwd.to_owned(), named, ..Default::default() }
|
Self { name: name.to_owned(), args, ..Default::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
@ -55,17 +53,17 @@ impl Exec {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clone_without_data(&self) -> Self {
|
pub fn clone_without_data(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cmd: self.cmd.clone(),
|
name: self.name.clone(),
|
||||||
args: self.args.clone(),
|
args: self.args.clone(),
|
||||||
named: self.named.clone(),
|
named: self.named.clone(),
|
||||||
..Default::default()
|
data: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Exec {
|
impl Display for Cmd {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.cmd)?;
|
write!(f, "{}", self.name)?;
|
||||||
if !self.args.is_empty() {
|
if !self.args.is_empty() {
|
||||||
write!(f, " {}", self.args.join(" "))?;
|
write!(f, " {}", self.args.join(" "))?;
|
||||||
}
|
}
|
||||||
|
|
@ -3,15 +3,15 @@ use std::{collections::VecDeque, ffi::OsString};
|
||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
|
||||||
use super::Exec;
|
use super::Cmd;
|
||||||
use crate::{term::Term, Layer, RoCell};
|
use crate::{term::Term, Layer, RoCell};
|
||||||
|
|
||||||
static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new();
|
static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new();
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
Call(Exec, Layer),
|
Call(Cmd, Layer),
|
||||||
Seq(VecDeque<Exec>, Layer),
|
Seq(VecDeque<Cmd>, Layer),
|
||||||
Render,
|
Render,
|
||||||
Key(KeyEvent),
|
Key(KeyEvent),
|
||||||
Resize,
|
Resize,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#![allow(clippy::module_inception)]
|
#![allow(clippy::module_inception)]
|
||||||
|
|
||||||
|
mod cmd;
|
||||||
mod event;
|
mod event;
|
||||||
mod exec;
|
|
||||||
mod render;
|
mod render;
|
||||||
|
|
||||||
|
pub use cmd::*;
|
||||||
pub use event::*;
|
pub use event::*;
|
||||||
pub use exec::*;
|
|
||||||
pub use render::*;
|
pub use render::*;
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue