mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-24 00:01:03 +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 yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use super::Key;
|
||||
|
||||
|
|
@ -9,12 +9,13 @@ use super::Key;
|
|||
pub struct Control {
|
||||
pub on: Vec<Key>,
|
||||
#[serde(deserialize_with = "super::exec_deserialize")]
|
||||
pub exec: Vec<Exec>,
|
||||
pub exec: Vec<Cmd>,
|
||||
pub desc: Option<String>,
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
@ -41,3 +42,27 @@ impl Control {
|
|||
|| 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 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
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
struct ExecVisitor;
|
||||
|
||||
fn parse(s: &str) -> Result<Exec> {
|
||||
fn parse(s: &str) -> Result<Cmd> {
|
||||
let s = shell_words::split(s)?;
|
||||
if s.is_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) {
|
||||
if arg.starts_with("--") {
|
||||
let mut arg = arg.splitn(2, '=');
|
||||
let key = arg.next().unwrap().trim_start_matches('-');
|
||||
let val = arg.next().unwrap_or("").to_string();
|
||||
exec.named.insert(key.to_string(), val);
|
||||
cmd.named.insert(key.to_string(), val);
|
||||
} else {
|
||||
exec.args.push(arg);
|
||||
cmd.args.push(arg);
|
||||
}
|
||||
}
|
||||
Ok(exec)
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
impl<'de> Visitor<'de> for ExecVisitor {
|
||||
type Value = Vec<Exec>;
|
||||
type Value = Vec<Cmd>;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("a `exec` string or array of strings within [keymap]")
|
||||
|
|
@ -41,14 +41,14 @@ where
|
|||
where
|
||||
A: de::SeqAccess<'de>,
|
||||
{
|
||||
let mut execs = vec![];
|
||||
let mut cmds = vec![];
|
||||
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"));
|
||||
}
|
||||
Ok(execs)
|
||||
Ok(cmds)
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@ use std::fmt;
|
|||
|
||||
use anyhow::Result;
|
||||
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
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
struct ExecVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for ExecVisitor {
|
||||
type Value = Exec;
|
||||
type Value = Cmd;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("a `exec` string or array of strings")
|
||||
|
|
@ -31,7 +31,7 @@ where
|
|||
if value.is_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 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};
|
||||
|
||||
|
|
@ -18,8 +18,9 @@ pub struct PluginRule {
|
|||
pub cond: Option<Condition>,
|
||||
pub name: Option<Pattern>,
|
||||
pub mime: Option<Pattern>,
|
||||
#[serde(rename = "exec")]
|
||||
#[serde(deserialize_with = "super::exec_deserialize")]
|
||||
pub exec: Exec,
|
||||
pub cmd: Cmd,
|
||||
#[serde(default)]
|
||||
pub sync: bool,
|
||||
#[serde(default)]
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ use crate::Priority;
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct PluginProps {
|
||||
pub id: u8,
|
||||
pub cmd: String,
|
||||
pub name: String,
|
||||
pub multi: bool,
|
||||
pub prio: Priority,
|
||||
}
|
||||
|
||||
impl From<&PluginRule> for PluginProps {
|
||||
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;
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
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};
|
||||
|
||||
|
|
@ -6,14 +6,14 @@ pub struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.named.contains_key("submit") } }
|
||||
}
|
||||
|
||||
impl Completion {
|
||||
#[inline]
|
||||
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>) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{mem, ops::ControlFlow};
|
||||
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -13,13 +13,13 @@ pub struct Opt {
|
|||
ticket: usize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
cache: mem::take(&mut e.args),
|
||||
cache_name: e.take_name("cache-name").unwrap_or_default(),
|
||||
word: e.take_name("word").unwrap_or_default(),
|
||||
ticket: e.take_name("ticket").and_then(|v| v.parse().ok()).unwrap_or(0),
|
||||
cache: mem::take(&mut c.args),
|
||||
cache_name: c.take_name("cache-name").unwrap_or_default(),
|
||||
word: c.take_name("word").unwrap_or_default(),
|
||||
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 tokio::fs;
|
||||
use yazi_shared::{emit, event::Exec, render, Layer};
|
||||
use yazi_shared::{emit, event::Cmd, render, Layer};
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ pub struct Opt {
|
|||
ticket: usize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
word: e.take_first().unwrap_or_default(),
|
||||
ticket: e.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
word: c.take_first().unwrap_or_default(),
|
||||
ticket: c.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ impl Completion {
|
|||
#[inline]
|
||||
pub fn _trigger(word: &str, ticket: usize) {
|
||||
emit!(Call(
|
||||
Exec::call("trigger", vec![word.to_owned()]).with("ticket", ticket),
|
||||
Cmd::args("trigger", vec![word.to_owned()]).with("ticket", ticket),
|
||||
Layer::Completion
|
||||
));
|
||||
}
|
||||
|
|
@ -39,10 +39,7 @@ impl Completion {
|
|||
|
||||
if self.caches.contains_key(&parent) {
|
||||
return self.show(
|
||||
Exec::call("show", vec![])
|
||||
.with("cache-name", parent)
|
||||
.with("word", child)
|
||||
.with("ticket", opt.ticket),
|
||||
Cmd::new("show").with("cache-name", parent).with("word", child).with("ticket", opt.ticket),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +61,7 @@ impl Completion {
|
|||
|
||||
if !cache.is_empty() {
|
||||
emit!(Call(
|
||||
Exec::call("show", cache)
|
||||
Cmd::args("show", cache)
|
||||
.with("cache-name", parent)
|
||||
.with("word", child)
|
||||
.with("ticket", ticket),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::{ffi::OsStr, ops::Range};
|
|||
|
||||
use anyhow::Result;
|
||||
use regex::bytes::{Regex, RegexBuilder};
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
pub struct Filter {
|
||||
raw: String,
|
||||
|
|
@ -43,9 +43,9 @@ pub enum FilterCase {
|
|||
Insensitive,
|
||||
}
|
||||
|
||||
impl From<&Exec> for FilterCase {
|
||||
fn from(e: &Exec) -> Self {
|
||||
match (e.named.contains_key("smart"), e.named.contains_key("insensitive")) {
|
||||
impl From<&Cmd> for FilterCase {
|
||||
fn from(c: &Cmd) -> Self {
|
||||
match (c.named.contains_key("smart"), c.named.contains_key("insensitive")) {
|
||||
(true, _) => Self::Smart,
|
||||
(_, false) => Self::Sensitive,
|
||||
(_, true) => Self::Insensitive,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::help::Help;
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
impl Help {
|
||||
pub fn escape(&mut self, _: Exec) {
|
||||
pub fn escape(&mut self, _: Cmd) {
|
||||
if self.in_filter.is_none() {
|
||||
return self.toggle(self.layer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
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};
|
||||
|
||||
impl Help {
|
||||
pub fn filter(&mut self, _: Exec) {
|
||||
pub fn filter(&mut self, _: Cmd) {
|
||||
let mut input = Input::default();
|
||||
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;
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
|||
under: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { under: e.named.contains_key("under") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { under: c.named.contains_key("under") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
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;
|
||||
|
||||
impl Input {
|
||||
pub fn backward(&mut self, _: Exec) {
|
||||
pub fn backward(&mut self, _: Cmd) {
|
||||
let snap = self.snap();
|
||||
if snap.cursor == 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};
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.named.contains_key("submit") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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;
|
||||
|
||||
|
|
@ -9,11 +9,11 @@ pub struct Opt {
|
|||
ticket: usize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
word: e.take_first().unwrap_or_default(),
|
||||
ticket: e.take_name("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
word: c.take_first().unwrap_or_default(),
|
||||
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 {
|
||||
#[inline]
|
||||
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>) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::input::{op::InputOp, Input};
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ pub struct Opt {
|
|||
insert: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
Self { cut: e.named.contains_key("cut"), insert: e.named.contains_key("insert") }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
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}};
|
||||
|
||||
pub struct Opt;
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
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};
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
|||
end_of_word: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { end_of_word: e.named.contains_key("end-of-word") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { end_of_word: c.named.contains_key("end-of-word") } }
|
||||
}
|
||||
|
||||
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};
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
|||
append: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { append: e.named.contains_key("append") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { append: c.named.contains_key("append") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(append: bool) -> Self { Self { append } }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::RangeBounds;
|
||||
|
||||
use yazi_shared::{event::Exec, render, CharKind};
|
||||
use yazi_shared::{event::Cmd, render, CharKind};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
|||
kind: String,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self { Self { kind: e.take_first().unwrap_or_default() } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { kind: c.take_first().unwrap_or_default() } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use unicode_width::UnicodeWidthStr;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::input::{op::InputOp, snap::InputSnap, Input};
|
||||
|
||||
|
|
@ -8,11 +8,11 @@ pub struct Opt {
|
|||
in_operating: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
in_operating: e.named.contains_key("in-operating"),
|
||||
step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
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};
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
|||
before: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { before: e.named.contains_key("before") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { before: c.named.contains_key("before") } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
impl Input {
|
||||
pub fn redo(&mut self, _: Exec) {
|
||||
pub fn redo(&mut self, _: Cmd) {
|
||||
render!(self.snaps.redo());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use tokio::sync::mpsc;
|
||||
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;
|
||||
|
||||
|
|
@ -9,16 +9,16 @@ pub struct Opt {
|
|||
tx: mpsc::UnboundedSender<Result<String, InputError>>,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
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 {
|
||||
pub fn _show(cfg: InputCfg) -> mpsc::UnboundedReceiver<Result<String, InputError>> {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use yazi_config::keymap::Key;
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::input::{Input, InputMode};
|
||||
|
||||
pub struct Opt;
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::input::{Input, InputMode};
|
||||
|
||||
impl Input {
|
||||
pub fn undo(&mut self, _: Exec) {
|
||||
pub fn undo(&mut self, _: Cmd) {
|
||||
if !self.snaps.undo() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::input::{op::InputOp, Input, InputMode};
|
||||
|
||||
impl Input {
|
||||
#[inline]
|
||||
pub fn visual(&mut self, _: Exec) {
|
||||
pub fn visual(&mut self, _: Cmd) {
|
||||
let snap = self.snap_mut();
|
||||
if snap.mode != InputMode::Normal {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::input::{op::InputOp, Input};
|
||||
|
||||
impl Input {
|
||||
pub fn yank(&mut self, _: Exec) {
|
||||
pub fn yank(&mut self, _: Cmd) {
|
||||
match self.snap().op {
|
||||
InputOp::None => {
|
||||
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};
|
||||
|
||||
impl Manager {
|
||||
pub fn close(&mut self, _: Exec, tasks: &Tasks) {
|
||||
pub fn close(&mut self, _: Cmd, tasks: &Tasks) {
|
||||
if self.tabs.len() > 1 {
|
||||
return self.tabs.close(self.tabs.idx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::path::{PathBuf, MAIN_SEPARATOR};
|
|||
|
||||
use tokio::fs;
|
||||
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};
|
||||
|
||||
|
|
@ -10,8 +10,8 @@ pub struct Opt {
|
|||
force: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { force: e.named.contains_key("force") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { force: c.named.contains_key("force") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
|||
url: Option<Url>,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self { Self { url: e.take_first().map(Url::from) } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { url: c.take_first().map(Url::from) } }
|
||||
}
|
||||
impl From<Option<Url>> for Opt {
|
||||
fn from(url: Option<Url>) -> Self { Self { url } }
|
||||
|
|
@ -19,7 +19,7 @@ impl Manager {
|
|||
#[inline]
|
||||
pub fn _hover(url: Option<Url>) {
|
||||
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
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ pub struct Opt {
|
|||
force: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
Self { relative: e.named.contains_key("relative"), force: e.named.contains_key("force") }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
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 yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
||||
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};
|
||||
|
||||
|
|
@ -12,11 +12,11 @@ pub struct Opt {
|
|||
interactive: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
targets: e.take_data().unwrap_or_default(),
|
||||
interactive: e.named.contains_key("interactive"),
|
||||
targets: c.take_data().unwrap_or_default(),
|
||||
interactive: c.named.contains_key("interactive"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ impl Manager {
|
|||
#[inline]
|
||||
pub fn _open_do(interactive: bool, targets: Vec<(Url, Option<String>)>) {
|
||||
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
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ pub struct Opt {
|
|||
follow: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
Self { force: e.named.contains_key("force"), follow: e.named.contains_key("follow") }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
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;
|
||||
|
||||
|
|
@ -10,13 +10,13 @@ pub struct Opt {
|
|||
upper_bound: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
skip: e.take_first().and_then(|s| s.parse().ok()),
|
||||
force: e.named.contains_key("force"),
|
||||
only_if: e.take_name("only-if").map(Url::from),
|
||||
upper_bound: e.named.contains_key("upper-bound"),
|
||||
skip: c.take_first().and_then(|s| s.parse().ok()),
|
||||
force: c.named.contains_key("force"),
|
||||
only_if: c.take_name("only-if").map(Url::from),
|
||||
upper_bound: c.named.contains_key("upper-bound"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ impl From<bool> for Opt {
|
|||
impl Manager {
|
||||
#[inline]
|
||||
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>) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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};
|
||||
|
||||
|
|
@ -10,8 +10,8 @@ pub struct Opt {
|
|||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self::default() }
|
||||
}
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { no_cwd_file: e.named.contains_key("no-cwd-file") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { no_cwd_file: c.named.contains_key("no-cwd-file") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
use std::env;
|
||||
|
||||
use yazi_shared::{emit, event::Exec, Layer};
|
||||
use yazi_shared::{emit, event::Cmd, Layer};
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
impl Manager {
|
||||
#[inline]
|
||||
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_var("PWD", self.cwd());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -7,11 +7,11 @@ pub struct Opt {
|
|||
permanently: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
Self {
|
||||
force: e.named.contains_key("force"),
|
||||
permanently: e.named.contains_key("permanently"),
|
||||
force: c.named.contains_key("force"),
|
||||
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_plugin::external::{self, ShellOpt};
|
||||
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};
|
||||
|
||||
|
|
@ -15,12 +15,12 @@ pub struct Opt {
|
|||
cursor: String,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
force: e.named.contains_key("force"),
|
||||
empty: e.take_name("empty").unwrap_or_default(),
|
||||
cursor: e.take_name("cursor").unwrap_or_default(),
|
||||
force: c.named.contains_key("force"),
|
||||
empty: c.take_name("empty").unwrap_or_default(),
|
||||
cursor: c.take_name("cursor").unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_config::PLUGIN;
|
||||
use yazi_plugin::isolate;
|
||||
use yazi_shared::{event::Exec, render, MIME_DIR};
|
||||
use yazi_shared::{event::Cmd, render, MIME_DIR};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -9,9 +9,9 @@ pub struct Opt {
|
|||
units: i16,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { units: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
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;
|
||||
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_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
impl Manager {
|
||||
pub fn suspend(&mut self, _: Exec) {
|
||||
pub fn suspend(&mut self, _: Cmd) {
|
||||
#[cfg(unix)]
|
||||
tokio::spawn(async move {
|
||||
Scheduler::app_stop().await;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::manager::Tabs;
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
idx: usize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { idx: e.take_first().and_then(|i| i.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
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};
|
||||
|
||||
|
|
@ -9,12 +9,12 @@ pub struct Opt {
|
|||
current: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
let mut opt = Self { url: None, current: e.named.contains_key("current") };
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
let mut opt = Self { url: None, current: c.named.contains_key("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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::manager::Tabs;
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
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;
|
||||
|
||||
|
|
@ -7,11 +7,11 @@ pub struct Opt {
|
|||
relative: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
relative: e.named.contains_key("relative"),
|
||||
step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0),
|
||||
relative: c.named.contains_key("relative"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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};
|
||||
|
||||
|
|
@ -8,12 +8,10 @@ pub struct Opt {
|
|||
op: FilesOp,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
||||
Ok(Self { op: e.take_data().ok_or(())? })
|
||||
}
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> { Ok(Self { op: c.take_data().ok_or(())? }) }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
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};
|
||||
|
||||
|
|
@ -9,11 +9,11 @@ pub struct Opt {
|
|||
data: ValueSendable,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
||||
Ok(Self { data: e.take_data().ok_or(())? })
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
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};
|
||||
|
||||
|
|
@ -8,11 +8,11 @@ pub struct Opt {
|
|||
only_if: Option<Url>,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
page: e.take_first().and_then(|s| s.parse().ok()),
|
||||
only_if: e.take_name("only-if").map(Url::from),
|
||||
page: c.take_first().and_then(|s| s.parse().ok()),
|
||||
only_if: c.take_name("only-if").map(Url::from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,13 +24,13 @@ impl From<()> for Opt {
|
|||
impl Manager {
|
||||
#[inline]
|
||||
pub fn _update_paged() {
|
||||
emit!(Call(Exec::call("update_paged", vec![]), Layer::Manager));
|
||||
emit!(Call(Cmd::new("update_paged"), Layer::Manager));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn _update_paged_by(page: usize, only_if: &Url) {
|
||||
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
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt {
|
|||
cut: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { cut: e.named.contains_key("cut") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { cut: c.named.contains_key("cut") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::select::Select;
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self { step: c.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::anyhow;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::select::Select;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ pub struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { submit: e.named.contains_key("submit") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.named.contains_key("submit") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
use tokio::sync::oneshot;
|
||||
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;
|
||||
|
||||
|
|
@ -10,16 +10,16 @@ pub struct Opt {
|
|||
tx: oneshot::Sender<Result<usize>>,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
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 {
|
||||
pub async fn _show(cfg: SelectCfg) -> Result<usize> {
|
||||
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))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::{manager::Manager, tab::Tab, Step};
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
step: Step,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or_default() }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
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;
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub struct Opt;
|
|||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
}
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::{mem, time::Duration};
|
|||
use tokio::{fs, pin};
|
||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
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};
|
||||
|
||||
|
|
@ -12,14 +12,14 @@ pub struct Opt {
|
|||
interactive: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
let mut target = Url::from(e.take_first().unwrap_or_default());
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
let mut target = Url::from(c.take_first().unwrap_or_default());
|
||||
if target.is_regular() {
|
||||
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 {
|
||||
|
|
@ -29,7 +29,7 @@ impl From<Url> for Opt {
|
|||
impl Tab {
|
||||
#[inline]
|
||||
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>) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ffi::{OsStr, OsString};
|
||||
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{tab::Tab, CLIPBOARD};
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
|||
type_: String,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self { Self { type_: e.take_first().unwrap_or_default() } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { type_: c.take_first().unwrap_or_default() } }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::mem;
|
||||
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::{manager::Manager, tab::Tab};
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ pub struct Opt;
|
|||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
}
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use bitflags::bitflags;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::tab::{Mode, Tab};
|
||||
|
||||
|
|
@ -13,9 +13,9 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
e.named.iter().fold(Opt::empty(), |acc, (k, _)| match k.as_str() {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
c.named.iter().fold(Opt::empty(), |acc, (k, _)| match k.as_str() {
|
||||
"all" => Self::all(),
|
||||
"find" => acc | Self::FIND,
|
||||
"visual" => acc | Self::VISUAL,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
|||
use tokio::pin;
|
||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
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};
|
||||
|
||||
|
|
@ -14,12 +14,12 @@ pub struct Opt {
|
|||
pub done: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
query: e.take_first().unwrap_or_default(),
|
||||
case: FilterCase::from(&e),
|
||||
done: e.named.contains_key("done"),
|
||||
query: c.take_first().unwrap_or_default(),
|
||||
case: FilterCase::from(&c),
|
||||
done: c.named.contains_key("done"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ impl Tab {
|
|||
};
|
||||
|
||||
emit!(Call(
|
||||
Exec::call("filter_do", vec![s])
|
||||
Cmd::args("filter_do", vec![s])
|
||||
.with_bool("smart", opt.case == FilterCase::Smart)
|
||||
.with_bool("insensitive", opt.case == FilterCase::Insensitive)
|
||||
.with_bool("done", done),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
|||
use tokio::pin;
|
||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
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}};
|
||||
|
||||
|
|
@ -13,12 +13,12 @@ pub struct Opt {
|
|||
case: FilterCase,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
query: e.take_first(),
|
||||
prev: e.named.contains_key("previous"),
|
||||
case: FilterCase::from(&e),
|
||||
query: c.take_first(),
|
||||
prev: c.named.contains_key("previous"),
|
||||
case: FilterCase::from(&c),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,8 +27,8 @@ pub struct ArrowOpt {
|
|||
prev: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for ArrowOpt {
|
||||
fn from(e: Exec) -> Self { Self { prev: e.named.contains_key("previous") } }
|
||||
impl From<Cmd> for ArrowOpt {
|
||||
fn from(c: Cmd) -> Self { Self { prev: c.named.contains_key("previous") } }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
@ -42,7 +42,7 @@ impl Tab {
|
|||
|
||||
while let Some(Ok(s)) | Some(Err(InputError::Typed(s))) = rx.next().await {
|
||||
emit!(Call(
|
||||
Exec::call("find_do", vec![s])
|
||||
Cmd::args("find_do", vec![s])
|
||||
.with_bool("previous", opt.prev)
|
||||
.with_bool("smart", opt.case == FilterCase::Smart)
|
||||
.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};
|
||||
|
||||
impl Tab {
|
||||
pub fn hidden(&mut self, e: Exec) {
|
||||
self.conf.show_hidden = match e.args.first().map(|s| s.as_str()) {
|
||||
pub fn hidden(&mut self, c: Cmd) {
|
||||
self.conf.show_hidden = match c.args.first().map(|s| s.as_str()) {
|
||||
Some("show") => true,
|
||||
Some("hide") => false,
|
||||
_ => !self.conf.show_hidden,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_plugin::external::{self, FzfOpt, ZoxideOpt};
|
||||
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;
|
||||
|
||||
|
|
@ -15,10 +15,10 @@ pub enum OptType {
|
|||
Zoxide,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> 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("zoxide") => OptType::Zoxide,
|
||||
_ => OptType::None,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::mem;
|
||||
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::{manager::Manager, tab::Tab};
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ pub struct Opt;
|
|||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
}
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn linemode(&mut self, mut e: Exec) {
|
||||
render!(self.conf.patch(|c| {
|
||||
let Some(mode) = e.take_first() else {
|
||||
pub fn linemode(&mut self, mut c: Cmd) {
|
||||
render!(self.conf.patch(|new| {
|
||||
let Some(mode) = c.take_first() else {
|
||||
return;
|
||||
};
|
||||
if !mode.is_empty() && mode.len() <= 20 {
|
||||
c.linemode = mode;
|
||||
new.linemode = mode;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_plugin::utils::PreviewLock;
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -7,11 +7,11 @@ pub struct Opt {
|
|||
lock: PreviewLock,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
||||
Ok(Self { lock: e.take_data().ok_or(())? })
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
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};
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
target: Url,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
let mut target = Url::from(e.take_first().unwrap_or_default());
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
let mut target = Url::from(c.take_first().unwrap_or_default());
|
||||
if target.is_regular() {
|
||||
target.set_path(expand_path(&target))
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ impl From<Url> for Opt {
|
|||
impl Tab {
|
||||
#[inline]
|
||||
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>) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use tokio::pin;
|
|||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
use yazi_config::popup::InputCfg;
|
||||
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};
|
||||
|
||||
|
|
@ -41,8 +41,8 @@ pub struct Opt {
|
|||
pub type_: OptType,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self { Self { type_: e.take_first().unwrap_or_default().into() } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { type_: c.take_first().unwrap_or_default().into() } }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -6,10 +6,10 @@ pub struct Opt {
|
|||
state: Option<bool>,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> 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("false") => Some(false),
|
||||
_ => None,
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
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};
|
||||
|
||||
pub struct Opt {
|
||||
cmd: String,
|
||||
exec: String,
|
||||
block: bool,
|
||||
confirm: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
cmd: e.take_first().unwrap_or_default(),
|
||||
block: e.named.contains_key("block"),
|
||||
confirm: e.named.contains_key("confirm"),
|
||||
exec: c.take_first().unwrap_or_default(),
|
||||
block: c.named.contains_key("block"),
|
||||
confirm: c.named.contains_key("confirm"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,16 +25,16 @@ impl Tab {
|
|||
let selected: Vec<_> = self.selected().into_iter().map(|f| f.url()).collect();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if !opt.confirm || opt.cmd.is_empty() {
|
||||
let mut result = Input::_show(InputCfg::shell(opt.block).with_value(opt.cmd));
|
||||
if !opt.confirm || opt.exec.is_empty() {
|
||||
let mut result = Input::_show(InputCfg::shell(opt.block).with_value(opt.exec));
|
||||
match result.recv().await {
|
||||
Some(Ok(e)) => opt.cmd = e,
|
||||
Some(Ok(e)) => opt.exec = e,
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
|
||||
Tasks::_open(selected, Opener {
|
||||
exec: opt.cmd,
|
||||
exec: opt.exec,
|
||||
block: opt.block,
|
||||
orphan: false,
|
||||
desc: Default::default(),
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use yazi_config::manager::SortBy;
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{manager::Manager, tab::Tab, tasks::Tasks};
|
||||
|
||||
impl Tab {
|
||||
pub fn sort(&mut self, e: Exec, tasks: &Tasks) {
|
||||
if let Some(by) = e.args.first() {
|
||||
pub fn sort(&mut self, c: Cmd, tasks: &Tasks) {
|
||||
if let Some(by) = c.args.first() {
|
||||
self.conf.sort_by = SortBy::from_str(by).unwrap_or_default();
|
||||
}
|
||||
self.conf.sort_sensitive = e.named.contains_key("sensitive");
|
||||
self.conf.sort_reverse = e.named.contains_key("reverse");
|
||||
self.conf.sort_dir_first = e.named.contains_key("dir-first");
|
||||
self.conf.sort_sensitive = c.named.contains_key("sensitive");
|
||||
self.conf.sort_reverse = c.named.contains_key("reverse");
|
||||
self.conf.sort_dir_first = c.named.contains_key("dir-first");
|
||||
|
||||
self.apply_files_attrs();
|
||||
Manager::_update_paged();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::collections::BTreeSet;
|
||||
|
||||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::tab::{Mode, Tab};
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ pub struct Opt {
|
|||
unset: bool,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(e: Exec) -> Self { Self { unset: e.named.contains_key("unset") } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { unset: c.named.contains_key("unset") } }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ impl Preview {
|
|||
|
||||
self.abort();
|
||||
if previewer.sync {
|
||||
isolate::peek_sync(&previewer.exec, file, self.skip);
|
||||
isolate::peek_sync(&previewer.cmd, file, self.skip);
|
||||
} 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;
|
||||
|
||||
|
|
@ -6,9 +6,9 @@ pub struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self {
|
||||
Self { step: e.take_first().and_then(|s| s.parse().ok()).unwrap_or(0) }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
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;
|
||||
|
||||
impl Tasks {
|
||||
pub fn cancel(&mut self, _: Exec) {
|
||||
pub fn cancel(&mut self, _: Cmd) {
|
||||
let id = self.scheduler.running.lock().get_id(self.cursor);
|
||||
if id.map(|id| self.scheduler.cancel(id)) != Some(true) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ use std::io::{stdout, Write};
|
|||
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
|
||||
use tokio::{io::{stdin, AsyncReadExt}, select, sync::mpsc, time};
|
||||
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;
|
||||
|
||||
impl Tasks {
|
||||
pub fn inspect(&self, _: Exec) {
|
||||
pub fn inspect(&self, _: Cmd) {
|
||||
let Some(id) = self.scheduler.running.lock().get_id(self.cursor) else {
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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;
|
||||
|
||||
|
|
@ -8,15 +8,15 @@ pub struct Opt {
|
|||
opener: Opener,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
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 {
|
||||
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>) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use yazi_shared::{event::Exec, render};
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::tasks::Tasks;
|
||||
|
||||
pub struct Opt;
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
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_plugin::ValueSendable;
|
||||
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 crate::{folder::Files, input::Input};
|
||||
|
|
@ -36,7 +36,7 @@ impl Tasks {
|
|||
let new = TasksProgress::from(&*running.lock());
|
||||
if 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, Key}, KEYMAP};
|
||||
use yazi_config::{keymap::{Control, ControlCow, Key}, KEYMAP};
|
||||
use yazi_shared::{emit, render, Layer};
|
||||
|
||||
pub struct Which {
|
||||
layer: Layer,
|
||||
pub times: usize,
|
||||
pub cands: Vec<&'static Control>,
|
||||
pub cands: Vec<ControlCow>,
|
||||
|
||||
pub visible: bool,
|
||||
}
|
||||
|
|
@ -21,16 +19,28 @@ impl Which {
|
|||
pub fn show(&mut self, key: &Key, layer: Layer) {
|
||||
self.layer = layer;
|
||||
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;
|
||||
render!();
|
||||
}
|
||||
|
||||
pub fn type_(&mut self, key: Key) -> bool {
|
||||
self.cands = mem::take(&mut self.cands)
|
||||
.into_iter()
|
||||
.filter(|s| s.on.len() > self.times && s.on[self.times] == key)
|
||||
.collect();
|
||||
self.cands.retain(|c| c.on.len() > self.times && c.on[self.times] == key);
|
||||
|
||||
if self.cands.is_empty() {
|
||||
self.visible = false;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
|||
use crossterm::event::KeyEvent;
|
||||
use yazi_config::keymap::Key;
|
||||
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};
|
||||
|
||||
|
|
@ -66,12 +66,10 @@ impl App {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn dispatch_call(&mut self, exec: Exec, layer: Layer) {
|
||||
Executor::new(self).execute(exec, layer);
|
||||
}
|
||||
fn dispatch_call(&mut self, cmd: Cmd, layer: Layer) { Executor::new(self).execute(cmd, layer); }
|
||||
|
||||
#[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() {
|
||||
Executor::new(self).execute(exec, layer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::fmt::Display;
|
|||
use mlua::{ExternalError, ExternalResult, IntoLua, Table, TableExt, Variadic};
|
||||
use tracing::warn;
|
||||
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};
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ impl App {
|
|||
|
||||
tokio::spawn(async move {
|
||||
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;
|
||||
|
||||
pub struct Opt;
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(_: Exec) -> Self { Self }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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.term = Some(Term::start().unwrap());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use tokio::sync::oneshot;
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ pub struct Opt {
|
|||
tx: Option<oneshot::Sender<()>>,
|
||||
}
|
||||
|
||||
impl From<Exec> for Opt {
|
||||
fn from(mut e: Exec) -> Self { Self { tx: e.take_data() } }
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { tx: c.take_data() } }
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use ratatui::backend::Backend;
|
||||
use yazi_core::tasks::TasksProgress;
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::{app::App, components::Progress, lives::Lives};
|
||||
|
||||
|
|
@ -8,11 +8,11 @@ pub struct Opt {
|
|||
progress: TasksProgress,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
||||
Ok(Self { progress: e.take_data().ok_or(())? })
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
Ok(Self { progress: c.take_data().ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_core::input::InputMode;
|
||||
use yazi_shared::{event::Exec, Layer};
|
||||
use yazi_shared::{event::Cmd, Layer};
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
|
|
@ -12,24 +12,24 @@ impl<'a> Executor<'a> {
|
|||
pub(super) fn new(app: &'a mut App) -> Self { Self { app } }
|
||||
|
||||
#[inline]
|
||||
pub(super) fn execute(&mut self, exec: Exec, layer: Layer) {
|
||||
pub(super) fn execute(&mut self, cmd: Cmd, layer: Layer) {
|
||||
match layer {
|
||||
Layer::App => self.app(exec),
|
||||
Layer::Manager => self.manager(exec),
|
||||
Layer::Tasks => self.tasks(exec),
|
||||
Layer::Select => self.select(exec),
|
||||
Layer::Input => self.input(exec),
|
||||
Layer::Help => self.help(exec),
|
||||
Layer::Completion => self.completion(exec),
|
||||
Layer::App => self.app(cmd),
|
||||
Layer::Manager => self.manager(cmd),
|
||||
Layer::Tasks => self.tasks(cmd),
|
||||
Layer::Select => self.select(cmd),
|
||||
Layer::Input => self.input(cmd),
|
||||
Layer::Help => self.help(cmd),
|
||||
Layer::Completion => self.completion(cmd),
|
||||
Layer::Which => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn app(&mut self, exec: Exec) {
|
||||
fn app(&mut self, cmd: Cmd) {
|
||||
macro_rules! on {
|
||||
($name:ident) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.$name(exec);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -42,21 +42,21 @@ impl<'a> Executor<'a> {
|
|||
on!(resume);
|
||||
}
|
||||
|
||||
fn manager(&mut self, exec: Exec) {
|
||||
fn manager(&mut self, cmd: Cmd) {
|
||||
macro_rules! on {
|
||||
(MANAGER, $name:ident $(,$args:expr)*) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.manager.$name(exec, $($args),*);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.manager.$name(cmd, $($args),*);
|
||||
}
|
||||
};
|
||||
(ACTIVE, $name:ident $(,$args:expr)*) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.manager.active_mut().$name(exec, $($args),*);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.manager.active_mut().$name(cmd, $($args),*);
|
||||
}
|
||||
};
|
||||
(TABS, $name:ident) => {
|
||||
if exec.cmd == concat!("tab_", stringify!($name)) {
|
||||
return self.app.cx.manager.tabs.$name(exec);
|
||||
if cmd.name == concat!("tab_", stringify!($name)) {
|
||||
return self.app.cx.manager.tabs.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -122,27 +122,27 @@ impl<'a> Executor<'a> {
|
|||
on!(TABS, switch);
|
||||
on!(TABS, swap);
|
||||
|
||||
match exec.cmd.as_bytes() {
|
||||
match cmd.name.as_bytes() {
|
||||
// Tasks
|
||||
b"tasks_show" => self.app.cx.tasks.toggle(()),
|
||||
// Help
|
||||
b"help" => self.app.cx.help.toggle(Layer::Manager),
|
||||
// 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 {
|
||||
($name:ident) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.tasks.$name(exec);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.tasks.$name(cmd);
|
||||
}
|
||||
};
|
||||
($name:ident, $alias:literal) => {
|
||||
if exec.cmd == $alias {
|
||||
return self.app.cx.tasks.$name(exec);
|
||||
if cmd.name == $alias {
|
||||
return self.app.cx.tasks.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -154,17 +154,17 @@ impl<'a> Executor<'a> {
|
|||
on!(cancel);
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match exec.cmd.as_str() {
|
||||
match cmd.name.as_str() {
|
||||
"help" => self.app.cx.help.toggle(Layer::Tasks),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn select(&mut self, exec: Exec) {
|
||||
fn select(&mut self, cmd: Cmd) {
|
||||
macro_rules! on {
|
||||
($name:ident) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.select.$name(exec);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.select.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -174,22 +174,22 @@ impl<'a> Executor<'a> {
|
|||
on!(arrow);
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match exec.cmd.as_str() {
|
||||
match cmd.name.as_str() {
|
||||
"help" => self.app.cx.help.toggle(Layer::Select),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn input(&mut self, exec: Exec) {
|
||||
fn input(&mut self, cmd: Cmd) {
|
||||
macro_rules! on {
|
||||
($name:ident) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.input.$name(exec);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.input.$name(cmd);
|
||||
}
|
||||
};
|
||||
($name:ident, $alias:literal) => {
|
||||
if exec.cmd == $alias {
|
||||
return self.app.cx.input.$name(exec);
|
||||
if cmd.name == $alias {
|
||||
return self.app.cx.input.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -201,11 +201,11 @@ impl<'a> Executor<'a> {
|
|||
on!(backward);
|
||||
on!(forward);
|
||||
|
||||
if exec.cmd.as_str() == "complete" {
|
||||
return if exec.named.contains_key("trigger") {
|
||||
self.app.cx.completion.trigger(exec)
|
||||
if cmd.name.as_str() == "complete" {
|
||||
return if cmd.named.contains_key("trigger") {
|
||||
self.app.cx.completion.trigger(cmd)
|
||||
} else {
|
||||
self.app.cx.input.complete(exec)
|
||||
self.app.cx.input.complete(cmd)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ impl<'a> Executor<'a> {
|
|||
on!(redo);
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match exec.cmd.as_str() {
|
||||
match cmd.name.as_str() {
|
||||
"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 {
|
||||
($name:ident) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.help.$name(exec);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.help.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -248,17 +248,17 @@ impl<'a> Executor<'a> {
|
|||
on!(filter);
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match exec.cmd.as_str() {
|
||||
match cmd.name.as_str() {
|
||||
"close" => self.app.cx.help.toggle(Layer::Help),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn completion(&mut self, exec: Exec) {
|
||||
fn completion(&mut self, cmd: Cmd) {
|
||||
macro_rules! on {
|
||||
($name:ident) => {
|
||||
if exec.cmd == stringify!($name) {
|
||||
return self.app.cx.completion.$name(exec);
|
||||
if cmd.name == stringify!($name) {
|
||||
return self.app.cx.completion.$name(cmd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -269,9 +269,9 @@ impl<'a> Executor<'a> {
|
|||
on!(arrow);
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match exec.cmd.as_str() {
|
||||
match cmd.name.as_str() {
|
||||
"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 (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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@ use tokio::{runtime::Handle, select};
|
|||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::error;
|
||||
use yazi_config::LAYOUT;
|
||||
use yazi_shared::{emit, event::Exec, Layer};
|
||||
use yazi_shared::{emit, event::Cmd, Layer};
|
||||
|
||||
use super::slim_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 cmd = exec.cmd.to_owned();
|
||||
let name = cmd.name.to_owned();
|
||||
let (ct1, ct2) = (ct.clone(), ct.clone());
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let future = async {
|
||||
LOADED.ensure(&cmd).await.into_lua_err()?;
|
||||
LOADED.ensure(&name).await.into_lua_err()?;
|
||||
|
||||
let lua = slim_lua()?;
|
||||
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(())?
|
||||
} else {
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
args: vec![],
|
||||
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,
|
||||
};
|
||||
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
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use mlua::TableExt;
|
||||
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};
|
||||
|
||||
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 {
|
||||
args: vec![],
|
||||
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,
|
||||
};
|
||||
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
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{Table, Value};
|
||||
use tokio::sync::oneshot;
|
||||
use yazi_shared::event::Exec;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use crate::ValueSendable;
|
||||
|
||||
|
|
@ -18,23 +18,23 @@ pub struct OptData {
|
|||
pub tx: Option<oneshot::Sender<ValueSendable>>,
|
||||
}
|
||||
|
||||
impl TryFrom<Exec> for Opt {
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(mut e: Exec) -> Result<Self, Self::Error> {
|
||||
let Some(name) = e.take_first().filter(|s| !s.is_empty()) else {
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
let Some(name) = c.take_first().filter(|s| !s.is_empty()) else {
|
||||
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)?
|
||||
.into_iter()
|
||||
.map(|s| ValueSendable::String(s.into_bytes()))
|
||||
.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 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 crate::ValueSendable;
|
||||
|
|
@ -29,9 +29,9 @@ impl Utils {
|
|||
}
|
||||
|
||||
#[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 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()) {
|
||||
exec = exec.with_data(data);
|
||||
|
|
@ -50,16 +50,16 @@ impl Utils {
|
|||
|
||||
ya.set(
|
||||
"app_emit",
|
||||
lua.create_function(|_, (cmd, table, data): (String, Table, Option<Value>)| {
|
||||
emit!(Call(Self::create_exec(cmd, table, data)?, Layer::App));
|
||||
lua.create_function(|_, (name, table, data): (String, Table, Option<Value>)| {
|
||||
emit!(Call(Self::create_cmd(name, table, data)?, Layer::App));
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
|
||||
ya.set(
|
||||
"manager_emit",
|
||||
lua.create_function(|_, (cmd, table, data): (String, Table, Option<Value>)| {
|
||||
emit!(Call(Self::create_exec(cmd, table, data)?, Layer::Manager));
|
||||
lua.create_function(|_, (name, table, data): (String, Table, Option<Value>)| {
|
||||
emit!(Call(Self::create_cmd(name, table, data)?, Layer::Manager));
|
||||
Ok(())
|
||||
})?,
|
||||
)?;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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 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() })];
|
||||
|
||||
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)
|
||||
})?,
|
||||
)?;
|
||||
|
|
@ -67,7 +67,7 @@ impl Utils {
|
|||
..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)
|
||||
})?,
|
||||
)?;
|
||||
|
|
@ -78,7 +78,7 @@ impl Utils {
|
|||
let mut lock = PreviewLock::try_from(t)?;
|
||||
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(())
|
||||
})?,
|
||||
)?;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl Preload {
|
|||
match op {
|
||||
PreloadOp::Rule(task) => {
|
||||
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 {
|
||||
self.fail(task.id, format!("Preload task failed:\n{e}"))?;
|
||||
return Err(e.into());
|
||||
|
|
@ -39,7 +39,7 @@ impl Preload {
|
|||
|
||||
let code = result.unwrap();
|
||||
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 {
|
||||
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 yazi_config::{open::Opener, plugin::PluginRule, TASKS};
|
||||
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 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() {
|
||||
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();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
@ -307,7 +307,7 @@ impl Scheduler {
|
|||
pub fn preload_paged(&self, rule: &PluginRule, targets: Vec<&yazi_shared::fs::File>) {
|
||||
let id = self.running.lock().add(
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
use std::{any::Any, collections::BTreeMap, fmt::{self, Display}, mem};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Exec {
|
||||
pub cmd: String,
|
||||
pub struct Cmd {
|
||||
pub name: String,
|
||||
pub args: Vec<String>,
|
||||
pub named: BTreeMap<String, String>,
|
||||
pub data: Option<Box<dyn Any + Send>>,
|
||||
}
|
||||
|
||||
impl Exec {
|
||||
impl Cmd {
|
||||
#[inline]
|
||||
pub fn call(cwd: &str, args: Vec<String>) -> Self {
|
||||
Exec { cmd: cwd.to_owned(), args, ..Default::default() }
|
||||
}
|
||||
pub fn new(name: &str) -> Self { Self { name: name.to_owned(), ..Default::default() } }
|
||||
|
||||
#[inline]
|
||||
pub fn call_named(cwd: &str, named: BTreeMap<String, String>) -> Self {
|
||||
Exec { cmd: cwd.to_owned(), named, ..Default::default() }
|
||||
pub fn args(name: &str, args: Vec<String>) -> Self {
|
||||
Self { name: name.to_owned(), args, ..Default::default() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -55,17 +53,17 @@ impl Exec {
|
|||
#[inline]
|
||||
pub fn clone_without_data(&self) -> Self {
|
||||
Self {
|
||||
cmd: self.cmd.clone(),
|
||||
args: self.args.clone(),
|
||||
name: self.name.clone(),
|
||||
args: self.args.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 {
|
||||
write!(f, "{}", self.cmd)?;
|
||||
write!(f, "{}", self.name)?;
|
||||
if !self.args.is_empty() {
|
||||
write!(f, " {}", self.args.join(" "))?;
|
||||
}
|
||||
|
|
@ -3,15 +3,15 @@ use std::{collections::VecDeque, ffi::OsString};
|
|||
use crossterm::event::KeyEvent;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
use super::Exec;
|
||||
use super::Cmd;
|
||||
use crate::{term::Term, Layer, RoCell};
|
||||
|
||||
static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new();
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
Call(Exec, Layer),
|
||||
Seq(VecDeque<Exec>, Layer),
|
||||
Call(Cmd, Layer),
|
||||
Seq(VecDeque<Cmd>, Layer),
|
||||
Render,
|
||||
Key(KeyEvent),
|
||||
Resize,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#![allow(clippy::module_inception)]
|
||||
|
||||
mod cmd;
|
||||
mod event;
|
||||
mod exec;
|
||||
mod render;
|
||||
|
||||
pub use cmd::*;
|
||||
pub use event::*;
|
||||
pub use exec::*;
|
||||
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