mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
perf: cache each file's icon to avoid redundant calculations at rendering
This commit is contained in:
parent
80000cfd86
commit
331d3185f3
12 changed files with 33 additions and 29 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use serde::{Deserialize, Deserializer};
|
||||
use yazi_shared::fs::File;
|
||||
use yazi_shared::{fs::File, theme::{Color, Style, StyleShadow}};
|
||||
|
||||
use super::{Color, Is, Style, StyleShadow};
|
||||
use super::Is;
|
||||
use crate::Pattern;
|
||||
|
||||
pub struct Filetype {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
use serde::{Deserialize, Deserializer};
|
||||
use yazi_shared::fs::File;
|
||||
use yazi_shared::{fs::File, theme::{Color, Style, StyleShadow}};
|
||||
|
||||
use super::Style;
|
||||
use crate::{preset::Preset, theme::{Color, Is, StyleShadow}, Pattern};
|
||||
use crate::{preset::Preset, theme::Is, Pattern};
|
||||
|
||||
pub struct Icon {
|
||||
pub is: Is,
|
||||
pub name: Pattern,
|
||||
is: Is,
|
||||
name: Pattern,
|
||||
pub text: String,
|
||||
pub style: Style,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
mod color;
|
||||
mod filetype;
|
||||
mod flavor;
|
||||
mod icon;
|
||||
mod is;
|
||||
mod style;
|
||||
mod theme;
|
||||
|
||||
pub use color::*;
|
||||
pub use filetype::*;
|
||||
pub use flavor::*;
|
||||
pub use icon::*;
|
||||
pub use is::*;
|
||||
pub use style::*;
|
||||
pub use theme::*;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ use std::path::PathBuf;
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
use yazi_shared::{fs::expand_path, Xdg};
|
||||
use yazi_shared::{fs::expand_path, theme::Style, Xdg};
|
||||
|
||||
use super::{Filetype, Flavor, Icon, Style};
|
||||
use super::{Filetype, Flavor, Icon};
|
||||
use crate::{validation::check_validation, MERGED_THEME};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use mlua::{AnyUserData, ExternalError, FromLua, Lua, Table, UserData, UserDataMethods, Value};
|
||||
use yazi_config::theme::Color;
|
||||
use yazi_shared::theme::Color;
|
||||
|
||||
use super::Style;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use mlua::{AnyUserData, ExternalError, ExternalResult, Lua, Table, UserData, UserDataMethods, Value};
|
||||
use yazi_config::theme::Color;
|
||||
use yazi_shared::theme::Color;
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct Style(pub(super) ratatui::style::Style);
|
||||
|
|
@ -17,8 +17,8 @@ impl Style {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<yazi_config::theme::Style> for Style {
|
||||
fn from(value: yazi_config::theme::Style) -> Self { Self(value.into()) }
|
||||
impl From<yazi_shared::theme::Style> for Style {
|
||||
fn from(value: yazi_shared::theme::Style) -> Self { Self(value.into()) }
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<Table<'a>> for Style {
|
||||
|
|
|
|||
1
yazi-shared/src/fs/icon.rs
Normal file
1
yazi-shared/src/fs/icon.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub struct Icon {}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
mod cha;
|
||||
mod file;
|
||||
mod fns;
|
||||
mod icon;
|
||||
mod op;
|
||||
mod path;
|
||||
mod url;
|
||||
|
|
@ -8,6 +9,7 @@ mod url;
|
|||
pub use cha::*;
|
||||
pub use file::*;
|
||||
pub use fns::*;
|
||||
pub use icon::*;
|
||||
pub use op::*;
|
||||
pub use path::*;
|
||||
pub use url::*;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ mod number;
|
|||
mod os;
|
||||
mod ro_cell;
|
||||
pub mod term;
|
||||
pub mod theme;
|
||||
mod throttle;
|
||||
mod time;
|
||||
mod xdg;
|
||||
|
|
|
|||
5
yazi-shared/src/theme/mod.rs
Normal file
5
yazi-shared/src/theme/mod.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
mod color;
|
||||
mod style;
|
||||
|
||||
pub use color::*;
|
||||
pub use style::*;
|
||||
|
|
@ -37,29 +37,29 @@ impl From<Style> for ratatui::style::Style {
|
|||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
pub(super) struct StyleShadow {
|
||||
pub struct StyleShadow {
|
||||
#[serde(default)]
|
||||
pub(super) fg: Option<Color>,
|
||||
pub fg: Option<Color>,
|
||||
#[serde(default)]
|
||||
pub(super) bg: Option<Color>,
|
||||
pub bg: Option<Color>,
|
||||
#[serde(default)]
|
||||
pub(super) bold: bool,
|
||||
pub bold: bool,
|
||||
#[serde(default)]
|
||||
pub(super) dim: bool,
|
||||
pub dim: bool,
|
||||
#[serde(default)]
|
||||
pub(super) italic: bool,
|
||||
pub italic: bool,
|
||||
#[serde(default)]
|
||||
pub(super) underline: bool,
|
||||
pub underline: bool,
|
||||
#[serde(default)]
|
||||
pub(super) blink: bool,
|
||||
pub blink: bool,
|
||||
#[serde(default)]
|
||||
pub(super) blink_rapid: bool,
|
||||
pub blink_rapid: bool,
|
||||
#[serde(default)]
|
||||
pub(super) reversed: bool,
|
||||
pub reversed: bool,
|
||||
#[serde(default)]
|
||||
pub(super) hidden: bool,
|
||||
pub hidden: bool,
|
||||
#[serde(default)]
|
||||
pub(super) crossed: bool,
|
||||
pub crossed: bool,
|
||||
}
|
||||
|
||||
impl From<StyleShadow> for Style {
|
||||
Loading…
Add table
Reference in a new issue