From 88a0685097f887a5d6657730020f7bc028bd9495 Mon Sep 17 00:00:00 2001 From: veeso Date: Sun, 19 Sep 2021 10:48:16 +0200 Subject: [PATCH] Added misc_info_dialog to themes --- CHANGELOG.md | 2 ++ docs/man.md | 20 ++++++++++++++++++++ src/config/serialization.rs | 1 + src/config/themes.rs | 7 +++++++ src/ui/activities/setup/actions.rs | 3 +++ src/ui/activities/setup/mod.rs | 1 + src/ui/activities/setup/update.rs | 14 +++++++++++--- src/ui/activities/setup/view/theme.rs | 20 ++++++++++++++------ themes/default.toml | 1 + themes/earth-wind-fire.toml | 1 + themes/horizon.toml | 1 + themes/mono-bright.toml | 1 + themes/mono-dark.toml | 1 + themes/sugarplum.toml | 1 + themes/ubuntu.toml | 1 + themes/veeso.toml | 1 + 16 files changed, 67 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1176c67..de2a054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ Released on ?? - Possibility to update termscp directly via GUI or CLI. - Install update via CLI running `(sudo) termscp --update`. - Install update via GUI from auth form: when the "new version message" is displayed press ``, then enter `YES` in the radio input asking whether to install the update. +- **❗ BREAKING CHANGES ❗**: + - Added a new key in themes: `misc_info_dialog`: if your theme won't load, just reload it. If you're using a customised theme, you can add to it the missing key via a text editor. Just edit the `theme.toml` in your `$CONFIG_DIR/termscp/theme.toml` and add `misc_info_dialog` (Read more in manual at Themes). - Dependencies: - Added `rust-s3 0.27-rc4` - Added `self_update 0.27.0` diff --git a/docs/man.md b/docs/man.md index f998947..0c84387 100644 --- a/docs/man.md +++ b/docs/man.md @@ -19,6 +19,7 @@ - [SSH Key Storage 🔐](#ssh-key-storage-) - [File Explorer Format](#file-explorer-format) - [Themes 🎨](#themes-) + - [My theme won't load 😱](#my-theme-wont-load-) - [Styles 💈](#styles-) - [Authentication page](#authentication-page) - [Transfer page](#transfer-page) @@ -360,6 +361,24 @@ termscp supports both the traditional explicit hex (`#rrggbb`) and rgb `rgb(r, g As said before, you can also import theme files. You can take inspiration from or directly use one of the themes provided along with termscp, located in the `themes/` directory of this repository and import them running termscp as `termscp -t `. If everything was fine, it should tell you the theme has successfully been imported. +### My theme won't load 😱 + +This is probably due to a recent update which has broken the theme. Whenever I add a new key to themes, the saved theme won't load. To fix this issues there are two really quick-fix solutions: + +1. Reload theme: whenever I release an update I will also patch the "official" themes, so you just have to download it from the repository again and re-import the theme via `-t` option + + ```sh + termscp -t + ``` + +2. Fix your theme: If you're using a custom theme, then you can edit via `vim` and add the missing key. The theme is located at `$CONFIG_DIR/termscp/theme.toml` where `$CONFIG_DIR` is: + + - FreeBSD/GNU-Linux: `$HOME/.config/` + - MacOs: `$HOME/Library/Application Support` + - Windows: `%appdata%` + + ❗ Missing keys are reported in the CHANGELOG under `BREAKING CHANGES` for the version you've just installed. + ### Styles 💈 You can find in the table below, the description for each style field. @@ -402,6 +421,7 @@ These styles applie to different part of the application. | Key | Description | |-------------------|---------------------------------------------| | misc_error_dialog | Color for error messages | +| misc_info_dialog | Color for info dialogs | | misc_input_dialog | Color for input dialogs (such as copy file) | | misc_keys | Color of text for key strokes | | misc_quit_dialog | Color for quit dialogs | diff --git a/src/config/serialization.rs b/src/config/serialization.rs index 6505c3a..57e8c1d 100644 --- a/src/config/serialization.rs +++ b/src/config/serialization.rs @@ -556,6 +556,7 @@ mod tests { auth_recents = "LightBlue" auth_username = "LightMagenta" misc_error_dialog = "Red" + misc_info_dialog = "LightYellow" misc_input_dialog = "240,240,240" misc_keys = "Cyan" misc_quit_dialog = "Yellow" diff --git a/src/config/themes.rs b/src/config/themes.rs index 39776d8..8b6f54e 100644 --- a/src/config/themes.rs +++ b/src/config/themes.rs @@ -83,6 +83,11 @@ pub struct Theme { deserialize_with = "deserialize_color", serialize_with = "serialize_color" )] + pub misc_info_dialog: Color, + #[serde( + deserialize_with = "deserialize_color", + serialize_with = "serialize_color" + )] pub misc_input_dialog: Color, #[serde( deserialize_with = "deserialize_color", @@ -183,6 +188,7 @@ impl Default for Theme { auth_recents: Color::LightBlue, auth_username: Color::LightMagenta, misc_error_dialog: Color::Red, + misc_info_dialog: Color::LightYellow, misc_input_dialog: Color::Reset, misc_keys: Color::Cyan, misc_quit_dialog: Color::Yellow, @@ -245,6 +251,7 @@ mod test { assert_eq!(theme.auth_recents, Color::LightBlue); assert_eq!(theme.auth_username, Color::LightMagenta); assert_eq!(theme.misc_error_dialog, Color::Red); + assert_eq!(theme.misc_info_dialog, Color::LightYellow); assert_eq!(theme.misc_input_dialog, Color::Reset); assert_eq!(theme.misc_keys, Color::Cyan); assert_eq!(theme.misc_quit_dialog, Color::Yellow); diff --git a/src/ui/activities/setup/actions.rs b/src/ui/activities/setup/actions.rs index 7bf2b3f..b49753c 100644 --- a/src/ui/activities/setup/actions.rs +++ b/src/ui/activities/setup/actions.rs @@ -254,6 +254,9 @@ impl SetupActivity { super::COMPONENT_COLOR_MISC_ERROR => { theme.misc_error_dialog = color; } + super::COMPONENT_COLOR_MISC_INFO => { + theme.misc_info_dialog = color; + } super::COMPONENT_COLOR_MISC_INPUT => { theme.misc_input_dialog = color; } diff --git a/src/ui/activities/setup/mod.rs b/src/ui/activities/setup/mod.rs index d615189..ec2b4ff 100644 --- a/src/ui/activities/setup/mod.rs +++ b/src/ui/activities/setup/mod.rs @@ -75,6 +75,7 @@ const COMPONENT_COLOR_AUTH_PROTOCOL: &str = "COMPONENT_COLOR_AUTH_PROTOCOL"; const COMPONENT_COLOR_AUTH_RECENTS: &str = "COMPONENT_COLOR_AUTH_RECENTS"; const COMPONENT_COLOR_AUTH_USERNAME: &str = "COMPONENT_COLOR_AUTH_USERNAME"; const COMPONENT_COLOR_MISC_ERROR: &str = "COMPONENT_COLOR_MISC_ERROR"; +const COMPONENT_COLOR_MISC_INFO: &str = "COMPONENT_COLOR_MISC_INFO"; const COMPONENT_COLOR_MISC_INPUT: &str = "COMPONENT_COLOR_MISC_INPUT"; const COMPONENT_COLOR_MISC_KEYS: &str = "COMPONENT_COLOR_MISC_KEYS"; const COMPONENT_COLOR_MISC_QUIT: &str = "COMPONENT_COLOR_MISC_QUIT"; diff --git a/src/ui/activities/setup/update.rs b/src/ui/activities/setup/update.rs index 06593e8..ffe5600 100644 --- a/src/ui/activities/setup/update.rs +++ b/src/ui/activities/setup/update.rs @@ -31,8 +31,8 @@ use super::{ SetupActivity, ViewLayout, COMPONENT_COLOR_AUTH_ADDR, COMPONENT_COLOR_AUTH_BOOKMARKS, COMPONENT_COLOR_AUTH_PASSWORD, COMPONENT_COLOR_AUTH_PORT, COMPONENT_COLOR_AUTH_PROTOCOL, COMPONENT_COLOR_AUTH_RECENTS, COMPONENT_COLOR_AUTH_USERNAME, COMPONENT_COLOR_MISC_ERROR, - COMPONENT_COLOR_MISC_INPUT, COMPONENT_COLOR_MISC_KEYS, COMPONENT_COLOR_MISC_QUIT, - COMPONENT_COLOR_MISC_SAVE, COMPONENT_COLOR_MISC_WARN, + COMPONENT_COLOR_MISC_INFO, COMPONENT_COLOR_MISC_INPUT, COMPONENT_COLOR_MISC_KEYS, + COMPONENT_COLOR_MISC_QUIT, COMPONENT_COLOR_MISC_SAVE, COMPONENT_COLOR_MISC_WARN, COMPONENT_COLOR_TRANSFER_EXPLORER_LOCAL_BG, COMPONENT_COLOR_TRANSFER_EXPLORER_LOCAL_FG, COMPONENT_COLOR_TRANSFER_EXPLORER_LOCAL_HG, COMPONENT_COLOR_TRANSFER_EXPLORER_REMOTE_BG, COMPONENT_COLOR_TRANSFER_EXPLORER_REMOTE_FG, COMPONENT_COLOR_TRANSFER_EXPLORER_REMOTE_HG, @@ -441,6 +441,10 @@ impl SetupActivity { None } (COMPONENT_COLOR_MISC_ERROR, key) if key == &MSG_KEY_DOWN => { + self.view.active(COMPONENT_COLOR_MISC_INFO); + None + } + (COMPONENT_COLOR_MISC_INFO, key) if key == &MSG_KEY_DOWN => { self.view.active(COMPONENT_COLOR_MISC_INPUT); None } @@ -551,10 +555,14 @@ impl SetupActivity { self.view.active(COMPONENT_COLOR_AUTH_RECENTS); None } - (COMPONENT_COLOR_MISC_INPUT, key) if key == &MSG_KEY_UP => { + (COMPONENT_COLOR_MISC_INFO, key) if key == &MSG_KEY_UP => { self.view.active(COMPONENT_COLOR_MISC_ERROR); None } + (COMPONENT_COLOR_MISC_INPUT, key) if key == &MSG_KEY_UP => { + self.view.active(COMPONENT_COLOR_MISC_INFO); + None + } (COMPONENT_COLOR_MISC_KEYS, key) if key == &MSG_KEY_UP => { self.view.active(COMPONENT_COLOR_MISC_INPUT); None diff --git a/src/ui/activities/setup/view/theme.rs b/src/ui/activities/setup/view/theme.rs index 8f7264a..2c51034 100644 --- a/src/ui/activities/setup/view/theme.rs +++ b/src/ui/activities/setup/view/theme.rs @@ -70,6 +70,7 @@ impl SetupActivity { // Misc self.mount_title(super::COMPONENT_COLOR_MISC_TITLE, "Misc styles"); self.mount_color_picker(super::COMPONENT_COLOR_MISC_ERROR, "Error"); + self.mount_color_picker(super::COMPONENT_COLOR_MISC_INFO, "Info dialogs"); self.mount_color_picker(super::COMPONENT_COLOR_MISC_INPUT, "Input fields"); self.mount_color_picker(super::COMPONENT_COLOR_MISC_KEYS, "Key strokes"); self.mount_color_picker(super::COMPONENT_COLOR_MISC_QUIT, "Quit dialogs"); @@ -222,12 +223,12 @@ impl SetupActivity { [ Constraint::Length(1), // Title Constraint::Length(3), // Error + Constraint::Length(3), // Info Constraint::Length(3), // Input Constraint::Length(3), // Keys Constraint::Length(3), // Quit Constraint::Length(3), // Save Constraint::Length(3), // Warn - Constraint::Length(3), // Empty ] .as_ref(), ) @@ -237,15 +238,17 @@ impl SetupActivity { self.view .render(super::COMPONENT_COLOR_MISC_ERROR, f, misc_colors_layout[1]); self.view - .render(super::COMPONENT_COLOR_MISC_INPUT, f, misc_colors_layout[2]); + .render(super::COMPONENT_COLOR_MISC_INFO, f, misc_colors_layout[2]); self.view - .render(super::COMPONENT_COLOR_MISC_KEYS, f, misc_colors_layout[3]); + .render(super::COMPONENT_COLOR_MISC_INPUT, f, misc_colors_layout[3]); self.view - .render(super::COMPONENT_COLOR_MISC_QUIT, f, misc_colors_layout[4]); + .render(super::COMPONENT_COLOR_MISC_KEYS, f, misc_colors_layout[4]); self.view - .render(super::COMPONENT_COLOR_MISC_SAVE, f, misc_colors_layout[5]); + .render(super::COMPONENT_COLOR_MISC_QUIT, f, misc_colors_layout[5]); self.view - .render(super::COMPONENT_COLOR_MISC_WARN, f, misc_colors_layout[6]); + .render(super::COMPONENT_COLOR_MISC_SAVE, f, misc_colors_layout[6]); + self.view + .render(super::COMPONENT_COLOR_MISC_WARN, f, misc_colors_layout[7]); let transfer_colors_layout_col1 = Layout::default() .direction(Direction::Vertical) @@ -405,6 +408,7 @@ impl SetupActivity { self.update_color(super::COMPONENT_COLOR_AUTH_RECENTS, theme.auth_recents); self.update_color(super::COMPONENT_COLOR_AUTH_USERNAME, theme.auth_username); self.update_color(super::COMPONENT_COLOR_MISC_ERROR, theme.misc_error_dialog); + self.update_color(super::COMPONENT_COLOR_MISC_INFO, theme.misc_info_dialog); self.update_color(super::COMPONENT_COLOR_MISC_INPUT, theme.misc_input_dialog); self.update_color(super::COMPONENT_COLOR_MISC_KEYS, theme.misc_keys); self.update_color(super::COMPONENT_COLOR_MISC_QUIT, theme.misc_quit_dialog); @@ -495,6 +499,9 @@ impl SetupActivity { let misc_error_dialog: Color = self .get_color(super::COMPONENT_COLOR_MISC_ERROR) .map_err(|_| super::COMPONENT_COLOR_MISC_ERROR)?; + let misc_info_dialog: Color = self + .get_color(super::COMPONENT_COLOR_MISC_INFO) + .map_err(|_| super::COMPONENT_COLOR_MISC_INFO)?; let misc_input_dialog: Color = self .get_color(super::COMPONENT_COLOR_MISC_INPUT) .map_err(|_| super::COMPONENT_COLOR_MISC_INPUT)?; @@ -560,6 +567,7 @@ impl SetupActivity { theme.auth_recents = auth_recents; theme.auth_username = auth_username; theme.misc_error_dialog = misc_error_dialog; + theme.misc_info_dialog = misc_info_dialog; theme.misc_input_dialog = misc_input_dialog; theme.misc_keys = misc_keys; theme.misc_quit_dialog = misc_quit_dialog; diff --git a/themes/default.toml b/themes/default.toml index 273533d..9f54d04 100644 --- a/themes/default.toml +++ b/themes/default.toml @@ -6,6 +6,7 @@ auth_protocol = "LightGreen" auth_recents = "LightBlue" auth_username = "LightMagenta" misc_error_dialog = "Red" +misc_info_dialog = "LightYellow" misc_input_dialog = "Default" misc_keys = "Cyan" misc_quit_dialog = "Yellow" diff --git a/themes/earth-wind-fire.toml b/themes/earth-wind-fire.toml index 9ad776c..c31d16a 100644 --- a/themes/earth-wind-fire.toml +++ b/themes/earth-wind-fire.toml @@ -6,6 +6,7 @@ auth_protocol = "orangered" auth_recents = "deepskyblue" auth_username = "aqua" misc_error_dialog = "crimson" +misc_info_dialog = "LightYellow" misc_input_dialog = "turquoise" misc_keys = "deeppink" misc_quit_dialog = "lime" diff --git a/themes/horizon.toml b/themes/horizon.toml index b793cdb..97bfbfd 100644 --- a/themes/horizon.toml +++ b/themes/horizon.toml @@ -6,6 +6,7 @@ auth_protocol = "coral" auth_recents = "royalblue" auth_username = "orangered" misc_error_dialog = "crimson" +misc_info_dialog = "coral" misc_input_dialog = "gold" misc_keys = "deeppink" misc_quit_dialog = "coral" diff --git a/themes/mono-bright.toml b/themes/mono-bright.toml index 86f695c..9b8d8d7 100644 --- a/themes/mono-bright.toml +++ b/themes/mono-bright.toml @@ -6,6 +6,7 @@ auth_protocol = "black" auth_recents = "#bbbbbb" auth_username = "black" misc_error_dialog = "black" +misc_info_dialog = "black" misc_input_dialog = "black" misc_keys = "black" misc_quit_dialog = "black" diff --git a/themes/mono-dark.toml b/themes/mono-dark.toml index 7fb9e01..15b93f4 100644 --- a/themes/mono-dark.toml +++ b/themes/mono-dark.toml @@ -6,6 +6,7 @@ auth_protocol = "white" auth_recents = "white" auth_username = "white" misc_error_dialog = "white" +misc_info_dialog = "white" misc_input_dialog = "white" misc_keys = "white" misc_quit_dialog = "white" diff --git a/themes/sugarplum.toml b/themes/sugarplum.toml index 2cd9fc6..0ecb617 100644 --- a/themes/sugarplum.toml +++ b/themes/sugarplum.toml @@ -6,6 +6,7 @@ auth_protocol = "deeppink" auth_recents = "lightpink" auth_username = "orchid" misc_error_dialog = "mediumvioletred" +misc_info_dialog = "plum" misc_input_dialog = "plum" misc_keys = "deeppink" misc_quit_dialog = "lightcoral" diff --git a/themes/ubuntu.toml b/themes/ubuntu.toml index 01e3bf1..0fb50fd 100644 --- a/themes/ubuntu.toml +++ b/themes/ubuntu.toml @@ -6,6 +6,7 @@ auth_protocol = "LightGreen" auth_recents = "aquamarine" auth_username = "hotpink" misc_error_dialog = "orangered" +misc_info_dialog = "LightYellow" misc_input_dialog = "snow" misc_keys = "LightCyan" misc_quit_dialog = "LightYellow" diff --git a/themes/veeso.toml b/themes/veeso.toml index c3b829d..c393382 100644 --- a/themes/veeso.toml +++ b/themes/veeso.toml @@ -6,6 +6,7 @@ auth_protocol = "greenyellow" auth_recents = "paleturquoise" auth_username = "deeppink" misc_error_dialog = "crimson" +misc_info_dialog = "SkyBlue" misc_input_dialog = "snow" misc_keys = "deeppink" misc_quit_dialog = "tomato"