Skip to content

ui: add theme support with dark and light modes#105

Merged
agavra merged 3 commits intoagavra:mainfrom
Mic92:theme
Jan 16, 2026
Merged

ui: add theme support with dark and light modes#105
agavra merged 3 commits intoagavra:mainfrom
Mic92:theme

Conversation

@Mic92
Copy link
Copy Markdown
Contributor

@Mic92 Mic92 commented Jan 16, 2026

Users with light terminal backgrounds cannot read the current color scheme. The hardcoded dark theme colors have poor contrast on light backgrounds.

Add a --theme flag to select between dark (default) and light themes:

tuicr --theme dark # default, original colors
tuicr --theme light # optimized for light terminal backgrounds

Introduce a Theme struct that holds all color definitions and thread it through the rendering code. All style functions in src/ui/styles.rs now take a &Theme parameter instead of using hardcoded constants.

The light theme uses subtle backgrounds (very light green/pink) with dark text for good contrast on light terminal backgrounds.

Closes: #7

Users with light terminal backgrounds cannot read the current color
scheme. The hardcoded dark theme colors have poor contrast on light
backgrounds.

Add a --theme flag to select between dark (default) and light themes:

  tuicr --theme dark   # default, original colors
  tuicr --theme light  # optimized for light terminal backgrounds

Introduce a Theme struct that holds all color definitions and thread it
through the rendering code. All style functions in src/ui/styles.rs now
take a &Theme parameter instead of using hardcoded constants.

The light theme uses subtle backgrounds (very light green/pink) with
dark text for good contrast on light terminal backgrounds.

Closes: agavra#7
Closes: agavra#44
Users running tuicr without knowing the available options had no way to
discover them. The --theme flag added in the previous commit is not
discoverable without documentation.

Add --help and -h flags that print a brief usage message showing all
available command-line options and a hint about the in-app help.

Document why we use a handrolled argument parser instead of clap: to
keep binary size small and build times fast.
@agavra
Copy link
Copy Markdown
Owner

agavra commented Jan 16, 2026

Really happy to see this change come in! I don't think this fixes #44 quite yet since users can't define their own without modifying source, but it opens the door to that.

I think we need to also change

tuicr/src/syntax/mod.rs

Lines 110 to 125 in 10802b8

pub fn apply_diff_background(
spans: Vec<(Style, String)>,
origin: LineOrigin,
) -> Vec<(Style, String)> {
let bg_color = match origin {
LineOrigin::Addition => Color::Rgb(0, 35, 12),
LineOrigin::Deletion => Color::Rgb(45, 0, 0),
LineOrigin::Context => return spans, // No background for context
};
spans
.into_iter()
.map(|(style, text)| (style.bg(bg_color), text))
.collect()
}
}
theme for light otherwise we get:
image

I also think we should change the syntect theme as well to respect this as well (e.g. use base16-ocean.light instead of "base16-eighties.dark")

Would be good to share screenshots of your final preview with it before we merge.

@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Jan 16, 2026

image

Copy link
Copy Markdown
Owner

@agavra agavra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'll merge after you fix clippy

The syntax highlighter was using hardcoded dark theme colors for diff
backgrounds and syntect theme selection. Users with light terminal
backgrounds got unreadable syntax highlighting.

Pass the SyntaxHighlighter through VcsBackend trait methods instead of
using global state. The Theme now owns a cached highlighter instance
(via OnceLock) configured with the appropriate colors and syntect theme.

For light theme, use 'base16-ocean.light' syntect theme and light
background colors for additions/deletions.
@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Jan 16, 2026

ci is green.

@agavra agavra merged commit 7f98e4a into agavra:main Jan 16, 2026
4 checks passed
@agavra
Copy link
Copy Markdown
Owner

agavra commented Jan 16, 2026

Thanks for the contribution @Mic92!

@Mic92 Mic92 deleted the theme branch January 16, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support light/dark mode

2 participants