From 4f629f1231f53899d7ef4656c8ad550afa5fe3fd Mon Sep 17 00:00:00 2001 From: extrawurst Date: Wed, 22 May 2024 11:25:37 +0200 Subject: [PATCH] unittest more of the color formats * to ensure noticing if breaking changes happen * document breaking change in changelog --- CHANGELOG.md | 22 ++++++++++++++++++++++ THEMES.md | 8 ++++---- src/ui/style.rs | 13 ++++++++----- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 763b9236c1..fb6de51383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Breaking Changes + +#### Theme file format + +**note:** this actually applied to the previous release already: `0.26.2` + +Ratatui (upstream terminal rendering crate) changed its serialization format for Colors. So the theme files have to be adjusted. + +`selection_fg: Some(White)` -> `selection_fg: Some("White")` + +but this also allows us now to define colors in the common hex format: + +`selection_fg: Some(Rgb(0,255,0))` -> `selection_fg: Some("#00ff00")` + +Checkout [THEME.md](./THEME.md) for more info. + +### Fixes +* update yanked dependency to `libc` to fix building with `--locked`. +* document breaking change in theme file format. + ## [0.26.2] - 2024-04-17 +**note:** this release introduced a breaking change documented in the following release: `0.26.3` + ### Fixes * fix `cargo install` without `--locked` ([#2098](https://github.com/extrawurst/gitui/issues/2098)) * respect configuration for remote when fetching (also applies to pulling) [[@cruessler](https://github.com/cruessler)] ([#1093](https://github.com/extrawurst/gitui/issues/1093)) diff --git a/THEMES.md b/THEMES.md index ff3be94a59..25990f332f 100644 --- a/THEMES.md +++ b/THEMES.md @@ -18,8 +18,8 @@ Example theme override: ``` ( - selection_bg: Some(Blue), - selection_fg: Some(White), + selection_bg: Some("Blue"), + selection_fg: Some("#ffffff"), ) ``` @@ -27,9 +27,9 @@ Note that you need to wrap values in `Some` due to the way the overrides work (a Notes: -* rgb colors might not be supported in every terminal. +* rgb colors might not be supported in every terminal. * using a color like `yellow` might appear in whatever your terminal/theme defines for `yellow` -* valid colors can be found in tui-rs' [Color](https://docs.rs/tui/0.12.0/tui/style/enum.Color.html) struct. +* valid colors can be found in tui-rs' [Color](https://docs.rs/tui/0.12.0/tui/style/enum.Color.html) struct. * all customizable theme elements can be found in [`style.rs` in the `impl Default for Theme` block](https://github.com/extrawurst/gitui/blob/master/src/ui/style.rs#L305) ## Customizing line breaks diff --git a/src/ui/style.rs b/src/ui/style.rs index 11b216a5c9..2d311af728 100644 --- a/src/ui/style.rs +++ b/src/ui/style.rs @@ -374,18 +374,21 @@ mod tests { writeln!( file, - r#" + r##" ( - selection_bg: Some("White"), + selection_bg: Some("Black"), + selection_fg: Some("#ffffff"), ) -"# +"## ) .unwrap(); let theme = Theme::init(&file.path().to_path_buf()); - assert_eq!(theme.selection_fg, Theme::default().selection_fg); - assert_eq!(theme.selection_bg, Color::White); + assert_eq!(theme.selected_tab, Theme::default().selected_tab); + assert_ne!(theme.selection_bg, Theme::default().selection_bg); + assert_eq!(theme.selection_bg, Color::Black); + assert_eq!(theme.selection_fg, Color::Rgb(255, 255, 255)); } }