Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Adjustable modules #8

Open
Zaedus opened this issue May 12, 2021 · 4 comments
Open

[FEATURE] Adjustable modules #8

Zaedus opened this issue May 12, 2021 · 4 comments

Comments

@Zaedus
Copy link

Zaedus commented May 12, 2021

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.

@spenserblack
Copy link
Contributor

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 🙂

@irevenko
Copy link
Owner

it does

x, y := ui.TerminalDimensions()
l.SetRect(0, 4, x, y)

@spenserblack
Copy link
Contributor

spenserblack commented May 12, 2021

That's what I get for only searching "Size" 😅
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).

@spenserblack
Copy link
Contributor

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! 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants