dj95 / zjstatus

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

Malformed stdout from command that produces longer output than available space #58

Closed jnickoloff closed 1 month ago

jnickoloff commented 1 month ago

When using "format_right" in a layout that refers to a command that produces output that is so long that it eats into other widgets, the output from this command will suddenly get ... wonky and won't look right. It is fine when it fits, it isn't if it is too long.

I would like the output of this command to be gracefully truncated so that at least as much as possible is visible. For a "format_right" directive, it would be nice for the left portion to be truncated as needed to fit in the bar.

Layout | 1 layout { │ 2 default_tab_template { │ 3 children │ 4 pane size=1 borderless=true { │ 5 plugin location="file:/etc/zellij/plugins/zjstatus.wasm" { │ 6 hide_frame_for_single_pane "true" | 7 │ 8 format_left "{mode} #[bg=#181825] {tabs}" │ 9 format_right "{command_baraction}" │10 format_space "#[bg=#181825]" │11
│12 mode_normal "#[bg=#89B4FA] " │13 mode_tmux "#[bg=#ffc387] " │14 │15 tab_normal "#[fg=#000000,bg=#76946A] {index} {name} {fullscreen_indicator}{sync_indicator}{floating_indicator}" │16 tab_active "#[fg=#000000,bg=#FF9E3B,bold,italic] {index} {name} {fullscreen_indicator}{sync_indicator}{floating_indicator}" │17 tab_fullscreen_indicator "□ " │18 tab_sync_indicator " " │19 tab_floating_indicator "󰉈 " │20 │21 command_baraction_command "baraction" │22 command_baraction_format "#[fg=#DCD7BA,bg=#181825,italic] {stdout" │23 command_baraction_interval "3" │24 } │25 } │26 } │27 │28 swap_tiled_layout name="stacked" { │29 tab min_panes=3 { │30 pane split_direction="vertical" { │31 pane │32 pane stacked=true { children; } │33 } │34 } │35 } │36 }

Thank you for this little status bar program. It really help to make Zellij usable for me. Cheers

dj95 commented 1 month ago

Hi and thanks for your bug report.

I actually thought about this behaviour previously, but didn't come to a conclusion on how to solve (except relying on the person configuring zjstatus to mitigate this).

The problem is, that users can prefer other locations as their primary location, like format_center, when tabs are centred. Therefore I'm not really sure if it's good to truncate format_right hardly.

dj95 commented 1 month ago

Hi,

I've implemented a precedence config such that every combination of primary, secondary and tertiary parts is possible.

e.g.

format_precedence "lcr"

If the left part is overflowing the center, center will be hidden. Same if the left part overflows the right. However, if the right part would overflow the center, the right part is hidden, as it is the last one in the order.

This way every user can individually choose, which part gets hidden first and which one last.

Hope this fixes your issue.

dj95 commented 1 month ago

Truncation is unfortunately not really possible, as it could truncate in the middle of an escape sequence. Therefore I cannot really implement this without breaking the general appearance or provoking visual glitches. Therefore hiding the lesser relevant parts seems an appropriate solution for me.

In case someone is annoyed and wants the older behaviour with the overflow back, we could also implement a toggle for this.

jnickoloff commented 3 weeks ago

Hopefully commenting does not resurrect this issue ...

I'm running your latest and I like this new feature. It at least allows me to construct a config where an overflow fails gracefully and does not look wonky.

Thank you.