diff --git a/config/yazi.toml b/config/yazi.toml index 9682df85..03ed3be0 100644 --- a/config/yazi.toml +++ b/config/yazi.toml @@ -4,7 +4,7 @@ sort_reverse = true show_hidden = false [preview] -adapter = "kitty" +adaptor = "kitty" tab_size = 2 max_width = 600 max_height = 900 diff --git a/src/config/preview/adapter.rs b/src/config/preview/adaptor.rs similarity index 73% rename from src/config/preview/adapter.rs rename to src/config/preview/adaptor.rs index 490219e3..7e1e95b4 100644 --- a/src/config/preview/adapter.rs +++ b/src/config/preview/adaptor.rs @@ -3,19 +3,19 @@ use serde::Deserialize; #[derive(Debug, Deserialize, PartialEq, Eq)] #[serde(try_from = "String")] -pub enum PreviewAdapter { +pub enum PreviewAdaptor { Kitty, Ueberzug, } -impl TryFrom for PreviewAdapter { +impl TryFrom for PreviewAdaptor { type Error = anyhow::Error; fn try_from(value: String) -> Result { Ok(match value.to_lowercase().as_str() { "kitty" => Self::Kitty, "ueberzug" => Self::Ueberzug, - _ => bail!("invalid preview adapter: {}", value), + _ => bail!("invalid preview adaptor: {}", value), }) } } diff --git a/src/config/preview/mod.rs b/src/config/preview/mod.rs index 73d684f7..612b0d97 100644 --- a/src/config/preview/mod.rs +++ b/src/config/preview/mod.rs @@ -1,5 +1,5 @@ -mod adapter; +mod adaptor; mod preview; -pub use adapter::*; +pub use adaptor::*; pub use preview::*; diff --git a/src/config/preview/preview.rs b/src/config/preview/preview.rs index 03bcc32c..d33272e2 100644 --- a/src/config/preview/preview.rs +++ b/src/config/preview/preview.rs @@ -1,11 +1,11 @@ use serde::Deserialize; -use super::PreviewAdapter; +use super::PreviewAdaptor; use crate::config::MERGED_YAZI; #[derive(Debug, Deserialize)] pub struct Preview { - pub adapter: PreviewAdapter, + pub adaptor: PreviewAdaptor, pub tab_size: u32, pub max_width: u32, diff --git a/src/core/adapter/mod.rs b/src/core/adapter/mod.rs deleted file mode 100644 index 14345594..00000000 --- a/src/core/adapter/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod adapter; -mod kitty; -mod ueberzug; - -pub use adapter::*; diff --git a/src/core/adapter/adapter.rs b/src/core/adaptor/adaptor.rs similarity index 54% rename from src/core/adapter/adapter.rs rename to src/core/adaptor/adaptor.rs index 16d35724..11eb53db 100644 --- a/src/core/adapter/adapter.rs +++ b/src/core/adaptor/adaptor.rs @@ -5,27 +5,27 @@ use ratatui::prelude::Rect; use tokio::sync::mpsc::UnboundedSender; use super::{kitty::Kitty, ueberzug::Ueberzug}; -use crate::config::{preview::PreviewAdapter, PREVIEW}; +use crate::config::{preview::PreviewAdaptor, PREVIEW}; -pub struct Adapter { +pub struct Adaptor { ueberzug: Option>>, } -impl Adapter { +impl Adaptor { pub fn new() -> Self { - let mut adapter = Self { ueberzug: None }; + let mut adaptor = Self { ueberzug: None }; - if PREVIEW.adapter == PreviewAdapter::Ueberzug { - adapter.ueberzug = Ueberzug::init().ok(); + if PREVIEW.adaptor == PreviewAdaptor::Ueberzug { + adaptor.ueberzug = Ueberzug::init().ok(); } - adapter + adaptor } pub async fn image_show(&self, path: &Path, rect: Rect) -> Result<()> { - match PREVIEW.adapter { - PreviewAdapter::Kitty => Kitty::image_show(path, rect).await, - PreviewAdapter::Ueberzug => { + match PREVIEW.adaptor { + PreviewAdaptor::Kitty => Kitty::image_show(path, rect).await, + PreviewAdaptor::Ueberzug => { if let Some(tx) = &self.ueberzug { tx.send(Some((path.to_path_buf(), rect))).ok(); } @@ -35,9 +35,9 @@ impl Adapter { } pub fn image_hide(&self) { - match PREVIEW.adapter { - PreviewAdapter::Kitty => Kitty::image_hide(), - PreviewAdapter::Ueberzug => { + match PREVIEW.adaptor { + PreviewAdaptor::Kitty => Kitty::image_hide(), + PreviewAdaptor::Ueberzug => { if let Some(tx) = &self.ueberzug { tx.send(None).ok(); } diff --git a/src/core/adapter/kitty.rs b/src/core/adaptor/kitty.rs similarity index 100% rename from src/core/adapter/kitty.rs rename to src/core/adaptor/kitty.rs diff --git a/src/core/adaptor/mod.rs b/src/core/adaptor/mod.rs new file mode 100644 index 00000000..9e4d7a07 --- /dev/null +++ b/src/core/adaptor/mod.rs @@ -0,0 +1,5 @@ +mod adaptor; +mod kitty; +mod ueberzug; + +pub use adaptor::*; diff --git a/src/core/adapter/ueberzug.rs b/src/core/adaptor/ueberzug.rs similarity index 100% rename from src/core/adapter/ueberzug.rs rename to src/core/adaptor/ueberzug.rs diff --git a/src/core/manager/preview.rs b/src/core/manager/preview.rs index 9d99a22a..b7c7ab94 100644 --- a/src/core/manager/preview.rs +++ b/src/core/manager/preview.rs @@ -6,7 +6,7 @@ use syntect::{easy::HighlightFile, highlighting::{Theme, ThemeSet}, parsing::Syn use tokio::{fs, task::JoinHandle}; use super::{ALL_RATIO, PREVIEW_BORDER, PREVIEW_PADDING, PREVIEW_RATIO}; -use crate::{config::{PREVIEW, THEME}, core::{adapter::Adapter, external, files::{Files, FilesOp}, tasks::Precache}, emit, misc::{tty_size, MimeKind}}; +use crate::{config::{PREVIEW, THEME}, core::{adaptor::Adaptor, external, files::{Files, FilesOp}, tasks::Precache}, emit, misc::{tty_size, MimeKind}}; static SYNTECT_SYNTAX: OnceLock = OnceLock::new(); static SYNTECT_THEME: OnceLock = OnceLock::new(); @@ -16,7 +16,7 @@ pub struct Preview { pub data: PreviewData, handle: Option>, - adaptor: Arc, + adaptor: Arc, } #[derive(Debug, Default)] @@ -33,7 +33,7 @@ impl Preview { path: Default::default(), data: Default::default(), handle: Default::default(), - adaptor: Arc::new(Adapter::new()), + adaptor: Arc::new(Adaptor::new()), } } @@ -84,7 +84,7 @@ impl Preview { Ok(PreviewData::Folder) } - pub async fn image(adaptor: Arc, mut path: &Path) -> Result { + pub async fn image(adaptor: Arc, mut path: &Path) -> Result { let cache = Precache::cache(path); if fs::metadata(&cache).await.is_ok() { path = cache.as_path(); @@ -100,7 +100,7 @@ impl Preview { Ok(PreviewData::None) } - pub async fn video(adaptor: Arc, path: &Path) -> Result { + pub async fn video(adaptor: Arc, path: &Path) -> Result { let cache = Precache::cache(path); if fs::metadata(&cache).await.is_err() { external::ffmpegthumbnailer(path, &cache).await?; diff --git a/src/core/mod.rs b/src/core/mod.rs index c01cc426..f2843f2d 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1,4 +1,4 @@ -pub mod adapter; +pub mod adaptor; mod blocker; mod event; pub mod external;