mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Remove independent parent, current and preview pane bg color config
This commit is contained in:
parent
2657ff8f2e
commit
4fd1598e0f
7 changed files with 35 additions and 116 deletions
|
|
@ -20,9 +20,6 @@ light = ""
|
||||||
|
|
||||||
[app]
|
[app]
|
||||||
overall = {}
|
overall = {}
|
||||||
parent = {}
|
|
||||||
current = {}
|
|
||||||
preview = {}
|
|
||||||
|
|
||||||
# : }}}
|
# : }}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,6 @@ light = ""
|
||||||
|
|
||||||
[app]
|
[app]
|
||||||
overall = {}
|
overall = {}
|
||||||
parent = {}
|
|
||||||
current = {}
|
|
||||||
preview = {}
|
|
||||||
|
|
||||||
# : }}}
|
# : }}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,6 @@ pub struct Theme {
|
||||||
#[derive(Deserialize, DeserializeOver2)]
|
#[derive(Deserialize, DeserializeOver2)]
|
||||||
pub struct App {
|
pub struct App {
|
||||||
pub overall: Style,
|
pub overall: Style,
|
||||||
#[serde(default)]
|
|
||||||
pub parent: Style,
|
|
||||||
#[serde(default)]
|
|
||||||
pub current: Style,
|
|
||||||
#[serde(default)]
|
|
||||||
pub preview: Style,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, DeserializeOver2)]
|
#[derive(Deserialize, DeserializeOver2)]
|
||||||
|
|
@ -254,10 +248,4 @@ impl Theme {
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn bg_color(&self) -> String { self.overall.bg.map(|c| c.to_string()).unwrap_or_default() }
|
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() }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,5 @@
|
||||||
use ratatui::{buffer::Buffer, layout::Rect, style::Color};
|
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
|
/// Apply background color to entire area, excluding header and status bar
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn apply_overall_bg(buf: &mut Buffer, area: Rect, bg_color: Color) {
|
pub fn apply_overall_bg(buf: &mut Buffer, area: Rect, bg_color: Color) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use mlua::{ObjectLike, Table};
|
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 tracing::error;
|
||||||
use yazi_binding::elements::render_once;
|
use yazi_binding::elements::render_once;
|
||||||
use yazi_config::{THEME, YAZI};
|
use yazi_config::THEME;
|
||||||
use yazi_core::Core;
|
use yazi_core::Core;
|
||||||
use yazi_plugin::LUA;
|
use yazi_plugin::LUA;
|
||||||
|
|
||||||
|
|
@ -70,57 +70,9 @@ impl Widget for Root<'_> {
|
||||||
which::Which::new(self.core).render(area, buf);
|
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::<ratatui::style::Color>() {
|
|
||||||
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::<ratatui::style::Color>() {
|
|
||||||
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::<ratatui::style::Color>() {
|
|
||||||
apply_pane_bg_with_borders(buf, chunks[2], bg_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill background on all cells to create an opaque background (like fzf does).
|
// 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.
|
// 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();
|
let bg_color_str = THEME.app.bg_color();
|
||||||
if !bg_color_str.is_empty() {
|
if !bg_color_str.is_empty() {
|
||||||
if let Ok(bg_color) = bg_color_str.parse::<ratatui::style::Color>() {
|
if let Ok(bg_color) = bg_color_str.parse::<ratatui::style::Color>() {
|
||||||
|
|
|
||||||
|
|
@ -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 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 crossterm::{
|
||||||
use ratatui::{CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect};
|
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_adapter::{Emulator, Mux, TMUX};
|
||||||
use yazi_config::{THEME, YAZI};
|
use yazi_config::{THEME, YAZI};
|
||||||
use yazi_shared::SyncCell;
|
use yazi_shared::SyncCell;
|
||||||
|
|
@ -38,8 +54,6 @@ impl Term {
|
||||||
Print("\x1b[?12$p"), // Request cursor blink status (DECRQM query for DECSET 12)
|
Print("\x1b[?12$p"), // Request cursor blink status (DECRQM query for DECSET 12)
|
||||||
Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
|
Print("\x1b[?u"), // Request keyboard enhancement flags (CSI u)
|
||||||
Print("\x1b[0c"), // Request device attributes
|
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::If(TMUX.get(), EnterAlternateScreen),
|
||||||
yazi_term::SetBackground(true, THEME.app.bg_color()), // Set app background
|
yazi_term::SetBackground(true, THEME.app.bg_color()), // Set app background
|
||||||
EnableBracketedPaste,
|
EnableBracketedPaste,
|
||||||
|
|
@ -149,15 +163,21 @@ impl Term {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Term {
|
impl Drop for Term {
|
||||||
fn drop(&mut self) { self.stop().ok(); }
|
fn drop(&mut self) {
|
||||||
|
self.stop().ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Term {
|
impl Deref for Term {
|
||||||
type Target = Terminal<CrosstermBackend<TtyWriter<'static>>>;
|
type Target = Terminal<CrosstermBackend<TtyWriter<'static>>>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target { &self.inner }
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.inner
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DerefMut for Term {
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,6 @@ fn app() -> Composer<ComposerGet, ComposerSet> {
|
||||||
let a = &THEME.app;
|
let a = &THEME.app;
|
||||||
match key {
|
match key {
|
||||||
b"overall" => Style::from(a.overall).into_lua(lua),
|
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),
|
_ => Ok(Value::Nil),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue