octotui
octotui copied to clipboard
[FEATURE] Adjustable modules
Its a little annoying, but is it possible for the little modules/boxes to adjust to the terminal width instead of being cut off. Also, it would be really cool to be able to modify which modules/boxes show.
Looking at termui's docs quickly, looks like it doesn't support relative sizing, only absolute, unlike tview, which is surprising. But I assume it shouldn't be too difficult to calculate manually by using x/term to calculate the terminal's size :slightly_smiling_face:
it does
x, y := ui.TerminalDimensions()
l.SetRect(0, 4, x, y)
That's what I get for only searching "Size" :sweat_smile:
Looks like octotui assumes the screen is at least 220
wide from what I'm looking at, so something like
x, _ := ui.TerminalDimensions()
ratio := 220 / x
if ratio < 1 {
ratio = 1
}
myWidget.SetRect(xCoord / ratio, yCoord, width / ratio, height)
should roughly accomplish sizing based on terminal width. If, for example, the terminal is 110 wide, then ratio is 2, and width of myWidget
is half the full size.
This is just a lazy example, and you'll probably want to use floating points instead to get more precise sizing (e.g. if x == 200
, there wouldn't be any resizing in this example).
Ignore my previous comment, it's probably better to use termui's Grid than to manually resize everything based on terminal size. See #9.
looks like it doesn't support relative sizing ... unlike tview,
I was wrong about this, too! :sweat_smile: