Skip to content

Commit 65b57c4

Browse files
authored
feat(ui): Add use_selection_fg flag to control selection foreground color (#2515)
1 parent dcd9a00 commit 65b57c4

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* Select syntax highlighting theme out of the defaults from syntect [[@vasilismanol](https://github.com/vasilismanol)] ([#1931](https://github.com/extrawurst/gitui/issues/1931))
1313
* 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))
1414
* dx: `make check` checks Cargo.toml dependency ordering using `cargo sort` [[@naseschwarz](https://github.com/naseschwarz)]
15+
* 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))
1516

1617
### Changed
1718
* improve syntax highlighting file detection [[@acuteenvy](https://github.com/acuteenvy)] ([#2524](https://github.com/extrawurst/gitui/pull/2524))

THEMES.md

+13
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,16 @@ Note that if you want to turn it off, you should use a blank string:
4949
line_break: Some(""),
5050
)
5151
```
52+
## Customizing selection
53+
54+
By default the `selection_fg` color is used to color the text of the selected line.
55+
Diff line, filename, commit hashes, time and author are re-colored with `selection_fg` color.
56+
This can be changed by specifying the `use_selection_fg` boolean in your `theme.ron`:
57+
58+
```
59+
(
60+
use_selection_fg: Some(false),
61+
)
62+
```
63+
64+
By default, `use_selection_fg` is set to `true`.

src/ui/style.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct Theme {
1616
command_fg: Color,
1717
selection_bg: Color,
1818
selection_fg: Color,
19+
use_selection_fg: bool,
1920
cmdbar_bg: Color,
2021
cmdbar_extra_lines_bg: Color,
2122
disabled_fg: Color,
@@ -151,7 +152,11 @@ impl Theme {
151152
selected: bool,
152153
) -> Style {
153154
if selected {
154-
style.bg(self.selection_bg).fg(self.selection_fg)
155+
if self.use_selection_fg {
156+
style.bg(self.selection_bg).fg(self.selection_fg)
157+
} else {
158+
style.bg(self.selection_bg)
159+
}
155160
} else {
156161
style
157162
}
@@ -340,6 +345,7 @@ impl Default for Theme {
340345
command_fg: Color::White,
341346
selection_bg: Color::Blue,
342347
selection_fg: Color::White,
348+
use_selection_fg: true,
343349
cmdbar_bg: Color::Blue,
344350
cmdbar_extra_lines_bg: Color::Blue,
345351
disabled_fg: Color::DarkGray,
@@ -387,6 +393,7 @@ mod tests {
387393
(
388394
selection_bg: Some("Black"),
389395
selection_fg: Some("#ffffff"),
396+
use_selection_fg: Some(false),
390397
syntax: Some("InspiredGitHub")
391398
)
392399
"##

0 commit comments

Comments
 (0)