Rendering a (status) line on the bottom of the screen, padding?

39 views
Skip to first unread message

Philipp Middendorf

unread,
Jul 24, 2017, 10:28:46 AM7/24/17
to Brick Users
Hi!

I'm designing a terminal application that is supposed to display a status line on the very last line of the screen. The content above this status line is of varying size. It might just be one line, or maybe it's a very long list spanning hundreds of lines.

However, I'm having problems expressing this using brick's layouting combinators. I tried prepending "padTop Max" before the status text. This, however, extends the (blue) background of the status line up to the last "regular" application line:



 Also, "big" widgets (for example, a vertical viewport containing hundreds of log line widgets) above the status line don't fill up the whole screen, but half of it:



 I suppose this is because both the status line and the widgets above are greedily taking up all the space, resulting in both getting half of it?

How do I solve this problem elegantly? Is there a widget that grows only if no other widget takes up the space?

Jonathan Daugherty

unread,
Jul 24, 2017, 12:05:19 PM7/24/17
to Philipp Middendorf, Brick Users
Hi,

> I suppose this is because both the status line and the widgets above
> are greedily taking up all the space, resulting in both getting half
> of it?

That's right - the key is to make the status bar non-greedy (so don't
add the padding to it). Instead, make the thing above it greedy, so that
the status bar gets "pushed down" to the bottom of the screen. To do
that, use a fill. Here's an example program:

module Main where

import Brick

ui :: Widget ()
ui = vBox [ str "This text is at the top."
, fill ' '
, str "This text is at the bottom."
]

main :: IO ()
main = simpleMain ui

Hope that helps!

--
Jonathan Daugherty

Philipp Middendorf

unread,
Jul 24, 2017, 3:34:58 PM7/24/17
to Brick Users
Ah, thank you, fill was all I was missing!

  Philipp
Reply all
Reply to author
Forward
0 new messages