diff --git a/yazi-config/src/keymap/control.rs b/yazi-config/src/keymap/control.rs index 6544654a..a3b1af64 100644 --- a/yazi-config/src/keymap/control.rs +++ b/yazi-config/src/keymap/control.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use serde::Deserialize; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use super::Key; diff --git a/yazi-config/src/keymap/exec.rs b/yazi-config/src/keymap/exec.rs index 3d3d7cfd..7c257c54 100644 --- a/yazi-config/src/keymap/exec.rs +++ b/yazi-config/src/keymap/exec.rs @@ -2,7 +2,7 @@ use std::fmt; use anyhow::{bail, Result}; use serde::{de::{self, Visitor}, Deserializer}; -use yazi_shared::Exec; +use yazi_shared::event::Exec; pub(super) fn exec_deserialize<'de, D>(deserializer: D) -> Result, D::Error> where diff --git a/yazi-core/src/completion/commands/arrow.rs b/yazi-core/src/completion/commands/arrow.rs index cdf32ccf..9368b5dd 100644 --- a/yazi-core/src/completion/commands/arrow.rs +++ b/yazi-core/src/completion/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::completion::Completion; diff --git a/yazi-core/src/completion/commands/close.rs b/yazi-core/src/completion/commands/close.rs index 5bc8d2cd..fdd6f785 100644 --- a/yazi-core/src/completion/commands/close.rs +++ b/yazi-core/src/completion/commands/close.rs @@ -1,6 +1,6 @@ -use yazi_shared::{Exec, Layer}; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{completion::Completion, emit, input::Input}; +use crate::{completion::Completion, input::Input}; pub struct Opt { submit: bool, diff --git a/yazi-core/src/completion/commands/show.rs b/yazi-core/src/completion/commands/show.rs index ea2ef2f8..5454b289 100644 --- a/yazi-core/src/completion/commands/show.rs +++ b/yazi-core/src/completion/commands/show.rs @@ -1,6 +1,6 @@ use std::{mem, ops::ControlFlow}; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::completion::Completion; diff --git a/yazi-core/src/completion/commands/trigger.rs b/yazi-core/src/completion/commands/trigger.rs index 8536cb02..fc6749c3 100644 --- a/yazi-core/src/completion/commands/trigger.rs +++ b/yazi-core/src/completion/commands/trigger.rs @@ -1,9 +1,9 @@ use std::{mem, path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR}}; use tokio::fs; -use yazi_shared::{Exec, Layer}; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{completion::Completion, emit}; +use crate::completion::Completion; pub struct Opt<'a> { word: &'a str, diff --git a/yazi-core/src/context.rs b/yazi-core/src/context.rs index 06cfbefc..b1b6d82c 100644 --- a/yazi-core/src/context.rs +++ b/yazi-core/src/context.rs @@ -1,9 +1,9 @@ use ratatui::prelude::Rect; use tokio::sync::oneshot; use yazi_config::popup::{Origin, Position}; -use yazi_shared::{Exec, Layer}; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{completion::Completion, emit, help::Help, input::Input, manager::Manager, select::Select, tasks::Tasks, which::Which}; +use crate::{completion::Completion, help::Help, input::Input, manager::Manager, select::Select, tasks::Tasks, which::Which}; pub struct Ctx { pub manager: Manager, diff --git a/yazi-core/src/external/fd.rs b/yazi-core/src/external/fd.rs index d8a073e7..f299af76 100644 --- a/yazi-core/src/external/fd.rs +++ b/yazi-core/src/external/fd.rs @@ -2,9 +2,7 @@ use std::process::Stdio; use anyhow::Result; use tokio::{io::{AsyncBufReadExt, BufReader}, process::Command, sync::mpsc::{self, UnboundedReceiver}}; -use yazi_shared::fs::Url; - -use crate::files::File; +use yazi_shared::{files::File, fs::Url}; pub struct FdOpt { pub cwd: Url, diff --git a/yazi-core/src/external/rg.rs b/yazi-core/src/external/rg.rs index 6292a3ae..c240b66d 100644 --- a/yazi-core/src/external/rg.rs +++ b/yazi-core/src/external/rg.rs @@ -2,9 +2,7 @@ use std::process::Stdio; use anyhow::Result; use tokio::{io::{AsyncBufReadExt, BufReader}, process::Command, sync::mpsc::{self, UnboundedReceiver}}; -use yazi_shared::fs::Url; - -use crate::files::File; +use yazi_shared::{files::File, fs::Url}; pub struct RgOpt { pub cwd: Url, diff --git a/yazi-core/src/files/files.rs b/yazi-core/src/files/files.rs index ffe5b2db..ff79e141 100644 --- a/yazi-core/src/files/files.rs +++ b/yazi-core/src/files/files.rs @@ -3,9 +3,9 @@ use std::{collections::{BTreeMap, BTreeSet}, mem, ops::Deref, sync::atomic::Orde use anyhow::Result; use tokio::{fs, select, sync::mpsc::{self, UnboundedReceiver}}; use yazi_config::{manager::SortBy, MANAGER}; -use yazi_shared::fs::Url; +use yazi_shared::{files::{File, FILES_TICKET}, fs::Url}; -use super::{File, FilesSorter, FILES_TICKET}; +use super::FilesSorter; pub struct Files { items: Vec, diff --git a/yazi-core/src/files/mod.rs b/yazi-core/src/files/mod.rs index 59df8d54..f6b8945d 100644 --- a/yazi-core/src/files/mod.rs +++ b/yazi-core/src/files/mod.rs @@ -1,9 +1,5 @@ -mod file; mod files; -mod op; mod sorter; -pub use file::*; pub use files::*; -pub use op::*; pub use sorter::*; diff --git a/yazi-core/src/files/sorter.rs b/yazi-core/src/files/sorter.rs index e214d172..9eca8551 100644 --- a/yazi-core/src/files/sorter.rs +++ b/yazi-core/src/files/sorter.rs @@ -1,9 +1,7 @@ use std::{cmp::Ordering, collections::BTreeMap, mem}; use yazi_config::manager::SortBy; -use yazi_shared::{fs::Url, natsort}; - -use super::File; +use yazi_shared::{files::File, fs::Url, natsort}; #[derive(Clone, Copy, Default, PartialEq)] pub struct FilesSorter { diff --git a/yazi-core/src/help/commands/arrow.rs b/yazi-core/src/help/commands/arrow.rs index b95fb81a..b78dbfbb 100644 --- a/yazi-core/src/help/commands/arrow.rs +++ b/yazi-core/src/help/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::help::Help; diff --git a/yazi-core/src/help/commands/escape.rs b/yazi-core/src/help/commands/escape.rs index be90b6ed..afde74e2 100644 --- a/yazi-core/src/help/commands/escape.rs +++ b/yazi-core/src/help/commands/escape.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::help::Help; diff --git a/yazi-core/src/help/commands/filter.rs b/yazi-core/src/help/commands/filter.rs index df5e7934..b6580b2d 100644 --- a/yazi-core/src/help/commands/filter.rs +++ b/yazi-core/src/help/commands/filter.rs @@ -1,5 +1,5 @@ use yazi_config::popup::{Offset, Origin, Position}; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{help::Help, input::Input}; diff --git a/yazi-core/src/input/commands/backspace.rs b/yazi-core/src/input/commands/backspace.rs index 521d622e..1bb89a86 100644 --- a/yazi-core/src/input/commands/backspace.rs +++ b/yazi-core/src/input/commands/backspace.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::Input; diff --git a/yazi-core/src/input/commands/backward.rs b/yazi-core/src/input/commands/backward.rs index 93fed9d1..3fe3b0b7 100644 --- a/yazi-core/src/input/commands/backward.rs +++ b/yazi-core/src/input/commands/backward.rs @@ -1,4 +1,4 @@ -use yazi_shared::{CharKind, Exec}; +use yazi_shared::{event::Exec, CharKind}; use crate::input::Input; diff --git a/yazi-core/src/input/commands/close.rs b/yazi-core/src/input/commands/close.rs index 861a16a2..594258af 100644 --- a/yazi-core/src/input/commands/close.rs +++ b/yazi-core/src/input/commands/close.rs @@ -1,4 +1,4 @@ -use yazi_shared::{Exec, InputError}; +use yazi_shared::{event::Exec, InputError}; use crate::{completion::Completion, input::Input}; diff --git a/yazi-core/src/input/commands/complete.rs b/yazi-core/src/input/commands/complete.rs index a3cc7257..50752f8e 100644 --- a/yazi-core/src/input/commands/complete.rs +++ b/yazi-core/src/input/commands/complete.rs @@ -1,8 +1,8 @@ use std::path::MAIN_SEPARATOR; -use yazi_shared::{Exec, Layer}; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{emit, input::Input}; +use crate::input::Input; pub struct Opt<'a> { word: &'a str, diff --git a/yazi-core/src/input/commands/delete.rs b/yazi-core/src/input/commands/delete.rs index d87cd43b..a46f6585 100644 --- a/yazi-core/src/input/commands/delete.rs +++ b/yazi-core/src/input/commands/delete.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{op::InputOp, Input}; diff --git a/yazi-core/src/input/commands/escape.rs b/yazi-core/src/input/commands/escape.rs index 747f23ab..4f09955f 100644 --- a/yazi-core/src/input/commands/escape.rs +++ b/yazi-core/src/input/commands/escape.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{completion::Completion, input::{op::InputOp, Input, InputMode}}; diff --git a/yazi-core/src/input/commands/forward.rs b/yazi-core/src/input/commands/forward.rs index 3d85ffb6..fc07a27d 100644 --- a/yazi-core/src/input/commands/forward.rs +++ b/yazi-core/src/input/commands/forward.rs @@ -1,4 +1,4 @@ -use yazi_shared::{CharKind, Exec}; +use yazi_shared::{event::Exec, CharKind}; use crate::input::{op::InputOp, Input}; diff --git a/yazi-core/src/input/commands/insert.rs b/yazi-core/src/input/commands/insert.rs index 207ce5de..db4d6c6e 100644 --- a/yazi-core/src/input/commands/insert.rs +++ b/yazi-core/src/input/commands/insert.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{op::InputOp, Input, InputMode}; diff --git a/yazi-core/src/input/commands/kill.rs b/yazi-core/src/input/commands/kill.rs index 262703eb..759f8d22 100644 --- a/yazi-core/src/input/commands/kill.rs +++ b/yazi-core/src/input/commands/kill.rs @@ -1,6 +1,6 @@ use std::ops::RangeBounds; -use yazi_shared::{CharKind, Exec}; +use yazi_shared::{event::Exec, CharKind}; use crate::input::Input; diff --git a/yazi-core/src/input/commands/move_.rs b/yazi-core/src/input/commands/move_.rs index 1cb527c1..f2b20a3e 100644 --- a/yazi-core/src/input/commands/move_.rs +++ b/yazi-core/src/input/commands/move_.rs @@ -1,5 +1,5 @@ use unicode_width::UnicodeWidthStr; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{op::InputOp, snap::InputSnap, Input}; diff --git a/yazi-core/src/input/commands/paste.rs b/yazi-core/src/input/commands/paste.rs index b53b8e16..47783b01 100644 --- a/yazi-core/src/input/commands/paste.rs +++ b/yazi-core/src/input/commands/paste.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{external, input::{op::InputOp, Input}}; diff --git a/yazi-core/src/input/commands/redo.rs b/yazi-core/src/input/commands/redo.rs index 685bbb2b..9573f0e1 100644 --- a/yazi-core/src/input/commands/redo.rs +++ b/yazi-core/src/input/commands/redo.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::Input; diff --git a/yazi-core/src/input/commands/show.rs b/yazi-core/src/input/commands/show.rs index 58593269..ba9f74b9 100644 --- a/yazi-core/src/input/commands/show.rs +++ b/yazi-core/src/input/commands/show.rs @@ -1,9 +1,9 @@ use anyhow::anyhow; use tokio::sync::mpsc; use yazi_config::popup::InputCfg; -use yazi_shared::{Exec, InputError, Layer}; +use yazi_shared::{emit, event::Exec, InputError, Layer}; -use crate::{emit, input::Input}; +use crate::input::Input; pub struct Opt { cfg: InputCfg, diff --git a/yazi-core/src/input/commands/type_.rs b/yazi-core/src/input/commands/type_.rs index 08162935..e693a825 100644 --- a/yazi-core/src/input/commands/type_.rs +++ b/yazi-core/src/input/commands/type_.rs @@ -1,5 +1,5 @@ use yazi_config::keymap::Key; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{Input, InputMode}; diff --git a/yazi-core/src/input/commands/undo.rs b/yazi-core/src/input/commands/undo.rs index bc6a7f68..12f63ceb 100644 --- a/yazi-core/src/input/commands/undo.rs +++ b/yazi-core/src/input/commands/undo.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{Input, InputMode}; diff --git a/yazi-core/src/input/commands/visual.rs b/yazi-core/src/input/commands/visual.rs index 1a1a3c17..0ce945ac 100644 --- a/yazi-core/src/input/commands/visual.rs +++ b/yazi-core/src/input/commands/visual.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{op::InputOp, Input, InputMode}; diff --git a/yazi-core/src/input/commands/yank.rs b/yazi-core/src/input/commands/yank.rs index 76dbf6b2..c56f653b 100644 --- a/yazi-core/src/input/commands/yank.rs +++ b/yazi-core/src/input/commands/yank.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::input::{op::InputOp, Input}; diff --git a/yazi-core/src/lib.rs b/yazi-core/src/lib.rs index 04664cdf..ef525620 100644 --- a/yazi-core/src/lib.rs +++ b/yazi-core/src/lib.rs @@ -9,7 +9,6 @@ mod blocker; pub mod completion; mod context; -mod event; pub mod external; pub mod files; pub mod help; @@ -25,7 +24,6 @@ pub mod which; pub use blocker::*; pub use context::*; -pub use event::*; pub use highlighter::*; pub use step::*; diff --git a/yazi-core/src/manager/commands/close.rs b/yazi-core/src/manager/commands/close.rs index ced8761c..7249a111 100644 --- a/yazi-core/src/manager/commands/close.rs +++ b/yazi-core/src/manager/commands/close.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/create.rs b/yazi-core/src/manager/commands/create.rs index cd3fb5b2..890dd79c 100644 --- a/yazi-core/src/manager/commands/create.rs +++ b/yazi-core/src/manager/commands/create.rs @@ -2,9 +2,9 @@ use std::path::{PathBuf, MAIN_SEPARATOR}; use tokio::fs; use yazi_config::popup::InputCfg; -use yazi_shared::{fs::Url, Exec}; +use yazi_shared::{emit, event::Exec, files::{File, FilesOp}, fs::Url}; -use crate::{emit, files::{File, FilesOp}, input::Input, manager::Manager}; +use crate::{input::Input, manager::Manager}; pub struct Opt { force: bool, diff --git a/yazi-core/src/manager/commands/hover.rs b/yazi-core/src/manager/commands/hover.rs index f52e80d8..33188093 100644 --- a/yazi-core/src/manager/commands/hover.rs +++ b/yazi-core/src/manager/commands/hover.rs @@ -1,9 +1,8 @@ use std::collections::BTreeSet; -use yazi_shared::Exec; -use yazi_shared::{fs::Url, Layer}; +use yazi_shared::{emit, event::Exec, fs::Url, Layer}; -use crate::{emit, manager::Manager}; +use crate::manager::Manager; pub struct Opt { url: Option, diff --git a/yazi-core/src/manager/commands/link.rs b/yazi-core/src/manager/commands/link.rs index a555df8d..2933aa6d 100644 --- a/yazi-core/src/manager/commands/link.rs +++ b/yazi-core/src/manager/commands/link.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/manager/commands/open.rs index e2e4bc14..db801322 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/manager/commands/open.rs @@ -1,7 +1,7 @@ use std::ffi::OsString; use yazi_config::{popup::SelectCfg, OPEN}; -use yazi_shared::{Exec, MIME_DIR}; +use yazi_shared::{event::Exec, MIME_DIR}; use crate::{external, manager::Manager, select::Select, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/paste.rs b/yazi-core/src/manager/commands/paste.rs index 4c51d942..88c9fe9a 100644 --- a/yazi-core/src/manager/commands/paste.rs +++ b/yazi-core/src/manager/commands/paste.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/peek.rs b/yazi-core/src/manager/commands/peek.rs index a101e959..500ad8d0 100644 --- a/yazi-core/src/manager/commands/peek.rs +++ b/yazi-core/src/manager/commands/peek.rs @@ -1,7 +1,7 @@ use yazi_config::MANAGER; -use yazi_shared::{fs::Url, Exec, Layer, MIME_DIR}; +use yazi_shared::{emit, event::Exec, fs::Url, Layer, MIME_DIR}; -use crate::{emit, manager::Manager}; +use crate::manager::Manager; #[derive(Debug)] pub struct Opt { diff --git a/yazi-core/src/manager/commands/quit.rs b/yazi-core/src/manager/commands/quit.rs index 1c630c45..4a77f6cb 100644 --- a/yazi-core/src/manager/commands/quit.rs +++ b/yazi-core/src/manager/commands/quit.rs @@ -1,7 +1,7 @@ use yazi_config::popup::InputCfg; -use yazi_shared::Exec; +use yazi_shared::{emit, event::Exec}; -use crate::{emit, input::Input, manager::Manager, tasks::Tasks}; +use crate::{input::Input, manager::Manager, tasks::Tasks}; #[derive(Default)] pub struct Opt { diff --git a/yazi-core/src/manager/commands/refresh.rs b/yazi-core/src/manager/commands/refresh.rs index a2b7c712..a3691fe5 100644 --- a/yazi-core/src/manager/commands/refresh.rs +++ b/yazi-core/src/manager/commands/refresh.rs @@ -1,9 +1,8 @@ use std::env; -use yazi_shared::Exec; -use yazi_shared::Layer; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{emit, manager::Manager}; +use crate::manager::Manager; pub struct Opt; diff --git a/yazi-core/src/manager/commands/remove.rs b/yazi-core/src/manager/commands/remove.rs index d9fee10e..6716688a 100644 --- a/yazi-core/src/manager/commands/remove.rs +++ b/yazi-core/src/manager/commands/remove.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index b9e7cab0..60a7a904 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -3,9 +3,9 @@ use std::{collections::BTreeMap, ffi::OsStr, io::{stdout, BufWriter, Write}, pat use anyhow::{anyhow, bail, Result}; use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}}; use yazi_config::{popup::InputCfg, OPEN, PREVIEW}; -use yazi_shared::{fs::{max_common_root, Url}, term::Term, Defer, Exec}; +use yazi_shared::{emit, event::Exec, files::{File, FilesOp}, fs::{max_common_root, Url}, term::Term, Defer}; -use crate::{emit, external::{self, ShellOpt}, files::{File, FilesOp}, input::Input, manager::Manager, Ctx, BLOCKER}; +use crate::{external::{self, ShellOpt}, input::Input, manager::Manager, Ctx, BLOCKER}; pub struct Opt { force: bool, diff --git a/yazi-core/src/manager/commands/suspend.rs b/yazi-core/src/manager/commands/suspend.rs index 01276681..f3db2bf1 100644 --- a/yazi-core/src/manager/commands/suspend.rs +++ b/yazi-core/src/manager/commands/suspend.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, Ctx}; diff --git a/yazi-core/src/manager/commands/tab_close.rs b/yazi-core/src/manager/commands/tab_close.rs index e6d8e350..eb4083ca 100644 --- a/yazi-core/src/manager/commands/tab_close.rs +++ b/yazi-core/src/manager/commands/tab_close.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::manager::Tabs; diff --git a/yazi-core/src/manager/commands/tab_create.rs b/yazi-core/src/manager/commands/tab_create.rs index 593c514d..8fa89d39 100644 --- a/yazi-core/src/manager/commands/tab_create.rs +++ b/yazi-core/src/manager/commands/tab_create.rs @@ -1,5 +1,4 @@ -use yazi_shared::Exec; -use yazi_shared::fs::Url; +use yazi_shared::{event::Exec, fs::Url}; use crate::{manager::Tabs, tab::Tab}; diff --git a/yazi-core/src/manager/commands/tab_swap.rs b/yazi-core/src/manager/commands/tab_swap.rs index e575b160..e7f02425 100644 --- a/yazi-core/src/manager/commands/tab_swap.rs +++ b/yazi-core/src/manager/commands/tab_swap.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::manager::Tabs; diff --git a/yazi-core/src/manager/commands/tab_switch.rs b/yazi-core/src/manager/commands/tab_switch.rs index a0bff3cd..4eeb41fe 100644 --- a/yazi-core/src/manager/commands/tab_switch.rs +++ b/yazi-core/src/manager/commands/tab_switch.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::manager::Tabs; diff --git a/yazi-core/src/manager/commands/yank.rs b/yazi-core/src/manager/commands/yank.rs index 715f9157..cb07bea5 100644 --- a/yazi-core/src/manager/commands/yank.rs +++ b/yazi-core/src/manager/commands/yank.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::manager::Manager; diff --git a/yazi-core/src/manager/manager.rs b/yazi-core/src/manager/manager.rs index 55e2a7c3..269042a5 100644 --- a/yazi-core/src/manager/manager.rs +++ b/yazi-core/src/manager/manager.rs @@ -1,9 +1,9 @@ use std::collections::{BTreeMap, HashMap, HashSet}; -use yazi_shared::fs::Url; +use yazi_shared::{files::{File, FilesOp}, fs::Url}; use super::{Tabs, Watcher}; -use crate::{files::{File, FilesOp}, tab::{Folder, Tab}, tasks::Tasks}; +use crate::{tab::{Folder, Tab}, tasks::Tasks}; pub struct Manager { pub tabs: Tabs, diff --git a/yazi-core/src/manager/watcher.rs b/yazi-core/src/manager/watcher.rs index 1636698e..785b2e2b 100644 --- a/yazi-core/src/manager/watcher.rs +++ b/yazi-core/src/manager/watcher.rs @@ -5,9 +5,9 @@ use notify::{event::{MetadataKind, ModifyKind}, EventKind, RecommendedWatcher, R use parking_lot::RwLock; use tokio::{fs, pin, sync::mpsc::{self, UnboundedReceiver}}; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; -use yazi_shared::fs::Url; +use yazi_shared::{emit, files::{File, FilesOp}, fs::Url}; -use crate::{emit, external, files::{File, Files, FilesOp}}; +use crate::{external, files::Files}; pub struct Watcher { watcher: RecommendedWatcher, diff --git a/yazi-core/src/preview/preview.rs b/yazi-core/src/preview/preview.rs index 4dccbe38..32804d57 100644 --- a/yazi-core/src/preview/preview.rs +++ b/yazi-core/src/preview/preview.rs @@ -4,10 +4,10 @@ use tokio::{pin, task::JoinHandle}; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_adaptor::ADAPTOR; use yazi_config::MANAGER; -use yazi_shared::{fs::{Cha, Url}, MimeKind, PeekError}; +use yazi_shared::{emit, event::{PreviewData, PreviewLock}, files::FilesOp, fs::{Cha, Url}, MimeKind, PeekError}; use super::Provider; -use crate::{emit, files::{Files, FilesOp}, manager::Manager, Highlighter}; +use crate::{files::Files, manager::Manager, Highlighter}; #[derive(Default)] pub struct Preview { @@ -17,20 +17,6 @@ pub struct Preview { handle: Option>, } -pub struct PreviewLock { - pub url: Url, - pub cha: Option, - pub skip: usize, - pub data: PreviewData, -} - -#[derive(Debug)] -pub enum PreviewData { - Folder, - Text(String), - Image, -} - impl Preview { pub fn go(&mut self, url: &Url, cha: Cha, mime: &str) { if self.content_unchanged(url, &cha) { @@ -152,11 +138,3 @@ impl Preview { } } } - -impl PreviewLock { - #[inline] - pub fn is_image(&self) -> bool { matches!(self.data, PreviewData::Image) } - - #[inline] - pub fn is_folder(&self) -> bool { matches!(self.data, PreviewData::Folder) } -} diff --git a/yazi-core/src/preview/provider.rs b/yazi-core/src/preview/provider.rs index 191dc76d..9fa4adfc 100644 --- a/yazi-core/src/preview/provider.rs +++ b/yazi-core/src/preview/provider.rs @@ -3,9 +3,8 @@ use std::path::Path; use tokio::fs; use yazi_adaptor::ADAPTOR; use yazi_config::{MANAGER, PREVIEW}; -use yazi_shared::{MimeKind, PeekError}; +use yazi_shared::{event::PreviewData, MimeKind, PeekError}; -use super::PreviewData; use crate::{external, Highlighter}; pub(super) struct Provider; diff --git a/yazi-core/src/select/commands/arrow.rs b/yazi-core/src/select/commands/arrow.rs index 4b4c4495..66f51fa2 100644 --- a/yazi-core/src/select/commands/arrow.rs +++ b/yazi-core/src/select/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::select::Select; diff --git a/yazi-core/src/select/commands/close.rs b/yazi-core/src/select/commands/close.rs index 70f575c8..5977cc29 100644 --- a/yazi-core/src/select/commands/close.rs +++ b/yazi-core/src/select/commands/close.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::select::Select; diff --git a/yazi-core/src/select/commands/show.rs b/yazi-core/src/select/commands/show.rs index d5fd50f7..5abf8d6d 100644 --- a/yazi-core/src/select/commands/show.rs +++ b/yazi-core/src/select/commands/show.rs @@ -1,9 +1,9 @@ use anyhow::{anyhow, Result}; use tokio::sync::oneshot; use yazi_config::popup::SelectCfg; -use yazi_shared::{term::Term, Exec, Layer}; +use yazi_shared::{emit, event::Exec, term::Term, Layer}; -use crate::{emit, select::Select}; +use crate::select::Select; pub struct Opt { cfg: SelectCfg, diff --git a/yazi-core/src/tab/commands/arrow.rs b/yazi-core/src/tab/commands/arrow.rs index e110bb89..098c7f53 100644 --- a/yazi-core/src/tab/commands/arrow.rs +++ b/yazi-core/src/tab/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tab::Tab, Step}; diff --git a/yazi-core/src/tab/commands/backstack.rs b/yazi-core/src/tab/commands/backstack.rs index bc1215e8..0ddab3f5 100644 --- a/yazi-core/src/tab/commands/backstack.rs +++ b/yazi-core/src/tab/commands/backstack.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/cd.rs b/yazi-core/src/tab/commands/cd.rs index c2d7fdc1..c4e3f40b 100644 --- a/yazi-core/src/tab/commands/cd.rs +++ b/yazi-core/src/tab/commands/cd.rs @@ -3,9 +3,9 @@ use std::{mem, time::Duration}; use tokio::{fs, pin}; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_config::popup::InputCfg; -use yazi_shared::{fs::{expand_path, Url}, Debounce, Exec, InputError, Layer}; +use yazi_shared::{emit, event::Exec, fs::{expand_path, Url}, Debounce, InputError, Layer}; -use crate::{completion::Completion, emit, input::Input, manager::Manager, tab::Tab}; +use crate::{completion::Completion, input::Input, manager::Manager, tab::Tab}; pub struct Opt { target: Url, diff --git a/yazi-core/src/tab/commands/copy.rs b/yazi-core/src/tab/commands/copy.rs index 27d54ce7..805619fa 100644 --- a/yazi-core/src/tab/commands/copy.rs +++ b/yazi-core/src/tab/commands/copy.rs @@ -1,6 +1,6 @@ use std::ffi::{OsStr, OsString}; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{external, tab::Tab}; diff --git a/yazi-core/src/tab/commands/enter.rs b/yazi-core/src/tab/commands/enter.rs index e275a8f4..a8a04e2b 100644 --- a/yazi-core/src/tab/commands/enter.rs +++ b/yazi-core/src/tab/commands/enter.rs @@ -1,6 +1,6 @@ use std::mem; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tab::Tab}; diff --git a/yazi-core/src/tab/commands/escape.rs b/yazi-core/src/tab/commands/escape.rs index 997656dc..c6e13721 100644 --- a/yazi-core/src/tab/commands/escape.rs +++ b/yazi-core/src/tab/commands/escape.rs @@ -1,5 +1,5 @@ use bitflags::bitflags; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tab::{Mode, Tab}; diff --git a/yazi-core/src/tab/commands/find.rs b/yazi-core/src/tab/commands/find.rs index a8cccae5..e95a330f 100644 --- a/yazi-core/src/tab/commands/find.rs +++ b/yazi-core/src/tab/commands/find.rs @@ -3,9 +3,9 @@ use std::time::Duration; use tokio::pin; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_config::popup::InputCfg; -use yazi_shared::{Debounce, Exec, InputError, Layer}; +use yazi_shared::{emit, event::Exec, Debounce, InputError, Layer}; -use crate::{emit, input::Input, tab::{Finder, FinderCase, Tab}}; +use crate::{input::Input, tab::{Finder, FinderCase, Tab}}; pub struct Opt<'a> { query: Option<&'a str>, diff --git a/yazi-core/src/tab/commands/hidden.rs b/yazi-core/src/tab/commands/hidden.rs index 4b919b76..916e6ef1 100644 --- a/yazi-core/src/tab/commands/hidden.rs +++ b/yazi-core/src/tab/commands/hidden.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tab::Tab}; diff --git a/yazi-core/src/tab/commands/jump.rs b/yazi-core/src/tab/commands/jump.rs index 6198d30e..3cb3e69d 100644 --- a/yazi-core/src/tab/commands/jump.rs +++ b/yazi-core/src/tab/commands/jump.rs @@ -1,4 +1,4 @@ -use yazi_shared::{fs::ends_with_slash, Defer, Exec}; +use yazi_shared::{event::Exec, fs::ends_with_slash, Defer}; use crate::{external::{self, FzfOpt, ZoxideOpt}, tab::Tab, Ctx, BLOCKER}; diff --git a/yazi-core/src/tab/commands/leave.rs b/yazi-core/src/tab/commands/leave.rs index 7c1ec497..04769e1f 100644 --- a/yazi-core/src/tab/commands/leave.rs +++ b/yazi-core/src/tab/commands/leave.rs @@ -1,6 +1,6 @@ use std::mem; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{manager::Manager, tab::Tab}; diff --git a/yazi-core/src/tab/commands/linemode.rs b/yazi-core/src/tab/commands/linemode.rs index 47ca8c16..12a1049c 100644 --- a/yazi-core/src/tab/commands/linemode.rs +++ b/yazi-core/src/tab/commands/linemode.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index 631e3a56..4c7bda76 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -1,7 +1,6 @@ -use yazi_shared::Exec; -use yazi_shared::{fs::{expand_path, Url}, Layer}; +use yazi_shared::{emit, event::Exec, files::{File, FilesOp}, fs::{expand_path, Url}, Layer}; -use crate::{emit, files::{File, FilesOp}, manager::Manager, tab::Tab}; +use crate::{manager::Manager, tab::Tab}; pub struct Opt { target: Url, diff --git a/yazi-core/src/tab/commands/search.rs b/yazi-core/src/tab/commands/search.rs index 3756f5fa..49b51471 100644 --- a/yazi-core/src/tab/commands/search.rs +++ b/yazi-core/src/tab/commands/search.rs @@ -4,9 +4,9 @@ use anyhow::bail; use tokio::pin; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_config::popup::InputCfg; -use yazi_shared::Exec; +use yazi_shared::{emit, event::Exec, files::FilesOp}; -use crate::{emit, external, files::FilesOp, input::Input, manager::Manager, tab::Tab}; +use crate::{external, input::Input, manager::Manager, tab::Tab}; pub struct Opt { pub type_: OptType, diff --git a/yazi-core/src/tab/commands/select.rs b/yazi-core/src/tab/commands/select.rs index bd034714..eb18b091 100644 --- a/yazi-core/src/tab/commands/select.rs +++ b/yazi-core/src/tab/commands/select.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/shell.rs b/yazi-core/src/tab/commands/shell.rs index 4d228ab8..f98c4a89 100644 --- a/yazi-core/src/tab/commands/shell.rs +++ b/yazi-core/src/tab/commands/shell.rs @@ -1,5 +1,5 @@ use yazi_config::{open::Opener, popup::InputCfg}; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::{input::Input, tab::Tab, tasks::Tasks}; diff --git a/yazi-core/src/tab/commands/sort.rs b/yazi-core/src/tab/commands/sort.rs index 1413fd09..f8e3eea1 100644 --- a/yazi-core/src/tab/commands/sort.rs +++ b/yazi-core/src/tab/commands/sort.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use yazi_config::manager::SortBy; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/visual_mode.rs b/yazi-core/src/tab/commands/visual_mode.rs index 34f096c9..470f6649 100644 --- a/yazi-core/src/tab/commands/visual_mode.rs +++ b/yazi-core/src/tab/commands/visual_mode.rs @@ -1,6 +1,6 @@ use std::collections::BTreeSet; -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tab::{Mode, Tab}; diff --git a/yazi-core/src/tab/folder.rs b/yazi-core/src/tab/folder.rs index b7596569..623b907d 100644 --- a/yazi-core/src/tab/folder.rs +++ b/yazi-core/src/tab/folder.rs @@ -1,8 +1,8 @@ use ratatui::layout::Rect; use yazi_config::MANAGER; -use yazi_shared::fs::Url; +use yazi_shared::{emit, files::{File, FilesOp}, fs::Url}; -use crate::{emit, files::{File, Files, FilesOp}, Step}; +use crate::{files::Files, Step}; #[derive(Default)] pub struct Folder { diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index 48133902..d1ddd9dc 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -2,10 +2,10 @@ use std::{borrow::Cow, collections::BTreeMap}; use anyhow::Result; use tokio::task::JoinHandle; -use yazi_shared::fs::Url; +use yazi_shared::{event::PreviewLock, files::File, fs::Url}; use super::{Backstack, Config, Finder, Folder, Mode}; -use crate::{files::File, preview::{Preview, PreviewLock}}; +use crate::preview::Preview; pub struct Tab { pub mode: Mode, diff --git a/yazi-core/src/tasks/commands/arrow.rs b/yazi-core/src/tasks/commands/arrow.rs index f734c78b..a662f5fe 100644 --- a/yazi-core/src/tasks/commands/arrow.rs +++ b/yazi-core/src/tasks/commands/arrow.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tasks::Tasks; diff --git a/yazi-core/src/tasks/commands/cancel.rs b/yazi-core/src/tasks/commands/cancel.rs index b449345c..013d10ed 100644 --- a/yazi-core/src/tasks/commands/cancel.rs +++ b/yazi-core/src/tasks/commands/cancel.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tasks::Tasks; diff --git a/yazi-core/src/tasks/commands/inspect.rs b/yazi-core/src/tasks/commands/inspect.rs index 0386e96d..349dabff 100644 --- a/yazi-core/src/tasks/commands/inspect.rs +++ b/yazi-core/src/tasks/commands/inspect.rs @@ -2,7 +2,7 @@ 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_shared::{term::Term, Defer, Exec}; +use yazi_shared::{event::Exec, term::Term, Defer}; use crate::{tasks::Tasks, Ctx, BLOCKER}; diff --git a/yazi-core/src/tasks/commands/open.rs b/yazi-core/src/tasks/commands/open.rs index 29883e0f..513945f4 100644 --- a/yazi-core/src/tasks/commands/open.rs +++ b/yazi-core/src/tasks/commands/open.rs @@ -2,9 +2,9 @@ use std::ffi::OsString; use anyhow::anyhow; use yazi_config::{open::Opener, BOOT}; -use yazi_shared::{Exec, Layer}; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{emit, tasks::Tasks}; +use crate::tasks::Tasks; pub struct Opt { targets: Vec<(OsString, String)>, diff --git a/yazi-core/src/tasks/commands/toggle.rs b/yazi-core/src/tasks/commands/toggle.rs index 43b72325..b97c5ba5 100644 --- a/yazi-core/src/tasks/commands/toggle.rs +++ b/yazi-core/src/tasks/commands/toggle.rs @@ -1,4 +1,4 @@ -use yazi_shared::Exec; +use yazi_shared::event::Exec; use crate::tasks::Tasks; diff --git a/yazi-core/src/tasks/commands/update.rs b/yazi-core/src/tasks/commands/update.rs index 2e87c88b..8f3d0f57 100644 --- a/yazi-core/src/tasks/commands/update.rs +++ b/yazi-core/src/tasks/commands/update.rs @@ -1,7 +1,7 @@ use anyhow::anyhow; -use yazi_shared::{Exec, Layer}; +use yazi_shared::{emit, event::Exec, Layer}; -use crate::{emit, tasks::{Tasks, TasksProgress}}; +use crate::tasks::{Tasks, TasksProgress}; pub struct Opt { progress: TasksProgress, diff --git a/yazi-core/src/tasks/tasks.rs b/yazi-core/src/tasks/tasks.rs index b70b3e87..0c573463 100644 --- a/yazi-core/src/tasks/tasks.rs +++ b/yazi-core/src/tasks/tasks.rs @@ -3,10 +3,10 @@ use std::{collections::{BTreeMap, HashMap, HashSet}, ffi::OsStr, path::Path, syn use serde::Serialize; use tracing::debug; use yazi_config::{manager::SortBy, open::Opener, popup::InputCfg, OPEN}; -use yazi_shared::{fs::Url, term::Term, MimeKind}; +use yazi_shared::{files::File, fs::Url, term::Term, MimeKind}; use super::{running::Running, task::TaskSummary, Scheduler, TASKS_PADDING, TASKS_PERCENT}; -use crate::{files::{File, Files}, input::Input}; +use crate::{files::Files, input::Input}; pub struct Tasks { pub(super) scheduler: Arc, diff --git a/yazi-core/src/tasks/workers/precache.rs b/yazi-core/src/tasks/workers/precache.rs index cd59c16e..a3239ee4 100644 --- a/yazi-core/src/tasks/workers/precache.rs +++ b/yazi-core/src/tasks/workers/precache.rs @@ -5,9 +5,9 @@ use parking_lot::Mutex; use tokio::{fs, sync::mpsc}; use yazi_adaptor::Image; use yazi_config::PREVIEW; -use yazi_shared::{fs::{calculate_size, Url}, Throttle}; +use yazi_shared::{emit, files::FilesOp, fs::{calculate_size, Url}, Throttle}; -use crate::{emit, external, files::FilesOp, tasks::TaskOp}; +use crate::{external, tasks::TaskOp}; pub(crate) struct Precache { tx: async_channel::Sender, diff --git a/yazi-core/src/which/which.rs b/yazi-core/src/which/which.rs index bdbe0af0..b70dcc18 100644 --- a/yazi-core/src/which/which.rs +++ b/yazi-core/src/which/which.rs @@ -1,9 +1,7 @@ use std::mem; use yazi_config::{keymap::{Control, Key}, KEYMAP}; -use yazi_shared::Layer; - -use crate::emit; +use yazi_shared::{emit, Layer}; pub struct Which { layer: Layer, diff --git a/yazi-fm/src/app/app.rs b/yazi-fm/src/app/app.rs index 7e75bded..29c6b32b 100644 --- a/yazi-fm/src/app/app.rs +++ b/yazi-fm/src/app/app.rs @@ -4,8 +4,8 @@ use anyhow::{Ok, Result}; use crossterm::event::KeyEvent; use ratatui::{backend::Backend, prelude::Rect}; use yazi_config::{keymap::Key, BOOT}; -use yazi_core::{emit, files::FilesOp, input::InputMode, preview::COLLISION, Ctx, Event}; -use yazi_shared::{term::Term, Exec, Layer}; +use yazi_core::{input::InputMode, preview::COLLISION, Ctx}; +use yazi_shared::{emit, event::{Event, Exec}, files::FilesOp, term::Term, Layer}; use crate::{Executor, Logs, Panic, Root, Signals}; diff --git a/yazi-fm/src/app/commands/stop.rs b/yazi-fm/src/app/commands/stop.rs index 82fa10d2..591335cc 100644 --- a/yazi-fm/src/app/commands/stop.rs +++ b/yazi-fm/src/app/commands/stop.rs @@ -1,7 +1,7 @@ use anyhow::Result; use tokio::sync::oneshot; -use yazi_core::{emit, manager::Manager}; -use yazi_shared::{term::Term, Exec}; +use yazi_core::manager::Manager; +use yazi_shared::{emit, event::Exec, term::Term}; use crate::app::App; diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 1330f309..8628aec6 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -1,6 +1,6 @@ use yazi_config::{keymap::{Control, Key}, KEYMAP}; use yazi_core::input::InputMode; -use yazi_shared::{Exec, Layer}; +use yazi_shared::{event::Exec, Layer}; use crate::app::App; diff --git a/yazi-fm/src/signals.rs b/yazi-fm/src/signals.rs index 400be6f4..1ce4c9e1 100644 --- a/yazi-fm/src/signals.rs +++ b/yazi-fm/src/signals.rs @@ -2,7 +2,7 @@ use anyhow::Result; use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind}; use futures::StreamExt; use tokio::{select, sync::{mpsc::{self, UnboundedReceiver, UnboundedSender}, oneshot}, task::JoinHandle}; -use yazi_core::Event; +use yazi_shared::event::Event; pub(super) struct Signals { tx: UnboundedSender, diff --git a/yazi-plugin/src/bindings/active.rs b/yazi-plugin/src/bindings/active.rs index 1823009a..c0d3246f 100644 --- a/yazi-plugin/src/bindings/active.rs +++ b/yazi-plugin/src/bindings/active.rs @@ -104,7 +104,7 @@ impl<'a, 'b> Active<'a, 'b> { fn file( &self, idx: usize, - inner: &'a yazi_core::files::File, + inner: &'a yazi_shared::files::File, folder: &'a yazi_core::tab::Folder, ) -> mlua::Result> { let ud = self.scope.create_any_userdata_ref(inner)?; diff --git a/yazi-plugin/src/bindings/files.rs b/yazi-plugin/src/bindings/files.rs index 803e1aeb..0962183b 100644 --- a/yazi-plugin/src/bindings/files.rs +++ b/yazi-plugin/src/bindings/files.rs @@ -6,10 +6,10 @@ use yazi_config::THEME; use super::{Range, Url}; use crate::{layout::Style, LUA}; -pub struct File(yazi_core::files::File); +pub struct File(yazi_shared::files::File); -impl From<&yazi_core::files::File> for File { - fn from(value: &yazi_core::files::File) -> Self { Self(value.clone()) } +impl From<&yazi_shared::files::File> for File { + fn from(value: &yazi_shared::files::File) -> Self { Self(value.clone()) } } impl UserData for File { @@ -47,7 +47,7 @@ impl Files { }); })?; - LUA.register_userdata_type::(|reg| { + LUA.register_userdata_type::(|reg| { reg.add_field_method_get("url", |_, me| Ok(Url::from(&me.url))); reg.add_field_method_get("link_to", |_, me| Ok(me.link_to().map(Url::from))); reg.add_field_method_get("is_link", |_, me| Ok(me.is_link())); @@ -87,7 +87,7 @@ impl Files { Ok(me.url.file_name().map(|n| n.to_string_lossy().to_string())) }); reg.add_function("size", |_, me: AnyUserData| { - let file = me.borrow::()?; + let file = me.borrow::()?; if !file.is_dir() { return Ok(Some(file.len)); } @@ -97,7 +97,7 @@ impl Files { }); reg.add_function("mime", |_, me: AnyUserData| { let manager = me.named_user_value::>("manager")?; - let file = me.borrow::()?; + let file = me.borrow::()?; Ok(manager.mimetype.get(&file.url).cloned()) }); reg.add_function("prefix", |_, me: AnyUserData| { @@ -106,7 +106,7 @@ impl Files { return Ok(None); } - let file = me.borrow::()?; + let file = me.borrow::()?; let mut p = file.url.strip_prefix(&folder.cwd).unwrap_or(&file.url).components(); p.next_back(); Ok(Some(p.as_path().to_string_lossy().to_string())) @@ -122,7 +122,7 @@ impl Files { }); reg.add_function("style", |_, me: AnyUserData| { let manager = me.named_user_value::>("manager")?; - let file = me.borrow::()?; + let file = me.borrow::()?; let mime = manager.mimetype.get(&file.url); Ok( THEME @@ -134,12 +134,12 @@ impl Files { }); reg.add_function("is_hovered", |_, me: AnyUserData| { let folder = me.named_user_value::>("folder")?; - let file = me.borrow::()?; + let file = me.borrow::()?; Ok(matches!(folder.hovered(), Some(f) if f.url == file.url)) }); reg.add_function("is_yanked", |_, me: AnyUserData| { let manager = me.named_user_value::>("manager")?; - let file = me.borrow::()?; + let file = me.borrow::()?; Ok(if !manager.yanked.1.contains(&file.url) { 0u8 } else if manager.yanked.0 { @@ -151,7 +151,7 @@ impl Files { reg.add_function("is_selected", |_, me: AnyUserData| { let manager = me.named_user_value::>("manager")?; let folder = me.named_user_value::>("folder")?; - let file = me.borrow::()?; + let file = me.borrow::()?; let selected = folder.files.is_selected(&file.url); Ok(if !manager.active().mode.is_visual() { @@ -167,7 +167,7 @@ impl Files { return Ok(None); }; - let file = me.borrow::()?; + let file = me.borrow::()?; if let Some(idx) = finder.matched_idx(&file.url) { return Some( lua.create_sequence_from([idx.into_lua(lua)?, finder.matched().len().into_lua(lua)?]), @@ -182,7 +182,7 @@ impl Files { return Ok(None); }; - let file = me.borrow::()?; + let file = me.borrow::()?; let Some(h) = file.name().and_then(|n| finder.highlighted(n)) else { return Ok(None); }; diff --git a/yazi-plugin/src/components/preview.rs b/yazi-plugin/src/components/preview.rs index 440e97f0..74840c0b 100644 --- a/yazi-plugin/src/components/preview.rs +++ b/yazi-plugin/src/components/preview.rs @@ -1,6 +1,7 @@ use ansi_to_tui::IntoText; use ratatui::{buffer::Buffer, layout::Rect, widgets::{Paragraph, Widget}}; -use yazi_core::{preview::PreviewData, Ctx}; +use yazi_core::Ctx; +use yazi_shared::event::PreviewData; use super::Folder; diff --git a/yazi-core/src/event.rs b/yazi-shared/src/event/event.rs similarity index 51% rename from yazi-core/src/event.rs rename to yazi-shared/src/event/event.rs index cb7a5586..ec665a58 100644 --- a/yazi-core/src/event.rs +++ b/yazi-shared/src/event/event.rs @@ -2,10 +2,9 @@ use std::collections::BTreeMap; use crossterm::event::KeyEvent; use tokio::sync::{mpsc::UnboundedSender, oneshot}; -use yazi_shared::{fs::Url, term::Term, Exec, Layer, RoCell}; -use super::files::FilesOp; -use crate::preview::PreviewLock; +use super::Exec; +use crate::{files::FilesOp, fs::{Cha, Url}, term::Term, Layer, RoCell}; static TX: RoCell> = RoCell::new(); @@ -40,39 +39,62 @@ impl Event { #[macro_export] macro_rules! emit { (Quit($no_cwd_file:expr)) => { - $crate::Event::Quit($no_cwd_file).emit(); + $crate::event::Event::Quit($no_cwd_file).emit(); }; (Key($key:expr)) => { - $crate::Event::Key($key).emit(); + $crate::event::Event::Key($key).emit(); }; (Render) => { - $crate::Event::Render(format!("{}:{}", file!(), line!())).emit(); + $crate::event::Event::Render(format!("{}:{}", file!(), line!())).emit(); }; (Resize($cols:expr, $rows:expr)) => { - $crate::Event::Resize($cols, $rows).emit(); + $crate::event::Event::Resize($cols, $rows).emit(); }; (Call($exec:expr, $layer:expr)) => { - $crate::Event::Call($exec, $layer).emit(); + $crate::event::Event::Call($exec, $layer).emit(); }; (Files($op:expr)) => { - $crate::Event::Files($op).emit(); + $crate::event::Event::Files($op).emit(); }; (Pages($page:expr)) => { - $crate::Event::Pages($page).emit(); + $crate::event::Event::Pages($page).emit(); }; (Mimetype($mimes:expr)) => { - $crate::Event::Mimetype($mimes).emit(); + $crate::event::Event::Mimetype($mimes).emit(); }; (Preview($lock:expr)) => { - $crate::Event::Preview($lock).emit(); + $crate::event::Event::Preview($lock).emit(); }; (Open($targets:expr, $opener:expr)) => { - $crate::Event::Open($targets, $opener).emit(); + $crate::event::Event::Open($targets, $opener).emit(); }; ($event:ident) => { - $crate::Event::$event.emit(); + $crate::event::Event::$event.emit(); }; } + +// TODO: remove this +pub struct PreviewLock { + pub url: Url, + pub cha: Option, + pub skip: usize, + pub data: PreviewData, +} + +#[derive(Debug)] +pub enum PreviewData { + Folder, + Text(String), + Image, +} + +impl PreviewLock { + #[inline] + pub fn is_image(&self) -> bool { matches!(self.data, PreviewData::Image) } + + #[inline] + pub fn is_folder(&self) -> bool { matches!(self.data, PreviewData::Folder) } +} diff --git a/yazi-shared/src/event.rs b/yazi-shared/src/event/exec.rs similarity index 100% rename from yazi-shared/src/event.rs rename to yazi-shared/src/event/exec.rs diff --git a/yazi-shared/src/event/mod.rs b/yazi-shared/src/event/mod.rs new file mode 100644 index 00000000..b85f499c --- /dev/null +++ b/yazi-shared/src/event/mod.rs @@ -0,0 +1,7 @@ +#![allow(clippy::module_inception)] + +mod event; +mod exec; + +pub use event::*; +pub use exec::*; diff --git a/yazi-core/src/files/file.rs b/yazi-shared/src/files/file.rs similarity index 97% rename from yazi-core/src/files/file.rs rename to yazi-shared/src/files/file.rs index f4f82502..44294727 100644 --- a/yazi-core/src/files/file.rs +++ b/yazi-shared/src/files/file.rs @@ -2,7 +2,8 @@ use std::{borrow::Cow, collections::BTreeMap, ffi::OsStr, fs::Metadata, ops::Der use anyhow::Result; use tokio::fs; -use yazi_shared::fs::{Cha, ChaKind, Url}; + +use crate::fs::{Cha, ChaKind, Url}; #[derive(Clone, Debug, Default)] pub struct File { diff --git a/yazi-shared/src/files/mod.rs b/yazi-shared/src/files/mod.rs new file mode 100644 index 00000000..600b5425 --- /dev/null +++ b/yazi-shared/src/files/mod.rs @@ -0,0 +1,5 @@ +mod file; +mod op; + +pub use file::*; +pub use op::*; diff --git a/yazi-core/src/files/op.rs b/yazi-shared/src/files/op.rs similarity index 88% rename from yazi-core/src/files/op.rs rename to yazi-shared/src/files/op.rs index 5ca32b28..db245387 100644 --- a/yazi-core/src/files/op.rs +++ b/yazi-shared/src/files/op.rs @@ -1,11 +1,9 @@ use std::{collections::{BTreeMap, BTreeSet}, sync::atomic::{AtomicU64, Ordering}}; -use yazi_shared::fs::Url; - use super::File; -use crate::emit; +use crate::{emit, fs::Url}; -pub(super) static FILES_TICKET: AtomicU64 = AtomicU64::new(0); +pub static FILES_TICKET: AtomicU64 = AtomicU64::new(0); #[derive(Debug)] pub enum FilesOp { diff --git a/yazi-shared/src/lib.rs b/yazi-shared/src/lib.rs index 9f87b4f1..df211bd1 100644 --- a/yazi-shared/src/lib.rs +++ b/yazi-shared/src/lib.rs @@ -5,7 +5,8 @@ mod debounce; mod defer; mod env; mod errors; -mod event; +pub mod event; +pub mod files; pub mod fs; mod layer; mod mime; @@ -20,7 +21,6 @@ pub use debounce::*; pub use defer::*; pub use env::*; pub use errors::*; -pub use event::*; pub use layer::*; pub use mime::*; pub use natsort::*;