Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Select syntax highlighting theme out of the defaults from syntect [[@vasilismanol](https://github.com/vasilismanol)] ([#1931](https://github.com/extrawurst/gitui/issues/1931))
* new command-line option to override the default log file path (`--logfile`) [[@acuteenvy](https://github.com/acuteenvy)] ([#2539](https://github.com/gitui-org/gitui/pull/2539))
* dx: `make check` checks Cargo.toml dependency ordering using `cargo sort` [[@naseschwarz](https://github.com/naseschwarz)]
* add `use_selection_fg` to theme file to allow customizing selection foreground color [[@Upsylonbare](https://github.com/Upsylonbare)] ([#2515](https://github.com/gitui-org/gitui/pull/2515))

### Changed
* improve syntax highlighting file detection [[@acuteenvy](https://github.com/acuteenvy)] ([#2524](https://github.com/extrawurst/gitui/pull/2524))
Expand Down
13 changes: 13 additions & 0 deletions THEMES.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,16 @@ Note that if you want to turn it off, you should use a blank string:
line_break: Some(""),
)
```
## Customizing selection

By default the `selection_fg` color is used to color the text of the selected line.
Diff line, filename, commit hashes, time and author are re-colored with `selection_fg` color.
This can be changed by specifying the `use_selection_fg` boolean in your `theme.ron`:

```
(
use_selection_fg: Some(false),
)
```

By default, `use_selection_fg` is set to `true`.
9 changes: 8 additions & 1 deletion src/ui/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Theme {
command_fg: Color,
selection_bg: Color,
selection_fg: Color,
use_selection_fg: bool,
cmdbar_bg: Color,
cmdbar_extra_lines_bg: Color,
disabled_fg: Color,
Expand Down Expand Up @@ -151,7 +152,11 @@ impl Theme {
selected: bool,
) -> Style {
if selected {
style.bg(self.selection_bg).fg(self.selection_fg)
if self.use_selection_fg {
style.bg(self.selection_bg).fg(self.selection_fg)
} else {
style.bg(self.selection_bg)
}
} else {
style
}
Expand Down Expand Up @@ -340,6 +345,7 @@ impl Default for Theme {
command_fg: Color::White,
selection_bg: Color::Blue,
selection_fg: Color::White,
use_selection_fg: true,
cmdbar_bg: Color::Blue,
cmdbar_extra_lines_bg: Color::Blue,
disabled_fg: Color::DarkGray,
Expand Down Expand Up @@ -387,6 +393,7 @@ mod tests {
(
selection_bg: Some("Black"),
selection_fg: Some("#ffffff"),
use_selection_fg: Some(false),
syntax: Some("InspiredGitHub")
)
"##
Expand Down