-
Notifications
You must be signed in to change notification settings - Fork 274
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
feat(viewport): gutter column, soft wrap, search highlight #697
base: feature/i236-viewport-horizontal-scroll
Are you sure you want to change the base?
Conversation
showing off soft wrap and search as well (on gum): CleanShot.2025-01-08.at.12.00.51.mp4 |
Signed-off-by: Carlos Alexandro Becker <[email protected]>
go.mod
Outdated
@@ -32,3 +32,5 @@ require ( | |||
golang.org/x/sys v0.26.0 // indirect | |||
golang.org/x/text v0.3.8 // indirect | |||
) | |||
|
|||
replace github.com/charmbracelet/lipgloss => ../lipgloss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should def remember to remove this before merging 😄
looks like this right now (using it in gum): CleanShot.2025-01-08.at.22.56.32.mp4 |
* 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 <[email protected]> * 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 <[email protected]> * fix: visible lines take frame into account --------- Signed-off-by: Carlos Alexandro Becker <[email protected]> Co-authored-by: Carlos Alexandro Becker <[email protected]> Co-authored-by: Christian Rocha <[email protected]>
This reverts commit 933f181.
This reverts commit 0e3e31b.
return m.prependColumn(lines) | ||
} | ||
|
||
func (m Model) highlighLines(lines []string, offset int) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
highlightLines*
// Use [SetHighligths] to set the highlight ranges, and [HightlightNext] | ||
// and [HihglightPrevious] to navigate. | ||
// Use [ClearHighlights] to remove all highlights. | ||
func (m *Model) SetHighligths(matches [][]int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*SetHighlights
TODO: create a runnable example with the API changes @bashbunni |
return hi.lineStart, 0, 0 | ||
} | ||
|
||
func makeHilightRanges( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Highlight*
This adds a
ColumnSign
API (name is the worst part of this so far), which allows you to define a left column in the viewport, which isn't taken into account when horizontal scrolling.You can use to show line numbers, for example:
which would render something like:
CleanShot.2025-01-07.at.16.36.30.mp4
As you can notice in the video and code, it also fills to the height if the viewport if the number of lines is lower than the available height, similar to what neovim and other editors do.
It also adds the ability to highlight ranges, e.g. from regex matches. This should work regardless of ansi sequences and/or grapheme clusters.
Finally, it adds options to soft wrap lines and to fill the height with empty lines.
Things to take into account here: