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

Open
wants to merge 56 commits into
base: master
Choose a base branch
from

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

@caarlos0 caarlos0 requested a review from meowgorithm as a code owner January 7, 2025 19:52
viewport/viewport.go Outdated Show resolved Hide resolved
@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
viewport/viewport.go Outdated Show resolved Hide resolved
viewport/viewport.go Outdated Show resolved Hide resolved
@bashbunni
Copy link
Member

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

viewport/highlight.go Outdated Show resolved Hide resolved
@bashbunni bashbunni added the enhancement New feature or request label Jan 23, 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
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

Successfully merging this pull request may close these issues.

feat: add search functionality viewport: horizontal scroll
4 participants