diff --git a/rm-config/defaults/config.toml b/rm-config/defaults/config.toml index 30d2b05..0d8cca8 100644 --- a/rm-config/defaults/config.toml +++ b/rm-config/defaults/config.toml @@ -38,3 +38,29 @@ headers = ["Name", "SizeWhenDone", "Progress", "Eta", "DownloadRate", "UploadRat # If you uncomment this, providers won't be automatically added in future # versions of Rustmission. # providers = ["Knaben", "Nyaa"] + +[icons] +# Ascii alternatives # Defaults +# upload = "↑" # "" +# download = "↓" # "" +# arrow_left = "←" # "" +# arrow_right = "→" # "" +# arrow_up = "↑" # "" +# arrow_down = "↓" # "" +# triangle_right = "▶" # "▶" +# triangle_down = "▼" # "▼" +# file = "∷" # "" +# disk = "[D]" # "󰋊" +# help = "[?]" # "󰘥" +# success = "✔" # "" +# failure = "✖" # "" +# searching = "⟳" # "" +# verifying = "⟳" # "󰑓" +# loading = "⌛" # "󱥸" +# pause = "‖" # "󰏤" +# idle = "○" # "󱗼" +# magnifying_glass = "[o]" # "" +# provider_disabled = "⛔" # "󰪎" +# provider_category_general = "[G]" # "" +# provider_category_anime = "[A]" # "󰎁" + diff --git a/rm-config/src/keymap/mod.rs b/rm-config/src/keymap/mod.rs index 3985e70..f7c3882 100644 --- a/rm-config/src/keymap/mod.rs +++ b/rm-config/src/keymap/mod.rs @@ -12,7 +12,10 @@ use serde::{ Deserialize, Serialize, }; -use crate::utils::{self, ConfigFetchingError}; +use crate::{ + utils::{self, ConfigFetchingError}, + CONFIG, +}; use rm_shared::action::Action; use self::actions::{general::GeneralAction, torrents_tab::TorrentsAction}; @@ -36,7 +39,7 @@ pub struct KeybindsHolder> { } #[derive(Serialize, Clone)] -pub struct Keybinding> { +pub struct Keybinding { pub on: KeyCode, #[serde(default)] pub modifier: KeyModifier, @@ -49,10 +52,10 @@ impl> Keybinding { let key = match self.on { KeyCode::Backspace => "Backspace".into(), KeyCode::Enter => "Enter".into(), - KeyCode::Left => "".into(), - KeyCode::Right => "".into(), - KeyCode::Up => "".into(), - KeyCode::Down => "".into(), + KeyCode::Left => CONFIG.icons.arrow_left.clone(), + KeyCode::Right => CONFIG.icons.arrow_right.clone(), + KeyCode::Up => CONFIG.icons.arrow_up.clone(), + KeyCode::Down => CONFIG.icons.arrow_down.clone(), KeyCode::Home => "Home".into(), KeyCode::End => "End".into(), KeyCode::PageUp => "PageUp".into(), @@ -90,7 +93,7 @@ impl> Keybinding { } } -impl> Keybinding { +impl Keybinding { fn new(on: KeyCode, action: T, modifier: Option, show_in_help: bool) -> Self { Self { on, @@ -101,7 +104,7 @@ impl> Keybinding { } } -impl<'de, T: Into + Deserialize<'de>> Deserialize<'de> for Keybinding { +impl<'de, T: Deserialize<'de>> Deserialize<'de> for Keybinding { fn deserialize(deserializer: D) -> std::prelude::v1::Result where D: serde::Deserializer<'de>, @@ -119,7 +122,7 @@ impl<'de, T: Into + Deserialize<'de>> Deserialize<'de> for Keybinding phantom: PhantomData, } - impl<'de, T: Into + Deserialize<'de>> Visitor<'de> for KeybindingVisitor { + impl<'de, T: Deserialize<'de>> Visitor<'de> for KeybindingVisitor { type Value = Keybinding; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/rm-config/src/lib.rs b/rm-config/src/lib.rs index 2853d32..0506ac6 100644 --- a/rm-config/src/lib.rs +++ b/rm-config/src/lib.rs @@ -20,6 +20,7 @@ pub struct Config { pub connection: main_config::Connection, pub torrents_tab: main_config::TorrentsTab, pub search_tab: main_config::SearchTab, + pub icons: main_config::Icons, pub keybindings: KeymapConfig, pub directories: Directories, } @@ -44,6 +45,7 @@ impl Config { connection: main_config.connection, torrents_tab: main_config.torrents_tab, search_tab: main_config.search_tab, + icons: main_config.icons, keybindings: keybindings.clone(), directories, }) diff --git a/rm-config/src/main_config.rs b/rm-config/src/main_config.rs deleted file mode 100644 index b1d6960..0000000 --- a/rm-config/src/main_config.rs +++ /dev/null @@ -1,129 +0,0 @@ -use std::{io::ErrorKind, path::PathBuf, sync::OnceLock}; - -use anyhow::{Context, Result}; -use magnetease::WhichProvider; -use ratatui::style::Color; -use rm_shared::header::Header; -use serde::Deserialize; -use url::Url; - -use crate::utils::{self, ConfigFetchingError}; - -#[derive(Deserialize)] -pub struct MainConfig { - pub general: General, - pub connection: Connection, - #[serde(default)] - pub torrents_tab: TorrentsTab, - #[serde(default)] - pub search_tab: SearchTab, -} - -#[derive(Deserialize)] -pub struct General { - #[serde(default)] - pub auto_hide: bool, - #[serde(default = "default_accent_color")] - pub accent_color: Color, - #[serde(default = "default_beginner_mode")] - pub beginner_mode: bool, - #[serde(default)] - pub headers_hide: bool, -} - -fn default_accent_color() -> Color { - Color::LightMagenta -} - -fn default_beginner_mode() -> bool { - true -} - -#[derive(Deserialize)] -pub struct Connection { - pub username: Option, - pub password: Option, - pub url: Url, - #[serde(default = "default_refresh")] - pub torrents_refresh: u64, - #[serde(default = "default_refresh")] - pub stats_refresh: u64, - #[serde(default = "default_refresh")] - pub free_space_refresh: u64, -} - -fn default_refresh() -> u64 { - 5 -} - -#[derive(Deserialize)] -pub struct TorrentsTab { - #[serde(default = "default_headers")] - pub headers: Vec
, -} - -fn default_headers() -> Vec
{ - vec![ - Header::Name, - Header::SizeWhenDone, - Header::Progress, - Header::Eta, - Header::DownloadRate, - Header::UploadRate, - ] -} - -impl Default for TorrentsTab { - fn default() -> Self { - Self { - headers: default_headers(), - } - } -} - -#[derive(Deserialize)] -pub struct SearchTab { - pub providers: Vec, -} - -fn default_providers() -> Vec { - vec![WhichProvider::Knaben, WhichProvider::Nyaa] -} - -impl Default for SearchTab { - fn default() -> Self { - Self { - providers: default_providers(), - } - } -} - -impl MainConfig { - pub(crate) const FILENAME: &'static str = "config.toml"; - pub const DEFAULT_CONFIG: &'static str = include_str!("../defaults/config.toml"); - - pub(crate) fn init() -> Result { - match utils::fetch_config::(Self::FILENAME) { - Ok(config) => Ok(config), - Err(e) => match e { - ConfigFetchingError::Io(e) if e.kind() == ErrorKind::NotFound => { - utils::put_config::(Self::DEFAULT_CONFIG, Self::FILENAME)?; - println!("Update {:?} and start rustmission again", Self::path()); - std::process::exit(0); - } - ConfigFetchingError::Toml(e) => Err(e).with_context(|| { - format!( - "Failed to parse config located at {:?}", - utils::get_config_path(Self::FILENAME) - ) - }), - _ => anyhow::bail!(e), - }, - } - } - - pub(crate) fn path() -> &'static PathBuf { - static PATH: OnceLock = OnceLock::new(); - PATH.get_or_init(|| utils::get_config_path(Self::FILENAME)) - } -} diff --git a/rm-config/src/main_config/connection.rs b/rm-config/src/main_config/connection.rs new file mode 100644 index 0000000..42664d5 --- /dev/null +++ b/rm-config/src/main_config/connection.rs @@ -0,0 +1,19 @@ +use serde::Deserialize; +use url::Url; + +#[derive(Deserialize)] +pub struct Connection { + pub username: Option, + pub password: Option, + pub url: Url, + #[serde(default = "default_refresh")] + pub torrents_refresh: u64, + #[serde(default = "default_refresh")] + pub stats_refresh: u64, + #[serde(default = "default_refresh")] + pub free_space_refresh: u64, +} + +fn default_refresh() -> u64 { + 5 +} diff --git a/rm-config/src/main_config/general.rs b/rm-config/src/main_config/general.rs new file mode 100644 index 0000000..cc862d1 --- /dev/null +++ b/rm-config/src/main_config/general.rs @@ -0,0 +1,33 @@ +use ratatui::style::Color; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct General { + #[serde(default)] + pub auto_hide: bool, + #[serde(default = "default_accent_color")] + pub accent_color: Color, + #[serde(default = "default_beginner_mode")] + pub beginner_mode: bool, + #[serde(default)] + pub headers_hide: bool, +} + +impl Default for General { + fn default() -> Self { + Self { + auto_hide: false, + accent_color: default_accent_color(), + beginner_mode: default_beginner_mode(), + headers_hide: false, + } + } +} + +fn default_accent_color() -> Color { + Color::LightMagenta +} + +fn default_beginner_mode() -> bool { + true +} diff --git a/rm-config/src/main_config/icons.rs b/rm-config/src/main_config/icons.rs new file mode 100644 index 0000000..97d1abf --- /dev/null +++ b/rm-config/src/main_config/icons.rs @@ -0,0 +1,165 @@ +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct Icons { + #[serde(default = "default_upload")] + pub upload: String, + #[serde(default = "default_download")] + pub download: String, + #[serde(default = "default_arrow_left")] + pub arrow_left: String, + #[serde(default = "default_arrow_right")] + pub arrow_right: String, + #[serde(default = "default_arrow_up")] + pub arrow_up: String, + #[serde(default = "default_arrow_down")] + pub arrow_down: String, + #[serde(default = "default_triangle_right")] + pub triangle_right: String, + #[serde(default = "default_triangle_down")] + pub triangle_down: String, + #[serde(default = "default_file")] + pub file: String, + #[serde(default = "default_disk")] + pub disk: String, + #[serde(default = "default_help")] + pub help: String, + #[serde(default = "default_success")] + pub success: String, + #[serde(default = "default_failure")] + pub failure: String, + #[serde(default = "default_searching")] + pub searching: String, + #[serde(default = "default_verifying")] + pub verifying: String, + #[serde(default = "default_loading")] + pub loading: String, + #[serde(default = "default_pause")] + pub pause: String, + #[serde(default = "default_idle")] + pub idle: String, + #[serde(default = "default_magnifying_glass")] + pub magnifying_glass: String, + #[serde(default = "default_provider_disabled")] + pub provider_disabled: String, + #[serde(default = "default_provider_category_general")] + pub provider_category_general: String, + #[serde(default = "default_provider_category_anime")] + pub provider_category_anime: String, +} + +impl Default for Icons { + fn default() -> Self { + Self { + upload: default_upload(), + download: default_download(), + arrow_left: default_arrow_left(), + arrow_right: default_arrow_right(), + arrow_up: default_arrow_up(), + arrow_down: default_arrow_down(), + triangle_right: default_triangle_right(), + triangle_down: default_triangle_down(), + file: default_file(), + disk: default_disk(), + help: default_help(), + success: default_success(), + failure: default_failure(), + searching: default_searching(), + verifying: default_verifying(), + loading: default_loading(), + pause: default_pause(), + idle: default_idle(), + magnifying_glass: default_magnifying_glass(), + provider_disabled: default_provider_disabled(), + provider_category_general: default_provider_category_general(), + provider_category_anime: default_provider_category_anime(), + } + } +} +fn default_upload() -> String { + "".into() +} + +fn default_download() -> String { + "".into() +} + +fn default_arrow_left() -> String { + "".into() +} + +fn default_arrow_right() -> String { + "".into() +} + +fn default_arrow_up() -> String { + "".into() +} + +fn default_arrow_down() -> String { + "".into() +} + +fn default_triangle_right() -> String { + "▶".into() +} + +fn default_triangle_down() -> String { + "▼".into() +} + +fn default_file() -> String { + "".into() +} + +fn default_disk() -> String { + "󰋊".into() +} + +fn default_help() -> String { + "󰘥".into() +} + +fn default_success() -> String { + "".into() +} + +fn default_failure() -> String { + "".into() +} + +fn default_searching() -> String { + "".into() +} + +fn default_verifying() -> String { + "󰑓".into() +} + +fn default_loading() -> String { + "󱥸".into() +} + +fn default_pause() -> String { + "󰏤".into() +} + +fn default_idle() -> String { + "󱗼".into() +} + +fn default_magnifying_glass() -> String { + "".into() +} + +fn default_provider_disabled() -> String { + "󰪎".into() +} + +fn default_provider_category_general() -> String { + "".into() +} + +fn default_provider_category_anime() -> String { + "󰎁".into() +} diff --git a/rm-config/src/main_config/mod.rs b/rm-config/src/main_config/mod.rs new file mode 100644 index 0000000..2352c42 --- /dev/null +++ b/rm-config/src/main_config/mod.rs @@ -0,0 +1,61 @@ +mod connection; +mod general; +mod icons; +mod search_tab; +mod torrents_tab; + +pub use connection::Connection; +pub use general::General; +pub use icons::Icons; +pub use search_tab::SearchTab; +pub use torrents_tab::TorrentsTab; + +use std::{io::ErrorKind, path::PathBuf, sync::OnceLock}; + +use anyhow::{Context, Result}; +use serde::Deserialize; + +use crate::utils::{self, ConfigFetchingError}; + +#[derive(Deserialize)] +pub struct MainConfig { + #[serde(default)] + pub general: General, + pub connection: Connection, + #[serde(default)] + pub torrents_tab: TorrentsTab, + #[serde(default)] + pub search_tab: SearchTab, + #[serde(default)] + pub icons: Icons, +} + +impl MainConfig { + pub(crate) const FILENAME: &'static str = "config.toml"; + pub const DEFAULT_CONFIG: &'static str = include_str!("../../defaults/config.toml"); + + pub(crate) fn init() -> Result { + match utils::fetch_config::(Self::FILENAME) { + Ok(config) => Ok(config), + Err(e) => match e { + ConfigFetchingError::Io(e) if e.kind() == ErrorKind::NotFound => { + utils::put_config::(Self::DEFAULT_CONFIG, Self::FILENAME)?; + println!("Update {:?} and start rustmission again", Self::path()); + std::process::exit(0); + } + ConfigFetchingError::Toml(e) => Err(e).with_context(|| { + format!( + "Failed to parse config located at {:?}", + utils::get_config_path(Self::FILENAME) + ) + }), + _ => anyhow::bail!(e), + }, + } + } + + pub(crate) fn path() -> &'static PathBuf { + static PATH: OnceLock = OnceLock::new(); + PATH.get_or_init(|| utils::get_config_path(Self::FILENAME)) + } +} diff --git a/rm-config/src/main_config/search_tab.rs b/rm-config/src/main_config/search_tab.rs new file mode 100644 index 0000000..c10ea6c --- /dev/null +++ b/rm-config/src/main_config/search_tab.rs @@ -0,0 +1,20 @@ +use magnetease::WhichProvider; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct SearchTab { + #[serde(default = "default_providers")] + pub providers: Vec, +} + +impl Default for SearchTab { + fn default() -> Self { + Self { + providers: default_providers(), + } + } +} + +fn default_providers() -> Vec { + vec![WhichProvider::Knaben, WhichProvider::Nyaa] +} diff --git a/rm-config/src/main_config/torrents_tab.rs b/rm-config/src/main_config/torrents_tab.rs new file mode 100644 index 0000000..92c3f6d --- /dev/null +++ b/rm-config/src/main_config/torrents_tab.rs @@ -0,0 +1,27 @@ +use rm_shared::header::Header; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct TorrentsTab { + #[serde(default = "default_headers")] + pub headers: Vec
, +} + +fn default_headers() -> Vec
{ + vec![ + Header::Name, + Header::SizeWhenDone, + Header::Progress, + Header::Eta, + Header::DownloadRate, + Header::UploadRate, + ] +} + +impl Default for TorrentsTab { + fn default() -> Self { + Self { + headers: default_headers(), + } + } +} diff --git a/rm-main/src/tui/tabs/search/mod.rs b/rm-main/src/tui/tabs/search/mod.rs index a94447b..7137eb6 100644 --- a/rm-main/src/tui/tabs/search/mod.rs +++ b/rm-main/src/tui/tabs/search/mod.rs @@ -367,8 +367,8 @@ impl Component for SearchTab { } }; - let paragraph_text = format!(" {input}"); - let prefix_len = paragraph_text.len() - input.len() - 2; + let paragraph_text = format!("{} {input}", CONFIG.icons.magnifying_glass); + let prefix_len = paragraph_text.chars().count() - input.chars().count(); let paragraph = Paragraph::new(paragraph_text).style(search_style); f.render_widget(paragraph, search_rect); diff --git a/rm-main/src/tui/tabs/search/popups/providers.rs b/rm-main/src/tui/tabs/search/popups/providers.rs index 781c454..bdbfa6e 100644 --- a/rm-main/src/tui/tabs/search/popups/providers.rs +++ b/rm-main/src/tui/tabs/search/popups/providers.rs @@ -3,7 +3,7 @@ use ratatui::{ layout::{Alignment, Constraint, Margin}, prelude::Rect, style::{Style, Styled, Stylize}, - text::{Line, ToLine}, + text::Line, widgets::{ block::{Position, Title}, Block, BorderType, Clear, Row, Table, @@ -26,18 +26,22 @@ pub struct ProvidersPopup { impl From<&ConfiguredProvider> for Row<'_> { fn from(value: &ConfiguredProvider) -> Self { let mut name: Line = match value.provider_state { - _ if !value.enabled => " 󰪎 ".into(), - ProviderState::Idle => " 󱗼 ".yellow().into(), - ProviderState::Searching => "  ".yellow().into(), - ProviderState::Found(_) => "  ".green().into(), - ProviderState::Error(_) => "  ".red().into(), + _ if !value.enabled => format!(" {} ", CONFIG.icons.provider_disabled).into(), + ProviderState::Idle => format!(" {} ", CONFIG.icons.idle).yellow().into(), + ProviderState::Searching => format!(" {} ", CONFIG.icons.searching).yellow().into(), + ProviderState::Found(_) => format!(" {} ", CONFIG.icons.success).green().into(), + ProviderState::Error(_) => format!(" {} ", CONFIG.icons.failure).red().into(), }; name.push_span(value.provider.name()); - let category: Line = match value.provider.category() { - ProviderCategory::General => " General".to_line(), - ProviderCategory::Anime => "󰎁 Anime".to_line(), + let category = match value.provider.category() { + ProviderCategory::General => { + format!("{} General", CONFIG.icons.provider_category_general) + } + ProviderCategory::Anime => { + format!("{} Anime", CONFIG.icons.provider_category_anime) + } }; let url: Line = format!("({})", value.provider.display_url()).into(); @@ -45,7 +49,9 @@ impl From<&ConfiguredProvider> for Row<'_> { let status: Line = match &value.provider_state { _ if !value.enabled => "Disabled".into(), ProviderState::Idle => "Idle".into(), - ProviderState::Searching => " Searching...".yellow().into(), + ProviderState::Searching => format!("{} Searching...", CONFIG.icons.searching) + .yellow() + .into(), ProviderState::Found(count) => { let mut line = Line::default(); line.push_span("Found("); @@ -56,7 +62,7 @@ impl From<&ConfiguredProvider> for Row<'_> { ProviderState::Error(e) => e.to_string().red().into(), }; - let row = Row::new(vec![name, url, category, status]); + let row = Row::new(vec![name, url, category.into(), status]); if value.enabled { row diff --git a/rm-main/src/tui/tabs/torrents/bottom_stats.rs b/rm-main/src/tui/tabs/torrents/bottom_stats.rs index 2d9fb76..d3054e4 100644 --- a/rm-main/src/tui/tabs/torrents/bottom_stats.rs +++ b/rm-main/src/tui/tabs/torrents/bottom_stats.rs @@ -5,6 +5,7 @@ use ratatui::{ widgets::Paragraph, Frame, }; +use rm_config::CONFIG; use rm_shared::utils::bytes_to_human_format; use transmission_rpc::types::{FreeSpace, SessionStats}; @@ -48,21 +49,24 @@ impl Component for BottomStats { let download = bytes_to_human_format(stats.download_speed); let upload = bytes_to_human_format(stats.upload_speed); - let mut text = format!(" {download} |  {upload}"); + let mut text = format!( + "{} {download} | {} {upload}", + CONFIG.icons.download, CONFIG.icons.upload + ); if let Some(free_space) = &self.free_space { let free_space = bytes_to_human_format(free_space.size_bytes); - text = format!("󰋊 {free_space} | {text}") + text = format!("{} {free_space} | {text}", CONFIG.icons.disk) } if self.torrent_count > 0 { text = format!( - " {}/{} | {text}", - self.torrent_currently_selected, self.torrent_count + "{} {}/{} | {text}", + CONFIG.icons.file, self.torrent_currently_selected, self.torrent_count ); } else { // dont display index if nothing is selected - text = format!(" {} | {text}", self.torrent_count); + text = format!("{} {} | {text}", CONFIG.icons.file, self.torrent_count); } let paragraph = Paragraph::new(text).alignment(Alignment::Right); diff --git a/rm-main/src/tui/tabs/torrents/rustmission_torrent.rs b/rm-main/src/tui/tabs/torrents/rustmission_torrent.rs index 1b1a423..5eb77ed 100644 --- a/rm-main/src/tui/tabs/torrents/rustmission_torrent.rs +++ b/rm-main/src/tui/tabs/torrents/rustmission_torrent.rs @@ -4,11 +4,10 @@ use ratatui::{ text::{Line, Span}, widgets::Row, }; +use rm_config::CONFIG; use rm_shared::{ header::Header, - utils::{ - bytes_to_human_format, download_speed_format, seconds_to_human_format, upload_speed_format, - }, + utils::{bytes_to_human_format, seconds_to_human_format}, }; use transmission_rpc::types::{ErrorType, Id, Torrent, TorrentStatus}; @@ -151,23 +150,23 @@ impl RustmissionTorrent { Header::PeersConnected => Line::from(self.peers_connected.to_string()), Header::SmallStatus => { if self.error.is_some() { - return Line::from(""); + return Line::from(CONFIG.icons.failure.as_str()); } match self.status() { - TorrentStatus::Stopped => Line::from("󰏤"), - TorrentStatus::QueuedToVerify => Line::from("󱥸"), - TorrentStatus::Verifying => Line::from("󰑓"), - TorrentStatus::QueuedToDownload => Line::from("󱥸"), - TorrentStatus::QueuedToSeed => Line::from("󱥸"), + TorrentStatus::Stopped => Line::from(CONFIG.icons.pause.as_str()), + TorrentStatus::QueuedToVerify => Line::from(CONFIG.icons.loading.as_str()), + TorrentStatus::Verifying => Line::from(CONFIG.icons.verifying.as_str()), + TorrentStatus::QueuedToDownload => Line::from(CONFIG.icons.loading.as_str()), + TorrentStatus::QueuedToSeed => Line::from(CONFIG.icons.loading.as_str()), + TorrentStatus::Downloading => Line::from(CONFIG.icons.download.as_str()), TorrentStatus::Seeding => { if !self.upload_speed.is_empty() { - Line::from("") + Line::from(CONFIG.icons.upload.as_str()) } else { - Line::from("󰄬") + Line::from(CONFIG.icons.success.as_str()) } } - TorrentStatus::Downloading => Line::from(""), } } } @@ -294,3 +293,17 @@ fn time_to_line<'a>(time: NaiveDateTime) -> Line<'a> { Line::from(time.format("%y|%m|%d %H:%M").to_string()) } } + +fn download_speed_format(download_speed: &str) -> String { + if !download_speed.is_empty() { + return format!("{} {}", CONFIG.icons.download, download_speed); + } + download_speed.to_string() +} + +fn upload_speed_format(upload_speed: &str) -> String { + if !upload_speed.is_empty() { + return format!("{} {}", CONFIG.icons.upload, upload_speed); + } + upload_speed.to_string() +} diff --git a/rm-main/src/tui/tabs/torrents/tasks/default.rs b/rm-main/src/tui/tabs/torrents/tasks/default.rs index 40126e1..64be209 100644 --- a/rm-main/src/tui/tabs/torrents/tasks/default.rs +++ b/rm-main/src/tui/tabs/torrents/tasks/default.rs @@ -1,5 +1,6 @@ use ratatui::prelude::*; use rm_config::CONFIG; +use rm_shared::action::Action; use crate::tui::components::Component; @@ -14,11 +15,8 @@ impl DefaultBar { impl Component for DefaultBar { fn render(&mut self, f: &mut ratatui::Frame<'_>, rect: Rect) { if CONFIG.general.beginner_mode { - if let Some(keys) = CONFIG - .keybindings - .get_keys_for_action(rm_shared::action::Action::ShowHelp) - { - f.render_widget(format!("󰘥 {keys} - help"), rect) + if let Some(keys) = CONFIG.keybindings.get_keys_for_action(Action::ShowHelp) { + f.render_widget(format!("{} {keys} - help", CONFIG.icons.help), rect) } } } diff --git a/rm-shared/src/utils.rs b/rm-shared/src/utils.rs index 48810bc..9bb5ffd 100644 --- a/rm-shared/src/utils.rs +++ b/rm-shared/src/utils.rs @@ -62,20 +62,6 @@ pub fn seconds_to_human_format(seconds: i64) -> String { curr_string } -pub fn download_speed_format(download_speed: &str) -> String { - if !download_speed.is_empty() { - return format!(" {}", download_speed); - } - download_speed.to_string() -} - -pub fn upload_speed_format(upload_speed: &str) -> String { - if !upload_speed.is_empty() { - return format!(" {}", upload_speed); - } - upload_speed.to_string() -} - pub fn truncated_str(str: &str, max: usize) -> String { if str.chars().count() < max { str.to_string()