dj95 / zjstatus

A configurable statusbar plugin for zellij
MIT License
358 stars 6 forks source link

ansicolor default #49

Closed nothendev closed 3 months ago

nothendev commented 3 months ago

Is your feature request related to a problem? Please describe. yep. i want background blur with alacritty and it only does that if the bg color is set to 49 (ansicolor default). i can use a separate magic 49 for any backgrounds but it feels meh.

Describe the solution you'd like i want a "default" color alias which maps to AnsiColor::Default so i can use it both as a fg and bg (which map to the respective 39/49 values depending on fg or bg)

Additional context alacritty

dj95 commented 3 months ago

Hi and thanks for your feature request.

Unfortunately it's not that easy to map the color to AnsiColor::Default since this does not exist. There's a function on_default which allows to render the text on the default background color. Internally, it just creates an empty style with only the foreground color set. The same goes for the default foreground color.

This implementation allows us to recreate the behaviour by just not setting fg and bg at all. I've tested it in Alacrity on macOS and it looks like this.

Screenshot 2024-03-16 at 10 47 18

As you can see it is blurring the background and zjstatus will not overpaint the regions. foo on the right side of the bar has the default fg color.

Therefore it would be a little bit unintuitive to implement the default color, which internally does nothing, since it defaults when not specified.

Does this work for you? If so, we should definitely add it to the documentation.


Used layout

layout {
    pane split_direction="vertical" {
        pane borderless=true
    }

    pane size=2 borderless=true {
        plugin location="file:target/wasm32-wasi/debug/zjstatus.wasm" {
            format_left  "{mode} #[fg=#89B4FA,bg=#181825,bold]{session} {tabs} "
            format_center "{command_0} {command_1} {command_git_branch} {command_3}"
            format_right "{tabs} {datetime}"
            format_space "#[bg=#181825]"

            // foo
            border_enabled  "true"
            border_char     "─"
            border_format   "#[fg=#6C7086]{char}"
            border_position "top"

            hide_frame_for_single_pane "true"

            mode_normal          "#[bg=blue] #[bg=yellow] "
            mode_tmux            "#[bg=yellow] "
            mode_default_to_mode "tmux"

            tab_normal              "#[fg=#6C7086,bg=#181825] {index} {name} {floating_indicator} "
            tab_normal_fullscreen   "#[fg=#6C7086,bg=#181825] {index} {name} [] "
            tab_normal_sync         "#[fg=#6C7086,bg=#181825] {index} {name} <> "
            tab_active              "#[fg=#9399B2,bg=#181825,bold,italic] {index} {name} {floating_total_count}{floating_indicator}{sync_indicator}{fullscreen_indicator}"
            tab_separator           "#[fg=#6C7086,bg=#181825] | "
            tab_floating_indicator  "F"
            tab_sync_indicator      "S"
            tab_fullscreen_indicator "FS"

            command_0_command  "echo \"平仮名, ひらがな 📦\""
            command_0_format    "#[fg=blue] {exit_code} {stdout} "
            command_0_interval  "1"

            command_1_command   "date"
            command_1_format    "#[fg=blue] {exit_code} {stdout} "
            command_1_interval  "1"

            command_git_branch_command   "git rev-parse --abbrev-ref HEAD"
            command_git_branch_format    "#[fg=red] {stdout} "
            command_git_branch_interval  "2"

            command_3_command   "echo -e \"#[italic,bold] foo #[fg=#000000,italic] bar \""
            command_3_format    "{stdout}"
            command_3_interval  "10"
            command_3_rendermode "dynamic"

            datetime          "#[fg=#6C7086,bg=#181825,bold] {format} "
            datetime_format   "%A, %d %b %Y %H:%M"
            datetime_timezone "Europe/Berlin"
        }
    }
}
nothendev commented 3 months ago

Also, i don't understand how layering works, i.e. if I do "#[fg=base,bg=blue] a #[fg=blue] b" would "b" be rendered as blue on blue or blue on default? (pretend base is a valid color) If layering works like second case then yeah it will solve my issue

dj95 commented 3 months ago

There is no layering. So b will be blue on the default background. Each format is resetting everything to default and just rendering the format that is specified in them. This is the main difference in contrast to tmux.

nothendev commented 3 months ago

thanks!