From 543f24193529d30f4fe7980b0acd8f0703eddfae Mon Sep 17 00:00:00 2001 From: Yiang Date: Tue, 26 Nov 2024 22:49:04 +0800 Subject: [PATCH] update: able to set header flag style --- yazi-config/src/theme/theme.rs | 1 + yazi-plugin/preset/components/header.lua | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index c23e2ec8..19210a64 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -44,6 +44,7 @@ impl FromStr for Theme { #[derive(Deserialize, Serialize, Validate)] pub struct Manager { cwd: Style, + flag: Style, // Hovered hovered: Style, diff --git a/yazi-plugin/preset/components/header.lua b/yazi-plugin/preset/components/header.lua index e926e2a8..1335fbdd 100644 --- a/yazi-plugin/preset/components/header.lua +++ b/yazi-plugin/preset/components/header.lua @@ -27,8 +27,13 @@ function Header:cwd() return "" end - local s = ya.readable_path(tostring(self._current.cwd)) .. self:flags() - return ui.Span(ya.truncate(s, { max = max, rtl = true })):style(THEME.manager.cwd) + local s = ya.readable_path(tostring(self._current.cwd)) .. " " + local flag = self:flags() + + return ui.Line { + ui.Span(ya.truncate(s, { max = max, rtl = true })):style(THEME.manager.cwd), + ui.Span(ya.truncate(flag, { max = max, rtl = true })):style(THEME.manager.flag) + } end function Header:flags() @@ -46,7 +51,7 @@ function Header:flags() if finder then t[#t + 1] = string.format("find: %s", finder) end - return #t == 0 and "" or " (" .. table.concat(t, ", ") .. ")" + return #t == 0 and "" or "(" .. table.concat(t, ", ") .. ")" end function Header:count()