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

feat(viewport)!: gutter column, soft wrap, search highlight #697

Merged
merged 59 commits into from
Feb 4, 2025

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Jan 7, 2025

This PR adds several somewhat related features to viewport.

Highlights

First, is highlights! This should allow users to add search features to their tea apps. You can see an example of this here.

CleanShot.2025-01-23.at.13.39.33.mp4

The highlights take into account visible characters and ANSI escape sequences, so users should be able to do something like:

m.SetHighlights(re.FindAllStringIndex(m.GetContent(), -1)

And it should take care of everything.

Soft wrapping

Previously, users would have to soft wrap on their side, which is not as simple as it looks some times.

Having it here also helps with the left gutter feature, oops, I'm getting ahead of myself 🙈

Users can m.SoftWrap = true to enable this feature.
You can see soft wrapping in action in the video above.

Left Gutter

This allows to add a fixed gutter to the left side of the viewport. You can use these to show line numbers, indicators, and more.

Users can set the gutter function with m.LeftGutterFunc = <your func>.

Example with line numbers:

CleanShot.2025-01-23.at.13.40.51.mp4

Example with a selector:

CleanShot.2025-01-23.at.13.42.40.mp4

Other fixes

  • properly handle the position calculations when there's line wrapping

@caarlos0 caarlos0 requested a review from meowgorithm as a code owner January 7, 2025 19:52
@caarlos0 caarlos0 requested a review from bashbunni as a code owner January 8, 2025 14:58
@caarlos0 caarlos0 changed the title feat(viewport): column sign feat(viewport): gutter column, soft wrap, search highlight Jan 8, 2025
@bashbunni bashbunni added this to the viewport milestone Jan 23, 2025
@bashbunni bashbunni linked an issue Jan 23, 2025 that may be closed by this pull request
Signed-off-by: Carlos Alexandro Becker <[email protected]>
Signed-off-by: Carlos Alexandro Becker <[email protected]>
Signed-off-by: Carlos Alexandro Becker <[email protected]>
Signed-off-by: Carlos Alexandro Becker <[email protected]>
@caarlos0
Copy link
Member Author

caarlos0 commented Jan 23, 2025

TODO: create a runnable example with the API changes @bashbunni

On this branch of gum:

cat README.md | go run . pager

Working on making it work in gum filter, too

@bashbunni bashbunni linked an issue Jan 23, 2025 that may be closed by this pull request
@caarlos0 caarlos0 changed the base branch from feature/i236-viewport-horizontal-scroll to master January 24, 2025 13:29
@bashbunni bashbunni added the v2 label Feb 3, 2025
@caarlos0 caarlos0 changed the base branch from master to v2-exp February 4, 2025 14:47
Signed-off-by: Carlos Alexandro Becker <[email protected]>
@caarlos0 caarlos0 changed the title feat(viewport): gutter column, soft wrap, search highlight feat(viewport)!: gutter column, soft wrap, search highlight Feb 4, 2025
Signed-off-by: Carlos Alexandro Becker <[email protected]>
@caarlos0
Copy link
Member Author

caarlos0 commented Feb 4, 2025

moved this to v2 due to breaking changes: viewport now also allows for left/right/h/l, which needs to be handled in the caller if e.g. the user has a text input.

@caarlos0
Copy link
Member Author

caarlos0 commented Feb 4, 2025

windows tests are broken on v2-exp already.

@caarlos0 caarlos0 merged commit edbb81c into v2-exp Feb 4, 2025
22 of 26 checks passed
@caarlos0 caarlos0 deleted the columnsign branch February 4, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add search functionality viewport line wrapping bug viewport: horizontal scroll
4 participants