Added misc_info_dialog to themes

This commit is contained in:
veeso 2021-09-19 10:48:16 +02:00
parent ed3225ed84
commit 88a0685097
16 changed files with 67 additions and 9 deletions

View File

@ -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 `<CTRL+R>`, 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`

View File

@ -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 <theme_file>`. 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 <theme.toml>
```
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 |

View File

@ -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"

View File

@ -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);

View File

@ -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;
}

View File

@ -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";

View File

@ -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

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"