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

Viewport: truncation and wrapping options #56

Open
meowgorithm opened this issue Jul 9, 2021 · 3 comments
Open

Viewport: truncation and wrapping options #56

meowgorithm opened this issue Jul 9, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@meowgorithm
Copy link
Member

meowgorithm commented Jul 9, 2021

It would be nice if the viewport provided some options to automatically wrap and truncate text to keep layouts from breaking, rather than leaving this as an exercise for the user.

The most likely solution here is to take advantage of reflow.

@meowgorithm meowgorithm changed the title Truncate at W\idth Viewport: truncation and wrapping options Jul 9, 2021
@mrusme
Copy link

mrusme commented Mar 20, 2022

Is this the reason why SetcContent with a very large text will make the viewport expand in height? I was under the assumption that I might have done something wrong, so I'm still looking into why the viewport won't obey the height I set. I thought that a large content will make the viewport scroll vertically.

@meowgorithm
Copy link
Member Author

@mrusme iirc, yes. you'll want to wrap your text with something like:

str := lipgloss.NewStyle().Width(width).Render(content)
model.SetContent(str)

@captv89
Copy link

captv89 commented Sep 24, 2024

@meowgorithm When the length of a line exceeds the width of the terminal, the line is soft-wrapped as per your example above. However, this is affects the scrolling. Scrolling is still assuming that each content line = line in the terminal, and stops after the YOffset has been incremented to the int value, which is the difference between viewport lines and total content lines. This affects the scroll percentage as well.

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

No branches or pull requests

4 participants