Refactor: Flatten app config structure - move panes directly under [app]

This commit is contained in:
Carlos de Paula 2025-11-12 12:17:40 -03:00
parent 228dca9d94
commit 27fe8eb6f9
5 changed files with 14 additions and 28 deletions

View file

@ -20,11 +20,9 @@ light = ""
[app]
overall = {}
[app.panes]
parent = ""
current = ""
preview = ""
parent = {}
current = {}
preview = {}
# : }}}

View file

@ -20,11 +20,9 @@ light = ""
[app]
overall = {}
[app.panes]
parent = ""
current = ""
preview = ""
parent = {}
current = {}
preview = {}
# : }}}

View file

@ -37,11 +37,6 @@ pub struct Theme {
#[derive(Deserialize, DeserializeOver2)]
pub struct App {
pub overall: Style,
pub panes: AppPanes,
}
#[derive(Deserialize, DeserializeOver2)]
pub struct AppPanes {
#[serde(default)]
pub parent: Style,
#[serde(default)]
@ -249,10 +244,10 @@ impl Theme {
impl App {
pub fn bg_color(&self) -> String { self.overall.bg.map(|c| c.to_string()).unwrap_or_default() }
}
impl AppPanes {
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() }
}

View file

@ -98,7 +98,7 @@ impl Widget for Root<'_> {
// Apply pane backgrounds (if configured)
// Skip borders: top/bottom rows and left/right edges where borders are drawn
let parent_bg = THEME.app.panes.parent_bg();
let parent_bg = THEME.app.parent_bg();
if !parent_bg.is_empty() {
if let Ok(bg_color) = parent_bg.parse::<ratatui::style::Color>() {
let pane = chunks[0];
@ -117,7 +117,7 @@ impl Widget for Root<'_> {
}
}
let current_bg = THEME.app.panes.current_bg();
let current_bg = THEME.app.current_bg();
if !current_bg.is_empty() {
if let Ok(bg_color) = current_bg.parse::<ratatui::style::Color>() {
let pane = chunks[1];
@ -134,7 +134,7 @@ impl Widget for Root<'_> {
}
}
let preview_bg = THEME.app.panes.preview_bg();
let preview_bg = THEME.app.preview_bg();
if !preview_bg.is_empty() {
if let Ok(bg_color) = preview_bg.parse::<ratatui::style::Color>() {
let pane = chunks[2];

View file

@ -34,14 +34,9 @@ fn app() -> Composer<ComposerGet, ComposerSet> {
let a = &THEME.app;
match key {
b"overall" => Style::from(a.overall).into_lua(lua),
b"panes" => lua
.create_table_from([
("parent", Style::from(a.panes.parent).into_lua(lua)?),
("current", Style::from(a.panes.current).into_lua(lua)?),
("preview", Style::from(a.panes.preview).into_lua(lua)?),
])?
.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),
}
}