Remove ui::style::ColorDef in favor up tui::style::Color (#391)

Closes #149.
This commit is contained in:
Florian Wilkens 2020-10-31 12:26:30 +01:00 committed by GitHub
parent d0f59fa0bf
commit 21b7513f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 45 deletions

1
Cargo.lock generated
View File

@ -1282,6 +1282,7 @@ dependencies = [
"bitflags",
"cassowary",
"crossterm 0.17.7",
"serde",
"unicode-segmentation",
"unicode-width",
]

View File

@ -23,7 +23,7 @@ scopetime = { path = "./scopetime", version = "0.1" }
asyncgit = { path = "./asyncgit", version = "0.10" }
crossterm = { version = "0.18", features = [ "serde" ] }
clap = { version = "2.33", default-features = false }
tui = { version = "0.12", default-features = false, features = ['crossterm'] }
tui = { version = "0.12", default-features = false, features = ['crossterm', 'serde'] }
bytesize = { version = "1.0.1", default-features = false}
itertools = "0.9"
rayon-core = "1.9"

View File

@ -1,4 +1,4 @@
# Themes
# Themes
default on light terminal:
![](assets/light-theme.png)
@ -10,5 +10,4 @@ to change the colors of the program you have to modify `theme.ron` file
* `$XDG_CONFIG_HOME/gitui/theme.ron` (linux using XDG)
* `$HOME/.config/gitui/theme.ron` (linux)
Valid colors can be found in [ColorDef](./src/ui/style.rs#ColorDef) struct. note that rgb colors might not be supported
in every terminal.
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.

View File

@ -18,35 +18,34 @@ pub type SharedTheme = Rc<Theme>;
#[derive(Serialize, Deserialize, Debug)]
pub struct Theme {
#[serde(with = "ColorDef")]
selected_tab: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
command_fg: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
selection_bg: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
cmdbar_extra_lines_bg: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
disabled_fg: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
diff_line_add: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
diff_line_delete: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
diff_file_added: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
diff_file_removed: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
diff_file_moved: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
diff_file_modified: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
commit_hash: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
commit_time: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
commit_author: Color,
#[serde(with = "ColorDef")]
#[serde(with = "Color")]
danger_fg: Color,
}
@ -266,29 +265,3 @@ impl Default for Theme {
}
}
}
/// we duplicate the Color definition from `tui` crate to implement Serde serialisation
/// this enum can be removed once [tui-#292](https://github.com/fdehau/tui-rs/issues/292) is resolved
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
#[serde(remote = "Color")]
enum ColorDef {
Reset,
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
Gray,
DarkGray,
LightRed,
LightGreen,
LightYellow,
LightBlue,
LightMagenta,
LightCyan,
White,
Rgb(u8, u8, u8),
Indexed(u8),
}