Skip to content

Commit

Permalink
unittest more of the color formats
Browse files Browse the repository at this point in the history
* to ensure noticing if breaking changes happen
* document breaking change in changelog
  • Loading branch information
extrawurst committed May 22, 2024
1 parent 659ee74 commit 4f629f1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions THEMES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ Example theme override:

```
(
selection_bg: Some(Blue),
selection_fg: Some(White),
selection_bg: Some("Blue"),
selection_fg: Some("#ffffff"),
)
```

Note that you need to wrap values in `Some` due to the way the overrides work (as of 0.23).

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
Expand Down
13 changes: 8 additions & 5 deletions src/ui/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit 4f629f1

Please sign in to comment.