diff options
| author | Daniel Jankowski <daniel.jankowski@rub.de> | 2023-12-17 15:56:40 +0100 |
|---|---|---|
| committer | Daniel Jankowski <daniel.jankowski@rub.de> | 2023-12-17 15:56:40 +0100 |
| commit | 19b8d9d63c55ade8b1a2fc70732756ae161909b4 (patch) | |
| tree | 3d60c361b89a46ca2f8959217e1298d7a288aebb /src | |
| parent | feat: add bench for render_bar (diff) | |
| download | sl0pstatus-19b8d9d63c55ade8b1a2fc70732756ae161909b4.tar.gz sl0pstatus-19b8d9d63c55ade8b1a2fc70732756ae161909b4.tar.xz sl0pstatus-19b8d9d63c55ade8b1a2fc70732756ae161909b4.zip | |
chore: ref config instead of copying
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/zjstatus.rs | 20 | ||||
| -rw-r--r-- | src/config.rs | 2 | ||||
| -rw-r--r-- | src/widgets/command.rs | 4 | ||||
| -rw-r--r-- | src/widgets/datetime.rs | 2 | ||||
| -rw-r--r-- | src/widgets/mode.rs | 2 | ||||
| -rw-r--r-- | src/widgets/session.rs | 2 | ||||
| -rw-r--r-- | src/widgets/swap_layout.rs | 2 | ||||
| -rw-r--r-- | src/widgets/tabs.rs | 2 |
8 files changed, 18 insertions, 18 deletions
diff --git a/src/bin/zjstatus.rs b/src/bin/zjstatus.rs index 801c0cc..7999380 100644 --- a/src/bin/zjstatus.rs +++ b/src/bin/zjstatus.rs @@ -51,9 +51,9 @@ impl ZellijPlugin for State { EventType::RunCommandResult, ]); - self.userspace_configuration = configuration.clone(); - self.module_config = ModuleConfig::new(configuration.clone()); - self.widget_map = register_widgets(configuration); + self.module_config = ModuleConfig::new(&configuration); + self.widget_map = register_widgets(&configuration); + self.userspace_configuration = configuration; self.got_permissions = false; let uid = Uuid::new_v4(); @@ -182,30 +182,30 @@ impl ZellijPlugin for State { } } -fn register_widgets(configuration: BTreeMap<String, String>) -> BTreeMap<String, Arc<dyn Widget>> { +fn register_widgets(configuration: &BTreeMap<String, String>) -> BTreeMap<String, Arc<dyn Widget>> { let mut widget_map = BTreeMap::<String, Arc<dyn Widget>>::new(); widget_map.insert( "command".to_owned(), - Arc::new(CommandWidget::new(configuration.clone())), + Arc::new(CommandWidget::new(&configuration)), ); widget_map.insert( "datetime".to_owned(), - Arc::new(DateTimeWidget::new(configuration.clone())), + Arc::new(DateTimeWidget::new(&configuration)), ); widget_map.insert( "swap_layout".to_owned(), - Arc::new(SwapLayoutWidget::new(configuration.clone())), + Arc::new(SwapLayoutWidget::new(&configuration)), ); widget_map.insert( "mode".to_owned(), - Arc::new(ModeWidget::new(configuration.clone())), + Arc::new(ModeWidget::new(&configuration)), ); widget_map.insert( "session".to_owned(), - Arc::new(SessionWidget::new(configuration.clone())), + Arc::new(SessionWidget::new(&configuration)), ); - widget_map.insert("tabs".to_owned(), Arc::new(TabsWidget::new(configuration))); + widget_map.insert("tabs".to_owned(), Arc::new(TabsWidget::new(&configuration))); widget_map } diff --git a/src/config.rs b/src/config.rs index 8591788..dab66f1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -33,7 +33,7 @@ pub struct ModuleConfig { } impl ModuleConfig { - pub fn new(config: BTreeMap<String, String>) -> Self { + pub fn new(config: &BTreeMap<String, String>) -> Self { let format_space_config = match config.get("format_space") { Some(space_config) => space_config, None => "", diff --git a/src/widgets/command.rs b/src/widgets/command.rs index c7df9b7..17c5e22 100644 --- a/src/widgets/command.rs +++ b/src/widgets/command.rs @@ -40,7 +40,7 @@ pub struct CommandWidget { } impl CommandWidget { - pub fn new(config: BTreeMap<String, String>) -> Self { + pub fn new(config: &BTreeMap<String, String>) -> Self { Self { config: parse_config(config), } @@ -119,7 +119,7 @@ fn run_command_if_needed(command_config: CommandConfig, name: &str, state: &Zell } } -fn parse_config(zj_conf: BTreeMap<String, String>) -> BTreeMap<String, CommandConfig> { +fn parse_config(zj_conf: &BTreeMap<String, String>) -> BTreeMap<String, CommandConfig> { let mut keys: Vec<String> = zj_conf .keys() .filter(|k| k.starts_with("command_")) diff --git a/src/widgets/datetime.rs b/src/widgets/datetime.rs index ef2fbee..e846d34 100644 --- a/src/widgets/datetime.rs +++ b/src/widgets/datetime.rs @@ -14,7 +14,7 @@ pub struct DateTimeWidget { } impl DateTimeWidget { - pub fn new(config: BTreeMap<String, String>) -> Self { + pub fn new(config: &BTreeMap<String, String>) -> Self { let mut format = "%H:%M"; if let Some(form) = config.get("datetime_format") { format = form; diff --git a/src/widgets/mode.rs b/src/widgets/mode.rs index 0cd68ac..db73544 100644 --- a/src/widgets/mode.rs +++ b/src/widgets/mode.rs @@ -25,7 +25,7 @@ pub struct ModeWidget { } impl ModeWidget { - pub fn new(config: BTreeMap<String, String>) -> Self { + pub fn new(config: &BTreeMap<String, String>) -> Self { let normal_format = match config.get("mode_normal") { Some(form) => FormattedPart::multiple_from_format_string(form.to_owned()), None => vec![], diff --git a/src/widgets/session.rs b/src/widgets/session.rs index 4d2ebf0..4916a65 100644 --- a/src/widgets/session.rs +++ b/src/widgets/session.rs @@ -5,7 +5,7 @@ use crate::{config::ZellijState, widgets::widget::Widget}; pub struct SessionWidget {} impl SessionWidget { - pub fn new(_config: BTreeMap<String, String>) -> Self { + pub fn new(_config: &BTreeMap<String, String>) -> Self { Self {} } } diff --git a/src/widgets/swap_layout.rs b/src/widgets/swap_layout.rs index 9b4dda6..f744e38 100644 --- a/src/widgets/swap_layout.rs +++ b/src/widgets/swap_layout.rs @@ -6,7 +6,7 @@ use crate::{config::ZellijState, widgets::widget::Widget}; pub struct SwapLayoutWidget {} impl SwapLayoutWidget { - pub fn new(_config: BTreeMap<String, String>) -> Self { + pub fn new(_config: &BTreeMap<String, String>) -> Self { Self {} } } diff --git a/src/widgets/tabs.rs b/src/widgets/tabs.rs index cefd124..d8a292d 100644 --- a/src/widgets/tabs.rs +++ b/src/widgets/tabs.rs @@ -16,7 +16,7 @@ pub struct TabsWidget { } impl TabsWidget { - pub fn new(config: BTreeMap<String, String>) -> Self { + pub fn new(config: &BTreeMap<String, String>) -> Self { let mut normal_tab_format: Vec<FormattedPart> = Vec::new(); if let Some(form) = config.get("tab_normal") { normal_tab_format = FormattedPart::multiple_from_format_string(form.to_owned()); |
