From d385f4b8c50afda66dc715f06c4b57f758f24dbe Mon Sep 17 00:00:00 2001 From: Jelenkee Date: Sat, 3 Aug 2024 12:56:13 +0200 Subject: [PATCH] -added config for showing tabs always --- yazi-config/preset/theme.toml | 7 ++++--- yazi-config/src/theme/theme.rs | 7 ++++--- yazi-plugin/preset/components/header.lua | 10 ++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/yazi-config/preset/theme.toml b/yazi-config/preset/theme.toml index 09e65b03..173af48e 100644 --- a/yazi-config/preset/theme.toml +++ b/yazi-config/preset/theme.toml @@ -31,9 +31,10 @@ marker_marked = { fg = "lightcyan", bg = "lightcyan" } marker_selected = { fg = "lightyellow", bg = "lightyellow" } # Tab -tab_active = { reversed = true } -tab_inactive = {} -tab_width = 1 +tab_active = { reversed = true } +tab_inactive = {} +tab_width = 1 +tab_show_always = false # Count count_copied = { fg = "white", bg = "green" } diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index da757143..a895156a 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -64,10 +64,11 @@ pub struct Manager { marker_selected: Style, // Tab - tab_active: Style, - tab_inactive: Style, + tab_active: Style, + tab_inactive: Style, #[validate(range(min = 1, message = "Must be greater than 0"))] - tab_width: u8, + tab_width: u8, + tab_show_always: bool, // Count count_copied: Style, diff --git a/yazi-plugin/preset/components/header.lua b/yazi-plugin/preset/components/header.lua index ac456073..3fda3a49 100644 --- a/yazi-plugin/preset/components/header.lua +++ b/yazi-plugin/preset/components/header.lua @@ -71,7 +71,7 @@ end function Header:tabs() local tabs = #cx.tabs - if tabs == 1 then + if tabs == 1 and not THEME.manager.tab_show_always then return ui.Line {} end @@ -102,7 +102,13 @@ function Header:render() end -- Mouse events -function Header:click(event, up) end +function Header:click(event, up) + if up or not event.is_left then + return + end + + ya.manager_emit("tab_switch", { 0 }) +end function Header:scroll(event, step) end