Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ed15acf
fix: somehow this existing fix was reverted at some point, oops
tauraamui Jan 8, 2026
a93f458
feat: pass in relevant options/external settings into splash model
tauraamui Jan 8, 2026
af4fafd
feat: pass in theme set to splash screen model
tauraamui Jan 8, 2026
386b5ea
misc: temp swap theme to light for now
tauraamui Jan 8, 2026
f5876c9
feat: set backdrop color from fg
tauraamui Jan 8, 2026
25df513
chore: move petal shades to theme from palette collection
tauraamui Jan 8, 2026
30d522a
fix: set fg color from inverse of selected file path bg color
tauraamui Jan 9, 2026
c075a57
chore(ui): adjust light theme's petal pink and background shades
tauraamui Jan 9, 2026
6e8aad3
chore(theme): move green choice for keybinds tow theme's petal green
tauraamui Jan 9, 2026
24b751a
chore(theme): pass in light grey to use for help fg use
tauraamui Jan 10, 2026
235ff6a
chore: provide better name for theme matte grey option
tauraamui Jan 10, 2026
fb7befd
chore: pass in shared theme def for subtle light grey
tauraamui Jan 10, 2026
32798e6
refactor: condense excessively long args into params struct for both
tauraamui Jan 10, 2026
e4b7f7f
chore: pass in selection bg color from theme for picker
tauraamui Jan 10, 2026
58793ba
chore: streamline theme structure fields
tauraamui Jan 10, 2026
13a0a50
chore: set formatting
tauraamui Jan 10, 2026
4d3e3db
chore: pass in ui elements colors from theme or use theme directly
tauraamui Jan 12, 2026
7282b64
chore(ui): tidy up the color palette shade defs
tauraamui Jan 12, 2026
379b81f
feat: pass in consistent (used elsewhere) shade for dialog border
tauraamui Jan 12, 2026
eda6d49
chore: better label magic number to deduct from clip area width
tauraamui Jan 13, 2026
9c81fa8
feat: enable easy switching of light/dark themes
tauraamui Jan 13, 2026
aacc4d5
chore(ui): improve highlight shade for file picker
tauraamui Jan 13, 2026
987697e
feat: add task alias for displaying ansi color codes table
tauraamui Jan 14, 2026
50495b8
chore(ui): adjust spacer bg color for each theme type
tauraamui Jan 15, 2026
4c51f2a
chore(ui): adjust shade used for status bar branch name
tauraamui Jan 15, 2026
15bdb6a
chore(ui): swap theme color usage for status file name on bar
tauraamui Jan 15, 2026
45f580d
fix: enable test to run successfully due to intialising theme
tauraamui Jan 17, 2026
d3321d0
chore: define status bar mode color segment defs into theme type
tauraamui Jan 21, 2026
7b4248a
chore: resolve mode segment colors with palette derived from theme
tauraamui Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions colors.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ 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 matte_black_bg_color = tea.Color{ 20, 20, 20 }
pub const matte_black_bg_color = tea.Color{20, 20, 20}

pub const petal_pink_color = tea.Color{ 245, 191, 243 }
pub const petal_green_color = tea.Color{ 97, 242, 136 }
pub const petal_red_color = tea.Color{ 245, 42, 42 }
pub const petal_pink_color = tea.Color{245, 191, 243}
pub const petal_green_color = tea.Color{97, 242, 136}
pub const petal_red_color = tea.Color{245, 42, 42}

pub const status_green = tea.Color{ 145, 237, 145 }
pub const status_orange = tea.Color{ 237, 207, 123 }
pub const status_lilac = tea.Color{ 194, 110, 230 }
pub const status_dark_lilac = tea.Color{ 154, 119, 209 }
pub const status_cyan = tea.Color{ 138, 222, 237 }
pub const status_purple = tea.Color{ 130, 144, 250 }
pub const status_green = tea.Color{145, 237, 145}
pub const status_orange = tea.Color{237, 207, 123}
pub const status_lilac = tea.Color{194, 110, 230}
pub const status_dark_lilac = tea.Color{154, 119, 209}
pub const status_cyan = tea.Color{138, 222, 237}
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 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 subtle_text_fg_color = tea.Color.ansi(249)
pub const help_fg_color = tea.Color.ansi(241)
Expand All @@ -33,10 +33,10 @@ 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 }
pub const status_cursor_pos_bg_color = tea.Color{ 245, 42, 42 }
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}
pub const status_cursor_pos_bg_color = tea.Color{245, 42, 42}

pub fn fg_color(background_color tea.Color) tea.Color {
s_r := f32(background_color.r) / 255
Expand All @@ -47,4 +47,3 @@ pub fn fg_color(background_color tea.Color) tea.Color {

return if luminance > 0.5 { matte_black_fg_color } else { matte_white_fg_color }
}

5 changes: 2 additions & 3 deletions colors_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module palette
import tauraamui.bobatea as tea

fn test_fg_color_from_shades_of_bg() {
assert fg_color(tea.Color{ 10, 10, 10 }) == matte_white_fg_color
assert fg_color(tea.Color{ 200, 200, 200 }) == matte_black_fg_color
assert fg_color(tea.Color{10, 10, 10}) == matte_white_fg_color
assert fg_color(tea.Color{200, 200, 200}) == matte_black_fg_color
}

11 changes: 5 additions & 6 deletions config.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import theme
pub const light_theme_name = theme.light_theme_name
pub const dark_theme_name = theme.dark_theme_name

pub struct Config{
pub struct Config {
pub:
theme theme.Theme
leader_key string
Expand All @@ -14,7 +14,7 @@ pub:
@[params]
pub struct ConfigOptions {
pub:
load_from_path ?string = "~/.config/petal/petal.cfg"
load_from_path ?string = '~/.config/petal/petal.cfg'
}

pub fn Config.new(opts ConfigOptions) Config {
Expand All @@ -25,15 +25,14 @@ pub fn Config.new(opts ConfigOptions) Config {
}

return Config{
theme: theme.dark_theme
leader_key: ";"
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 }
theme: if name == 'dark' { theme.dark_theme } else { theme.light_theme }
}
}

28 changes: 16 additions & 12 deletions debug_screen.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import palette
interface DebuggableModel {
tea.Model
Debuggable
width() int
width() int
height() int
}

Expand Down Expand Up @@ -58,18 +58,18 @@ enum LogLevel {

fn (l LogLevel) str() string {
return match l {
.debug { "DEBU" }
.info { "INFO" }
.warn { "WARN" }
.error { "ERRO" }
.debug { 'DEBU' }
.info { 'INFO' }
.warn { 'WARN' }
.error { 'ERRO' }
}
}

fn (l LogLevel) fg() tea.Color {
return match l {
.debug { tea.Color.ansi(62) }
.info { tea.Color.ansi(183) }
.warn { tea.Color.ansi(220) }
.info { tea.Color.ansi(183) }
.warn { tea.Color.ansi(220) }
.error { tea.Color.ansi(162) }
}
}
Expand All @@ -80,7 +80,7 @@ struct LogMsg {
}

fn log(message string, level LogLevel) tea.Msg {
return LogMsg{ level, message }
return LogMsg{level, message}
}

fn debug_log(message string) tea.Cmd {
Expand Down Expand Up @@ -253,11 +253,11 @@ fn render_logs(mut ctx tea.Context, x int, y int, logs []LogMsg) {
ctx.set_color(l.level.fg())

mut label_x_offset := 0
ctx.draw_text(x + label_x_offset, y + i, "[")
ctx.draw_text(x + label_x_offset, y + i, '[')
label_x_offset += 1
ctx.draw_text(x + label_x_offset, y + i, level_label)
label_x_offset += tea.visible_len(level_label)
ctx.draw_text(x + label_x_offset, y + i, "]")
ctx.draw_text(x + label_x_offset, y + i, ']')
label_x_offset += 1
ctx.reset_color()
label_x_offset += 1 // single space padding
Expand Down Expand Up @@ -301,9 +301,13 @@ fn (m DebugScreenModel) debug_data() DebugData {
}
}

fn (m DebugScreenModel) width() int { return m.window_width }
fn (m DebugScreenModel) width() int {
return m.window_width
}

fn (m DebugScreenModel) height() int { return m.window_height }
fn (m DebugScreenModel) height() int {
return m.window_height
}

fn (m DebugScreenModel) clone() tea.Model {
return DebugScreenModel{
Expand Down
92 changes: 61 additions & 31 deletions editor.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,46 @@ struct ModelCursorPos {

fn (c ModelCursorPos) up() ModelCursorPos {
yy := c.y - 1
if yy < 0 { return c }
return ModelCursorPos{ y: yy, x: 0 }
if yy < 0 {
return c
}
return ModelCursorPos{
y: yy
x: 0
}
}

fn (c ModelCursorPos) down(max int) ModelCursorPos {
yy := c.y + 1
if yy >= max { return c }
return ModelCursorPos{ y: yy, x: 0 }
if yy >= max {
return c
}
return ModelCursorPos{
y: yy
x: 0
}
}

fn (c ModelCursorPos) left() ModelCursorPos {
xx := c.x - 1
if xx < 0 { return c }
return ModelCursorPos{ y: c.y, x: xx }
if xx < 0 {
return c
}
return ModelCursorPos{
y: c.y
x: xx
}
}

fn (c ModelCursorPos) right(max int) ModelCursorPos {
yy := c.y + 1
if yy >= max { return c }
return ModelCursorPos{ y: yy, x: 0 }
if yy >= max {
return c
}
return ModelCursorPos{
y: yy
x: 0
}
}

struct EditorData {
Expand Down Expand Up @@ -60,16 +80,16 @@ struct OpenEditorMsg {

fn open_editor(file_path string) tea.Cmd {
return fn [file_path] () tea.Msg {
return OpenEditorMsg{ file_path }
return OpenEditorMsg{file_path}
}
}

struct QueryEditorDataMsg {}

fn query_editor_data(id int) tea.Cmd {
return fn [id] () tea.Msg {
return EditorModelMsg {
id: id
return EditorModelMsg{
id: id
msg: QueryEditorDataMsg{}
}
}
Expand All @@ -81,16 +101,20 @@ struct EditorDataResultMsg {

fn editor_data(data EditorData) tea.Cmd {
return fn [data] () tea.Msg {
return EditorDataResultMsg{ data }
return EditorDataResultMsg{data}
}
}

fn EditorModel.new(id int, file_path string) EditorModel {
assert file_path.len != 0
return EditorModel{
id: id,
file_path: file_path,
lines: if content := os.read_lines(file_path) { content } else { []string{ len: 150, init: "This is a line of random text" } }
id: id
file_path: file_path
lines: if content := os.read_lines(file_path) {
content
} else {
[]string{len: 150, init: 'This is a line of random text'}
}
}
}

Expand Down Expand Up @@ -121,22 +145,20 @@ fn move_cursor_up() tea.Msg {
return EditorCursorUpMsg{}
}


fn (mut m EditorModel) update(msg tea.Msg) (tea.Model, ?tea.Cmd) {
mut cmds := []tea.Cmd{}

if msg is tea.KeyMsg && m.focused {
match msg.k_type {
.runes {
match msg.string() {
"j" {
'j' {
cmds << move_cursor_down
return m.clone(), tea.batch_array(cmds)
}
"k" {
'k' {
cmds << move_cursor_up
return m.clone(), tea.batch_array(cmds)

}
else {}
}
Expand All @@ -147,7 +169,7 @@ fn (mut m EditorModel) update(msg tea.Msg) (tea.Model, ?tea.Cmd) {

match msg {
tea.ResizedMsg {
m.width = msg.window_width
m.width = msg.window_width
m.height = msg.window_height
}
EditorModelMsg {
Expand Down Expand Up @@ -196,25 +218,30 @@ const active_editor_border_color = palette.petal_pink_color
const inactive_editor_border_color = palette.status_dark_lilac

fn (m EditorModel) view(mut ctx tea.Context) {
ctx.set_clip_area(tea.ClipArea{ 0, 0, m.width, m.height })
ctx.set_clip_area(tea.ClipArea{0, 0, m.width, m.height})
defer { ctx.clear_clip_area() }

if m.show_border {
border_color := if m.focused { active_editor_border_color } else { inactive_editor_border_color }
border_color := if m.focused {
active_editor_border_color
} else {
inactive_editor_border_color
}
ctx.set_color(border_color)
for y in 0..m.height {
for y in 0 .. m.height {
ctx.draw_text(0, y, '│')
}
ctx.reset_color()
ctx.push_offset(tea.Offset{ x: 1 })
}

ctx.push_offset(tea.Offset{ x: 1 })

for y, l in m.lines {
ctx.draw_text(0, y, l.replace('\t', ' '))
}

if m.focused { m.render_cursor(mut ctx) }
if m.focused {
m.render_cursor(mut ctx)
}
}

fn (m EditorModel) render_cursor(mut ctx tea.Context) {
Expand All @@ -228,8 +255,8 @@ fn (m EditorModel) debug_data() DebugData {
return DebugData{
name: 'active editor data'
data: {
'id': '${m.id}'
'file path': m.file_path
'id': '${m.id}'
'file path': m.file_path
'cursor_row': '${m.cursor_pos.y}'
'cursor_col': '${m.cursor_pos.x}'
}
Expand All @@ -245,14 +272,17 @@ fn (m EditorModel) data() EditorData {
}
}

fn (m EditorModel) width() int { return m.width }
fn (m EditorModel) width() int {
return m.width
}

fn (m EditorModel) height() int { return m.height }
fn (m EditorModel) height() int {
return m.height
}

fn (m EditorModel) clone() tea.Model {
assert m.file_path.len != 0
return EditorModel{
...m
}
}

Loading