Skip to content

Commit bff6fba

Browse files
authored
Merge branch 'master' into feat/files_support_pageupdown
2 parents 9dd360c + 1563811 commit bff6fba

File tree

6 files changed

+66
-15
lines changed

6 files changed

+66
-15
lines changed

CHANGELOG.md

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

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

Cargo.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ scopetime = { path = "./scopetime", version = "0.1" }
5151
serde = "1.0"
5252
shellexpand = "3.1"
5353
simplelog = { version = "0.12", default-features = false }
54-
struct-patch = "0.8"
54+
struct-patch = "0.9"
5555
syntect = { version = "5.2", default-features = false, features = [
5656
"parsing",
5757
"default-syntaxes",

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
.PHONY: debug build-release release-linux-musl test clippy clippy-pedantic install install-debug
2+
.PHONY: debug build-release release-linux-musl test clippy clippy-pedantic install install-debug sort
33

44
ARGS=-l
55
# ARGS=-l -d ~/code/extern/kubernetes
@@ -94,7 +94,7 @@ clippy:
9494
clippy-nightly:
9595
cargo +nightly clippy --workspace --all-features
9696

97-
check: fmt clippy test deny
97+
check: fmt clippy test deny sort
9898

9999
check-nightly:
100100
cargo +nightly c
@@ -104,6 +104,9 @@ check-nightly:
104104
deny:
105105
cargo deny check
106106

107+
sort:
108+
cargo sort -c -w "."
109+
107110
install:
108111
cargo install --path "." --offline --locked
109112

THEMES.md

+42-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
default on light terminal:
44
![](assets/light-theme.png)
55

6+
## Configuration
7+
68
To change the colors of the default theme you need to add a `theme.ron` file that contains the colors you want to override. Note that you don’t have to specify the full theme anymore (as of 0.23). Instead, it is sufficient to override just the values that you want to differ from their default values.
79

810
The file uses the [Ron format](https://github.com/ron-rs/ron) and is located at one of the following paths, depending on your operating system:
@@ -16,7 +18,7 @@ Alternatively, you can create a theme in the same directory mentioned above and
1618

1719
Example theme override:
1820

19-
```
21+
```ron
2022
(
2123
selection_bg: Some("Blue"),
2224
selection_fg: Some("#ffffff"),
@@ -32,20 +34,57 @@ Notes:
3234
* valid colors can be found in ratatui's [Color](https://docs.rs/ratatui/latest/ratatui/style/enum.Color.html) struct.
3335
* all customizable theme elements can be found in [`style.rs` in the `impl Default for Theme` block](https://github.com/gitui-org/gitui/blob/master/src/ui/style.rs#L305)
3436

37+
## Preset Themes
38+
39+
You can find preset themes by Catppuccin [here](https://github.com/catppuccin/gitui.git).
40+
41+
## Syntax Highlighting
42+
43+
The syntax highlighting theme can be defined using the element `syntax`. Both [default themes of the syntect library](https://github.com/trishume/syntect/blob/7fe13c0fd53cdfa0f9fea1aa14c5ba37f81d8b71/src/dumps.rs#L215) and custom themes are supported.
44+
45+
Example syntax theme:
46+
```ron
47+
(
48+
syntax: Some("InspiredGitHub"),
49+
)
50+
```
51+
52+
Custom themes are located in the [configuration directory](#configuration), are using TextMate's theme format and must have a `.tmTheme` file extension. To load a custom theme, `syntax` must be set to the file name without the file extension. For example, to load [`Blackboard.tmTheme`](https://raw.githubusercontent.com/filmgirl/TextMate-Themes/refs/heads/master/Blackboard.tmTheme), place the file next to `theme.ron` and set:
53+
```ron
54+
(
55+
syntax: Some("Blackboard"),
56+
)
57+
```
58+
59+
[filmgirl/TextMate-Themes](https://github.com/filmgirl/TextMate-Themes) offers many [beautiful](https://inkdeep.github.io/TextMate-Themes) TextMate themes to choose from.
60+
3561
## Customizing line breaks
3662

3763
If you want to change how the line break is displayed in the diff, you can also specify `line_break` in your `theme.ron`:
3864

39-
```
65+
```ron
4066
(
4167
line_break: Some("¶"),
4268
)
4369
```
4470

4571
Note that if you want to turn it off, you should use a blank string:
4672

47-
```
73+
```ron
4874
(
4975
line_break: Some(""),
5076
)
5177
```
78+
## Customizing selection
79+
80+
By default the `selection_fg` color is used to color the text of the selected line.
81+
Diff line, filename, commit hashes, time and author are re-colored with `selection_fg` color.
82+
This can be changed by specifying the `use_selection_fg` boolean in your `theme.ron`:
83+
84+
```
85+
(
86+
use_selection_fg: Some(false),
87+
)
88+
```
89+
90+
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)