From 4fd1598e0fc8b35e2892bf48e54bfff43178b5ac Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 5 Jan 2026 11:53:28 -0300 Subject: [PATCH] Remove independent parent, current and preview pane bg color config --- yazi-config/preset/theme-dark.toml | 3 -- yazi-config/preset/theme-light.toml | 3 -- yazi-config/src/theme/theme.rs | 12 ------- yazi-fm/src/bg_render.rs | 32 ----------------- yazi-fm/src/root.rs | 54 ++--------------------------- yazi-fm/src/term.rs | 44 ++++++++++++++++------- yazi-plugin/src/theme/theme.rs | 3 -- 7 files changed, 35 insertions(+), 116 deletions(-) diff --git a/yazi-config/preset/theme-dark.toml b/yazi-config/preset/theme-dark.toml index 6533e6e8..56f46344 100644 --- a/yazi-config/preset/theme-dark.toml +++ b/yazi-config/preset/theme-dark.toml @@ -20,9 +20,6 @@ light = "" [app] overall = {} -parent = {} -current = {} -preview = {} # : }}} diff --git a/yazi-config/preset/theme-light.toml b/yazi-config/preset/theme-light.toml index a823d0c2..d6aef72b 100644 --- a/yazi-config/preset/theme-light.toml +++ b/yazi-config/preset/theme-light.toml @@ -20,9 +20,6 @@ light = "" [app] overall = {} -parent = {} -current = {} -preview = {} # : }}} diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index 47065ac7..57eb2a46 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -37,12 +37,6 @@ pub struct Theme { #[derive(Deserialize, DeserializeOver2)] pub struct App { pub overall: Style, - #[serde(default)] - pub parent: Style, - #[serde(default)] - pub current: Style, - #[serde(default)] - pub preview: Style, } #[derive(Deserialize, DeserializeOver2)] @@ -254,10 +248,4 @@ impl Theme { impl App { pub fn bg_color(&self) -> String { self.overall.bg.map(|c| c.to_string()).unwrap_or_default() } - - pub fn parent_bg(&self) -> String { self.parent.bg.map(|c| c.to_string()).unwrap_or_default() } - - pub fn current_bg(&self) -> String { self.current.bg.map(|c| c.to_string()).unwrap_or_default() } - - pub fn preview_bg(&self) -> String { self.preview.bg.map(|c| c.to_string()).unwrap_or_default() } } diff --git a/yazi-fm/src/bg_render.rs b/yazi-fm/src/bg_render.rs index e130de66..054ed959 100644 --- a/yazi-fm/src/bg_render.rs +++ b/yazi-fm/src/bg_render.rs @@ -1,37 +1,5 @@ use ratatui::{buffer::Buffer, layout::Rect, style::Color}; -/// Apply background color to a pane, skipping borders on all sides -#[inline] -pub fn apply_pane_bg_with_borders(buf: &mut Buffer, pane: Rect, bg_color: Color) { - let start_y = pane.top() + 1; - let end_y = if pane.bottom() > 0 { pane.bottom() - 1 } else { pane.bottom() }; - let start_x = pane.left() + 1; - let end_x = if pane.right() > 0 { pane.right() - 1 } else { pane.right() }; - - if start_y < end_y && start_x < end_x { - for y in start_y..end_y { - for x in start_x..end_x { - buf[(x, y)].set_bg(bg_color); - } - } - } -} - -/// Apply background color to a pane, skipping only top/bottom borders -#[inline] -pub fn apply_pane_bg_no_vertical_borders(buf: &mut Buffer, pane: Rect, bg_color: Color) { - let start_y = pane.top() + 1; - let end_y = if pane.bottom() > 0 { pane.bottom() - 1 } else { pane.bottom() }; - - if start_y < end_y { - for y in start_y..end_y { - for x in pane.left()..pane.right() { - buf[(x, y)].set_bg(bg_color); - } - } - } -} - /// Apply background color to entire area, excluding header and status bar #[inline] pub fn apply_overall_bg(buf: &mut Buffer, area: Rect, bg_color: Color) { diff --git a/yazi-fm/src/root.rs b/yazi-fm/src/root.rs index 9f30d8ce..31df492e 100644 --- a/yazi-fm/src/root.rs +++ b/yazi-fm/src/root.rs @@ -1,8 +1,8 @@ use mlua::{ObjectLike, Table}; -use ratatui::{buffer::Buffer, layout::{Constraint, Direction, Layout, Rect}, widgets::Widget}; +use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget}; use tracing::error; use yazi_binding::elements::render_once; -use yazi_config::{THEME, YAZI}; +use yazi_config::THEME; use yazi_core::Core; use yazi_plugin::LUA; @@ -70,57 +70,9 @@ impl Widget for Root<'_> { which::Which::new(self.core).render(area, buf); } - // Calculate the Tab area (excluding Header, Tabs, and Status) - // This matches the Root layout in root.lua - let tabs_height = if self.core.mgr.tabs.len() > 1 { 1 } else { 0 }; - let root_chunks = Layout::default() - .direction(Direction::Vertical) - .constraints([ - Constraint::Length(1), // Header - Constraint::Length(tabs_height), // Tabs - Constraint::Fill(1), // Tab content (the 3 panes) - Constraint::Length(1), // Status - ]) - .split(area); - let tab_area = root_chunks[2]; - - // Apply per-pane backgrounds first, then app-wide background - // Calculate pane areas using the manager ratio within the tab area - let ratio = YAZI.mgr.ratio.get(); - let chunks = Layout::default() - .direction(Direction::Horizontal) - .constraints([ - Constraint::Ratio(ratio.parent as u32, ratio.all as u32), - Constraint::Ratio(ratio.current as u32, ratio.all as u32), - Constraint::Ratio(ratio.preview as u32, ratio.all as u32), - ]) - .split(tab_area); - - // Apply pane backgrounds (if configured) - // Skip borders: top/bottom rows and left/right edges where borders are drawn - let parent_bg = THEME.app.parent_bg(); - if !parent_bg.is_empty() { - if let Ok(bg_color) = parent_bg.parse::() { - apply_pane_bg_with_borders(buf, chunks[0], bg_color); - } - } - - let current_bg = THEME.app.current_bg(); - if !current_bg.is_empty() { - if let Ok(bg_color) = current_bg.parse::() { - apply_pane_bg_no_vertical_borders(buf, chunks[1], bg_color); - } - } - - let preview_bg = THEME.app.preview_bg(); - if !preview_bg.is_empty() { - if let Ok(bg_color) = preview_bg.parse::() { - apply_pane_bg_with_borders(buf, chunks[2], bg_color); - } - } - // Fill background on all cells to create an opaque background (like fzf does). // This is done AFTER all rendering so text/foreground colors are already set. + // The background is skipped on the header (top row) and status bar (bottom row). let bg_color_str = THEME.app.bg_color(); if !bg_color_str.is_empty() { if let Ok(bg_color) = bg_color_str.parse::() { diff --git a/yazi-fm/src/term.rs b/yazi-fm/src/term.rs index 5a036eff..c0b23d3b 100644 --- a/yazi-fm/src/term.rs +++ b/yazi-fm/src/term.rs @@ -1,8 +1,24 @@ -use std::{io, ops::{Deref, DerefMut}, sync::atomic::{AtomicBool, Ordering}}; +use std::{ + io, + ops::{Deref, DerefMut}, + sync::atomic::{AtomicBool, Ordering}, +}; use anyhow::Result; -use crossterm::{event::{DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}, execute, queue, style::Print, terminal::{EnterAlternateScreen, LeaveAlternateScreen, SetTitle, disable_raw_mode, enable_raw_mode}}; -use ratatui::{CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect}; +use crossterm::{ + event::{ + DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture, + KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags, + }, + execute, queue, + style::Print, + terminal::{ + EnterAlternateScreen, LeaveAlternateScreen, SetTitle, disable_raw_mode, enable_raw_mode, + }, +}; +use ratatui::{ + CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect, +}; use yazi_adapter::{Emulator, Mux, TMUX}; use yazi_config::{THEME, YAZI}; use yazi_shared::SyncCell; @@ -11,16 +27,16 @@ use yazi_term::tty::{TTY, TtyWriter}; static CSI_U: AtomicBool = AtomicBool::new(false); pub(super) struct Term { - inner: Terminal>>, - last_area: Rect, + inner: Terminal>>, + last_area: Rect, last_buffer: Buffer, } impl Term { pub(super) fn start() -> Result { let mut term = Self { - inner: Terminal::new(CrosstermBackend::new(TTY.writer()))?, - last_area: Default::default(), + inner: Terminal::new(CrosstermBackend::new(TTY.writer()))?, + last_area: Default::default(), last_buffer: Default::default(), }; let background = THEME.app.bg_color(); @@ -38,8 +54,6 @@ impl Term { Print("\x1b[?12$p"), // Request cursor blink status (DECRQM query for DECSET 12) Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u) Print("\x1b[0c"), // Request device attributes - // Set terminal background color - yazi_term::If(!background.is_empty(), Print(format!("\x1b]11;{}\x1b\\", background))), yazi_term::If(TMUX.get(), EnterAlternateScreen), yazi_term::SetBackground(true, THEME.app.bg_color()), // Set app background EnableBracketedPaste, @@ -149,15 +163,21 @@ impl Term { } impl Drop for Term { - fn drop(&mut self) { self.stop().ok(); } + fn drop(&mut self) { + self.stop().ok(); + } } impl Deref for Term { type Target = Terminal>>; - fn deref(&self) -> &Self::Target { &self.inner } + fn deref(&self) -> &Self::Target { + &self.inner + } } impl DerefMut for Term { - fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } } diff --git a/yazi-plugin/src/theme/theme.rs b/yazi-plugin/src/theme/theme.rs index 78a2a9de..2a1eebbe 100644 --- a/yazi-plugin/src/theme/theme.rs +++ b/yazi-plugin/src/theme/theme.rs @@ -35,9 +35,6 @@ fn app() -> Composer { let a = &THEME.app; match key { b"overall" => Style::from(a.overall).into_lua(lua), - b"parent" => Style::from(a.parent).into_lua(lua), - b"current" => Style::from(a.current).into_lua(lua), - b"preview" => Style::from(a.preview).into_lua(lua), _ => Ok(Value::Nil), } }