mum4k / termdash

Terminal based dashboard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I have a row as tall as one character?

fenollp opened this issue · comments

I have adapted the demo to use this layout:

func contLayout(w *widgets) ([]container.Option, error) {
        builder := grid.New()
        builder.Add(
                grid.RowHeightPerc(94, grid.Widget(w.rollT)),
                grid.RowHeightPerc(3, grid.Widget(w.gauge)),
                grid.RowHeightPerc(3, grid.Widget(w.gauge)),
        )
        return builder.Build()

I'm trying to get the bottom 2 gauges to always be as tall as a the XX% progress they contain (= as tall as a character).
But when I change my terminal zoom this eventually ends as text smaller than the bar and no longer vertically centered.

Any plans on adding something akin to grid.RowHeightEM (from CSS: https://www.w3schools.com/cssref/css_units.asp)

Hi @fenollp, thanks for pointing this out. PR #204 recently added support for fixed size container splits. Note this hasn't been released yet and is available in the devel branch only. However the PR added the support only to the binary tree layout. It should be trivial to add this to the grid layout as well. I will try to squeeze this in before the next release.

Do note that Termdash currently only supports a full-screen mode. So even with fixed size splits - the last row (the last container) will always dynamically adjust to the remaining height of the screen. If I understand your use case correctly - this should not be a problem.

This has now been pushed into the devel branch.

Please give it a try and let me know if you see anything missing.

It works quite well, as long as I fix the top container height which breaks as soon as I resize the window:

        builder.Add(
                grid.RowHeightFixed(47, grid.Widget(w.rollT)),
                grid.RowHeightFixed(1, grid.Widget(w.gauge)),
                grid.RowHeightFixed(1, grid.Widget(w.gauge)),
        )

Thanks for coming back @fenollp,

sorry not sure what you mean by "which breaks as soon as I resize the window". Does this mean we still have an issue we should improve on?

Actually yes, now that I'm trying the above code on a different terminal & screen resolution it appears grid.RowHeightFixed(1, grid.Widget(w.gauge)) can take more height than the height of the characters it contains. It is fine on OSX though.