Add support for the events of a horizontal mouse wheel and when holding
shift while using the regular mouse wheel now scrolls the screen left
and right.
Add support for the events of a horizontal mouse wheel and when holding
shift while using the regular mouse wheel now scrolls the screen left
and right.
* Reapply "fix(viewport): normalize method names"
This reverts commit f2434c374b.
* test: fixes
* fix: lint
* fix: disable horizontal scroll on v1
it might be a breaking change.
let's enable it by default on v2, and remove the deprecated methods as
well.
cc/ @meowgorithm
* fix: simplify
Since LeftGutterFunc is public, it can be nil if viewport is
instantiated without using `viewport.New()`. This commit adds nil
checks to handle this case.
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>
This breaks the API and removes high performance rendering and its
related methods from the viewport package. It changes the API and
makes the methods return nothing instead of lines to render.
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.