Skip to content

Commit e3bd1c1

Browse files
1wilkensStephan Dilly
authored and
Stephan Dilly
committed
Remove ui::style::ColorDef in favor up tui::style::Color (#391)
Closes #149.
1 parent 59eaca8 commit e3bd1c1

File tree

4 files changed

+18
-45
lines changed

4 files changed

+18
-45
lines changed

Cargo.lock

+1
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
@@ -23,7 +23,7 @@ scopetime = { path = "./scopetime", version = "0.1" }
2323
asyncgit = { path = "./asyncgit", version = "0.10" }
2424
crossterm = { version = "0.18", features = [ "serde" ] }
2525
clap = { version = "2.33", default-features = false }
26-
tui = { version = "0.12", default-features = false, features = ['crossterm'] }
26+
tui = { version = "0.12", default-features = false, features = ['crossterm', 'serde'] }
2727
bytesize = { version = "1.0.1", default-features = false}
2828
itertools = "0.9"
2929
rayon-core = "1.9"

THEMES.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Themes
1+
# Themes
22

33
default on light terminal:
44
![](assets/light-theme.png)
@@ -10,5 +10,4 @@ to change the colors of the program you have to modify `theme.ron` file
1010
* `$XDG_CONFIG_HOME/gitui/theme.ron` (linux using XDG)
1111
* `$HOME/.config/gitui/theme.ron` (linux)
1212

13-
Valid colors can be found in [ColorDef](./src/ui/style.rs#ColorDef) struct. note that rgb colors might not be supported
14-
in every terminal.
13+
Valid colors can be found in tui-rs' [Color](https://docs.rs/tui/0.12.0/tui/style/enum.Color.html) struct. note that rgb colors might not be supported in every terminal.

src/ui/style.rs

+14-41
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,34 @@ pub type SharedTheme = Rc<Theme>;
1818

1919
#[derive(Serialize, Deserialize, Debug)]
2020
pub struct Theme {
21-
#[serde(with = "ColorDef")]
2221
selected_tab: Color,
23-
#[serde(with = "ColorDef")]
22+
#[serde(with = "Color")]
2423
command_fg: Color,
25-
#[serde(with = "ColorDef")]
24+
#[serde(with = "Color")]
2625
selection_bg: Color,
27-
#[serde(with = "ColorDef")]
26+
#[serde(with = "Color")]
2827
cmdbar_extra_lines_bg: Color,
29-
#[serde(with = "ColorDef")]
28+
#[serde(with = "Color")]
3029
disabled_fg: Color,
31-
#[serde(with = "ColorDef")]
30+
#[serde(with = "Color")]
3231
diff_line_add: Color,
33-
#[serde(with = "ColorDef")]
32+
#[serde(with = "Color")]
3433
diff_line_delete: Color,
35-
#[serde(with = "ColorDef")]
34+
#[serde(with = "Color")]
3635
diff_file_added: Color,
37-
#[serde(with = "ColorDef")]
36+
#[serde(with = "Color")]
3837
diff_file_removed: Color,
39-
#[serde(with = "ColorDef")]
38+
#[serde(with = "Color")]
4039
diff_file_moved: Color,
41-
#[serde(with = "ColorDef")]
40+
#[serde(with = "Color")]
4241
diff_file_modified: Color,
43-
#[serde(with = "ColorDef")]
42+
#[serde(with = "Color")]
4443
commit_hash: Color,
45-
#[serde(with = "ColorDef")]
44+
#[serde(with = "Color")]
4645
commit_time: Color,
47-
#[serde(with = "ColorDef")]
46+
#[serde(with = "Color")]
4847
commit_author: Color,
49-
#[serde(with = "ColorDef")]
48+
#[serde(with = "Color")]
5049
danger_fg: Color,
5150
}
5251

@@ -266,29 +265,3 @@ impl Default for Theme {
266265
}
267266
}
268267
}
269-
270-
/// we duplicate the Color definition from `tui` crate to implement Serde serialisation
271-
/// this enum can be removed once [tui-#292](https://github.com/fdehau/tui-rs/issues/292) is resolved
272-
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
273-
#[serde(remote = "Color")]
274-
enum ColorDef {
275-
Reset,
276-
Black,
277-
Red,
278-
Green,
279-
Yellow,
280-
Blue,
281-
Magenta,
282-
Cyan,
283-
Gray,
284-
DarkGray,
285-
LightRed,
286-
LightGreen,
287-
LightYellow,
288-
LightBlue,
289-
LightMagenta,
290-
LightCyan,
291-
White,
292-
Rgb(u8, u8, u8),
293-
Indexed(u8),
294-
}

0 commit comments

Comments
 (0)