-
Notifications
You must be signed in to change notification settings - Fork 189
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
Render
fills shorter lines with spaces
#235
Comments
Render
adds spaces until WordWrap
to every lineRender
fills shorter lines with spaces
I believe that is expected due to the nature of TUIs. In order to respect the widths defined by the user, in this case 80 characters, it needs to get filled with whitespace to make that width consistent across all lines. Otherwise any borders would be staggered depending on the width of each line. Is this blocking something for you? We might be able to find a workaround if we have a better idea of what you're trying to do :) |
Let's say you want to center some glamorous text in the screen: txt, _ := glamour.Render("Hello World", "auto")
vp, hp := viewport.Height - lipgloss.Height(txt), viewport.Width - lipgloss.Width(txt)
txt = lipgloss.NewStyle().Padding(vp/2, hp/2).Render(txt) This will not work because the W and H that
The word wrap width should have nothing to do with the margin or padding. The If at all, I would say that padding and margin should be the ones defining the word wrap width, as it happens in e.g. HTML/CSS, and not the other way around? |
@gsalvatella ah gotcha, thank you so much for the info and context! |
We pad the content to ensure the background color gets rendered. |
So the background width is set throught the |
The following program:
Produces the following output:
The rendering engine adds spaces to every line until the value of
WordWrap
(80 by default). This resizes shorter strings and preventslipgloss.{Width,Height}
from measuring the actual size of a cell. Notice thatstrings.TrimSpace()
won't work here. The spaces are intermingled with escape codes in a convoluted way. You can test this by writingtxt
to a file. Is this the intended behavior?The text was updated successfully, but these errors were encountered: