From 074de293171888026b7d4d05f22a84cd0edfc8d1 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:22:10 +0000 Subject: [PATCH 1/9] chore: define config type with useful constructor pattern --- config.v | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 config.v diff --git a/config.v b/config.v new file mode 100644 index 00000000..4f428ac8 --- /dev/null +++ b/config.v @@ -0,0 +1,36 @@ +module cfg + +import theme + +pub struct Config{ +pub: + theme theme.Theme + leader_key string +} + +@[params] +pub struct ConfigOptions { +pub: + load_from_path ?string = "~/.config/petal/petal.cfg" +} + +pub fn Config.new(opts ConfigOptions) Config { + if path_to_load := opts.load_from_path { + assert path_to_load.len > 0 + // do some loading from file here + // return Config{} + } + + return Config{ + theme: theme.dark_theme + leader_key: ";" + } +} + +pub fn (c Config) set_theme(name string) Config { + return Config{ + ...c + theme: if name == "dark" { theme.dark_theme } else { theme.light_theme } + } +} + From 0675c8c0edfe2ff300d3310f5ceaf4808df024a4 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:22:34 +0000 Subject: [PATCH 2/9] chore: define new collections of palettes in the form of themes --- theme.v | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 theme.v diff --git a/theme.v b/theme.v new file mode 100644 index 00000000..8904beb2 --- /dev/null +++ b/theme.v @@ -0,0 +1,31 @@ +module theme + +import tauraamui.bobatea as tea +import palette + +pub const dark_theme_name = "dark" +pub const light_theme_name = "light" + +pub struct Theme{ +pub: + name string @[required] + background_color tea.Color @[required] + foreground_color tea.Color + active_split_divider_color tea.Color @[required] + inactive_split_divider_color tea.Color @[required] +} + +pub const dark_theme = Theme{ + name: "dark" + background_color: palette.matte_black_bg_color + active_split_divider_color: palette.petal_pink_color + inactive_split_divider_color: palette.status_bar_bg_color +} + +pub const light_theme = Theme{ + name: "light" + background_color: palette.matte_white_fg_color + active_split_divider_color: palette.petal_pink_color + inactive_split_divider_color: palette.status_bar_bg_color +} + From edd39b882ff505f10d523b23f4bf0cfccf753d1c Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:23:05 +0000 Subject: [PATCH 3/9] feat: initialise config instances and passed to app --- main.v | 6 +++++- petal.v | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.v b/main.v index 5e50dd90..785d9c96 100644 --- a/main.v +++ b/main.v @@ -2,9 +2,13 @@ module main import tauraamui.bobatea as tea import palette +import cfg +import theme fn main() { - mut petal_model := PetalModel.new(palette.theme_bg_color, palette.fg_color(palette.theme_bg_color)) + config := cfg.Config.new(load_from_path: none).set_theme(theme.light_theme_name) + + mut petal_model := PetalModel.new(palette.theme_bg_color, palette.fg_color(palette.theme_bg_color), config) mut app := tea.new_program(mut petal_model) petal_model.app_send = app.send app.run() or { panic('something went wrong! ${err}') } diff --git a/petal.v b/petal.v index 3581d5b3..f464f639 100644 --- a/petal.v +++ b/petal.v @@ -2,12 +2,14 @@ module main import os import tauraamui.bobatea as tea +import cfg const dot = '•' struct PetalModel { mut: app_send ?fn (tea.Msg) + config cfg.Config @[required] theme_fg_color ?tea.Color theme_bg_color ?tea.Color first_frame bool @@ -18,8 +20,9 @@ mut: last_resize_height int } -fn PetalModel.new(theme_bg_color ?tea.Color, theme_fg_color ?tea.Color) PetalModel { +fn PetalModel.new(theme_bg_color ?tea.Color, theme_fg_color ?tea.Color, config cfg.Config) PetalModel { return PetalModel{ + config: config theme_bg_color: theme_bg_color theme_fg_color: theme_fg_color first_frame: true From fcc4ae5141b8b3d9c8dceab878afe19908cd777f Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:30:52 +0000 Subject: [PATCH 4/9] chore: alias theme names to avoid requring two module imports --- config.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.v b/config.v index 4f428ac8..a72d0a06 100644 --- a/config.v +++ b/config.v @@ -2,6 +2,9 @@ module cfg import theme +pub const light_theme_name = theme.light_theme_name +pub const dark_theme_name = theme.dark_theme_name + pub struct Config{ pub: theme theme.Theme From 797d51a5d1b13f4c1466d521e886b54a7af9c9e5 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:31:47 +0000 Subject: [PATCH 5/9] chore: set ctxs default bg color from theme and fg as inverse of that --- petal.v | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/petal.v b/petal.v index f464f639..0670dc96 100644 --- a/petal.v +++ b/petal.v @@ -3,6 +3,8 @@ module main import os import tauraamui.bobatea as tea import cfg +import theme +import palette const dot = '•' @@ -10,8 +12,7 @@ struct PetalModel { mut: app_send ?fn (tea.Msg) config cfg.Config @[required] - theme_fg_color ?tea.Color - theme_bg_color ?tea.Color + theme theme.Theme first_frame bool active_screen DebuggableModel // all screens are debuggable to help with live, well... debugging clear_screen_next_frame bool @@ -23,8 +24,9 @@ mut: fn PetalModel.new(theme_bg_color ?tea.Color, theme_fg_color ?tea.Color, config cfg.Config) PetalModel { return PetalModel{ config: config - theme_bg_color: theme_bg_color - theme_fg_color: theme_fg_color + theme: config.theme + // theme_bg_color: theme_bg_color + // theme_fg_color: theme_fg_color first_frame: true active_screen: SplashScreenModel.new() } @@ -102,13 +104,9 @@ fn (mut m PetalModel) update(msg tea.Msg) (tea.Model, ?tea.Cmd) { fn (mut m PetalModel) view(mut ctx tea.Context) { if m.first_frame { - if fg_color := m.theme_fg_color { - ctx.set_default_fg_color(fg_color) - } - - if bg_color := m.theme_bg_color { - ctx.set_default_bg_color(bg_color) - } + bg_color := m.theme.bg_color + ctx.set_default_fg_color(palette.fg_color(bg_color)) + ctx.set_default_bg_color(bg_color) m.first_frame = false } mut screen := m.active_screen From 7fc1f110c390b2d14da9db62768fd65397e23de6 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:32:04 +0000 Subject: [PATCH 6/9] chore: adjust field names to be more consistent with previous --- theme.v | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/theme.v b/theme.v index 8904beb2..a6d2cd4c 100644 --- a/theme.v +++ b/theme.v @@ -9,22 +9,22 @@ pub const light_theme_name = "light" pub struct Theme{ pub: name string @[required] - background_color tea.Color @[required] - foreground_color tea.Color + bg_color tea.Color @[required] + fg_color tea.Color active_split_divider_color tea.Color @[required] inactive_split_divider_color tea.Color @[required] } pub const dark_theme = Theme{ name: "dark" - background_color: palette.matte_black_bg_color + bg_color: palette.matte_black_bg_color active_split_divider_color: palette.petal_pink_color inactive_split_divider_color: palette.status_bar_bg_color } pub const light_theme = Theme{ name: "light" - background_color: palette.matte_white_fg_color + bg_color: palette.matte_white_fg_color active_split_divider_color: palette.petal_pink_color inactive_split_divider_color: palette.status_bar_bg_color } From 430f659ccdc0300c8ef360160cf77a2d72fa0b82 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:32:28 +0000 Subject: [PATCH 7/9] chore: make it now v easy to swap between default D/L themes in code --- main.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.v b/main.v index 785d9c96..3d3e8132 100644 --- a/main.v +++ b/main.v @@ -3,10 +3,10 @@ module main import tauraamui.bobatea as tea import palette import cfg -import theme fn main() { - config := cfg.Config.new(load_from_path: none).set_theme(theme.light_theme_name) + // config := cfg.Config.new(load_from_path: none).set_theme(cfg.light_theme_name) + config := cfg.Config.new(load_from_path: none) mut petal_model := PetalModel.new(palette.theme_bg_color, palette.fg_color(palette.theme_bg_color), config) mut app := tea.new_program(mut petal_model) From 79603b472838010c3838d33fdc7e4fe2b91561bb Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:33:00 +0000 Subject: [PATCH 8/9] chore(tidy): remove unneeded now unused fields --- petal.v | 2 -- 1 file changed, 2 deletions(-) diff --git a/petal.v b/petal.v index 0670dc96..59a9e123 100644 --- a/petal.v +++ b/petal.v @@ -25,8 +25,6 @@ fn PetalModel.new(theme_bg_color ?tea.Color, theme_fg_color ?tea.Color, config c return PetalModel{ config: config theme: config.theme - // theme_bg_color: theme_bg_color - // theme_fg_color: theme_fg_color first_frame: true active_screen: SplashScreenModel.new() } From a579252387724ed27fa520efe895e48867fc8f10 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 8 Jan 2026 17:49:02 +0000 Subject: [PATCH 9/9] chore(tidy): remove remaining left over junk --- colors.v | 4 +--- main.v | 3 +-- petal.v | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/colors.v b/colors.v index f4bd249d..d5c3d441 100644 --- a/colors.v +++ b/colors.v @@ -5,7 +5,6 @@ import tauraamui.bobatea as tea // TODO(tauraamui): consolidate all used colors into a core palette/swatch set // and alias reference off of that only in the places/models they are used with // alternative names, instead of here. This file is getting messy and out of hand. -pub const theme_bg_color = matte_black_bg_color pub const matte_black_bg_color = tea.Color{ 20, 20, 20 } pub const petal_pink_color = tea.Color{ 245, 191, 243 } @@ -21,11 +20,11 @@ pub const status_purple = tea.Color{ 130, 144, 250 } pub const error_color = petal_red_color +// pub const matte_black_fg_color = tea.Color.ansi(232) pub const matte_white_fg_color = tea.Color{ 230, 230, 230 } pub const bright_off_white_fg_color = tea.Color{ 255, 255, 255 } -// pub const bright_red_fg_color = tea.Color{ 245, 42, 42 } pub const subtle_text_fg_color = tea.Color.ansi(249) pub const help_fg_color = tea.Color.ansi(241) @@ -34,7 +33,6 @@ pub const selected_highlight_bg_color = tea.Color.ansi(239) pub const subtle_border_fg_color = petal_pink_color - pub const status_bar_bg_color = tea.Color.ansi(234) pub const status_file_name_bg_color = tea.Color{ 86, 86, 86 } pub const status_branch_name_bg_color = tea.Color{ 154, 119, 209 } diff --git a/main.v b/main.v index 3d3e8132..314eee5f 100644 --- a/main.v +++ b/main.v @@ -1,14 +1,13 @@ module main import tauraamui.bobatea as tea -import palette import cfg fn main() { // config := cfg.Config.new(load_from_path: none).set_theme(cfg.light_theme_name) config := cfg.Config.new(load_from_path: none) - mut petal_model := PetalModel.new(palette.theme_bg_color, palette.fg_color(palette.theme_bg_color), config) + mut petal_model := PetalModel.new(config) mut app := tea.new_program(mut petal_model) petal_model.app_send = app.send app.run() or { panic('something went wrong! ${err}') } diff --git a/petal.v b/petal.v index 59a9e123..a972e59d 100644 --- a/petal.v +++ b/petal.v @@ -21,7 +21,7 @@ mut: last_resize_height int } -fn PetalModel.new(theme_bg_color ?tea.Color, theme_fg_color ?tea.Color, config cfg.Config) PetalModel { +fn PetalModel.new(config cfg.Config) PetalModel { return PetalModel{ config: config theme: config.theme