diff options
| author | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-07-15 16:32:12 +0200 |
|---|---|---|
| committer | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-07-15 16:32:12 +0200 |
| commit | 4fc37420c70a6d453fc831ea6fa7e69ea0b434b7 (patch) | |
| tree | 169f310f8ed9a36f2244b54840d09d88262744e3 | |
| parent | feat: add color aliases (diff) | |
| download | sl0pstatus-4fc37420c70a6d453fc831ea6fa7e69ea0b434b7.tar.gz sl0pstatus-4fc37420c70a6d453fc831ea6fa7e69ea0b434b7.tar.xz sl0pstatus-4fc37420c70a6d453fc831ea6fa7e69ea0b434b7.zip | |
chore: move from {alias} to $alias
| -rw-r--r-- | plugin-dev-workspace.kdl | 32 | ||||
| -rw-r--r-- | src/render.rs | 8 |
2 files changed, 20 insertions, 20 deletions
diff --git a/plugin-dev-workspace.kdl b/plugin-dev-workspace.kdl index 0da48e4..2facd5d 100644 --- a/plugin-dev-workspace.kdl +++ b/plugin-dev-workspace.kdl @@ -9,15 +9,15 @@ layout { color_yellow "yellow" color_bg "#181825" - format_left "{mode}#[fg={blue},bg={bg},bold] {session}" + format_left "{mode}#[fg=$blue,bg=$bg,bold] {session}" format_center "{tabs} {command_3}" format_right "{datetime}" - format_space "#[bg={bg}]" + format_space "#[bg=$bg]" format_precedence "lrc" format_hide_on_overlength "false" - notification_format_unread "#[fg={blue},bg={bg},blink] #[fg={blue},bg={bg}] {message} " - notification_format_no_notifications "#[fg={blue},bg={bg},dim] " + notification_format_unread "#[fg=$blue,bg=$bg,blink] #[fg=$blue,bg=$bg] {message} " + notification_format_no_notifications "#[fg=$blue,bg=$bg,dim] " notification_show_interval "10" border_enabled "true" @@ -30,22 +30,22 @@ layout { hide_frame_for_single_pane "true" - mode_normal "#[bg={blue}] #[bg={yellow}] " - mode_tmux "#[bg={yellow}] " + mode_normal "#[bg=$blue] #[bg=yellow] " + mode_tmux "#[bg=$yellow] " mode_default_to_mode "tmux" - tab_normal "#[fg=#6C7086,bg={bg}] {index} {name} {floating_indicator} " - tab_rename "#[fg=#eba0ac,bg={bg}] {index} {name} {floating_indicator} " - tab_normal_fullscreen "#[fg=#6C7086,bg={bg}] {index} {name} [] " - tab_normal_sync "#[fg=#6C7086,bg={bg}] {index} {name} <> " - tab_active "#[fg=#9399B2,bg={bg},bold,italic] {index} {name} {floating_total_count}{floating_indicator}{sync_indicator}{fullscreen_indicator}" - tab_separator "#[fg=#6C7086,bg={bg}] | " + tab_normal "#[fg=#6C7086,bg=$bg] {index} {name} {floating_indicator} " + tab_rename "#[fg=#eba0ac,bg=$bg] {index} {name} {floating_indicator} " + tab_normal_fullscreen "#[fg=#6C7086,bg=$bg] {index} {name} [] " + tab_normal_sync "#[fg=#6C7086,bg=$bg] {index} {name} <> " + tab_active "#[fg=#9399B2,bg=$bg,bold,italic] {index} {name} {floating_total_count}{floating_indicator}{sync_indicator}{fullscreen_indicator}" + tab_separator "#[fg=#6C7086,bg=$bg] | " tab_floating_indicator "F" tab_sync_indicator "S" tab_fullscreen_indicator "FS" tab_display_count "3" - tab_truncate_start_format "#[fg=red,bg={bg}] < +{count} ..." - tab_truncate_end_format "#[fg=red,bg={bg}] ... +{count} >" + tab_truncate_start_format "#[fg=red,bg=$bg] < +{count} ..." + tab_truncate_end_format "#[fg=red,bg=$bg] ... +{count} >" command_0_command "echo \"平仮名, ひらがな 📦\"" command_0_clickaction "bash -c \"zellij --session zjstatus-dev pipe 'zjstatus::notify::hello world!' -n zjstatus\"" @@ -65,12 +65,12 @@ layout { command_git_branch_format "#[fg=red] {stdout} " command_git_branch_interval "2" - command_3_command "echo -e \"#[fg={yellow},italic,bold] foo #[dim,bold,italic] bar \"" + command_3_command "echo -e \"#[fg=$yellow,italic,bold] foo #[dim,bold,italic] bar \"" command_3_format "{stdout}" command_3_interval "10" command_3_rendermode "dynamic" - datetime "#[fg=#6C7086,bg={bg},bold] {format} #[bg=#6C7086,fg={bg},bold] {time}" + datetime "#[fg=#6C7086,bg=$bg,bold] {format} #[bg=#6C7086,fg=$bg,bold] {time}" datetime_time_format "%H:%M:%S" datetime_format "%A, %d %b %Y %H:%M" datetime_timezone "Europe/Berlin" diff --git a/src/render.rs b/src/render.rs index 352cdbb..a9f55ef 100644 --- a/src/render.rs +++ b/src/render.rs @@ -301,8 +301,8 @@ fn hex_to_rgb(s: &str) -> anyhow::Result<Vec<u8>> { )] fn parse_color(color: &str, config: &BTreeMap<String, String>) -> Option<Color> { let mut color = color; - if color.starts_with('{') { - let alias_name = &color[1..color.len() - 1]; + if color.starts_with('$') { + let alias_name = color.strip_prefix('$').unwrap(); color = match config.get(&format!("color_{alias_name}")) { Some(color_str) => color_str, @@ -411,11 +411,11 @@ mod test { let result = parse_color("#365", &config); assert_eq!(result, None); - let result = parse_color("{green}", &config); + let result = parse_color("$green", &config); let expected = RgbColor(0, 255, 0); assert_eq!(result, Some(expected.into())); - let result = parse_color("{blue}", &config); + let result = parse_color("$blue", &config); assert_eq!(result, None); } } |
