If the viewport has borders, they are not currently taken into account
when calculating the viewport max y offset, which might cause the last
line to not be visible.
This is easily reproducible in `gum pager`.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
* horizontal scroll
* rebase branch
* add tests
* add tests with 2 cells symbols
* trimLeft, move to charmbracelete/x/ansi lib
* up ansi package
* Update viewport/viewport.go
Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
* fix: do not navigate out to the right
* fix: cache line width on setcontent
* fix tests
* fix viewport tests
* add test for preventing right overscroll
* chore(viewport): increase horizontal step to 6
* chore(viewport): make horizontal scroll API better match vertical scroll API
* fix: nolint
* fix: use ansi.Cut
* perf: do not cut anything if not needed
* feat: expose HorizontalScrollPercent
* fix: do not scroll if width is 0
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
* fix: visible lines take frame into account
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Christian Rocha <christian@rocha.is>
There are many "interesting" cases:
- logical content is wider than display width (long lines).
In this case, we truncate.
- logical content is smaller than display height (fewer lines
than visible).
In this case, we pad with empty lines up to the specified height.
- logical content is higher than display height (more lines than
visible).
In this case, we truncate.
- style specifies a width wider than the display width.
In this case, we ignore the style width and
fit in the display width.
- style specifies a height higher than the display height.
Same as width, we ignore the style and fit in the display height.
- style specifies a narrower width or smaller height than the display.
In this case we obey the style.
This previously went unnoticed because we all seemed to have newlines at
the end of our viewport input.
This update introduces the Model.SetYOffset method.