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

Make URLs in confirmation panels clickable, and underline them #3446

Merged
merged 5 commits into from Mar 29, 2024

Conversation

stefanhaller
Copy link
Collaborator

  • PR Description

This is especially helpful for the breaking changes popup, which has a link to the release notes, but it could also be useful for other panels that display some warning or error with a link to more information.

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • Docs (specifically docs/Config.md) have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@stefanhaller stefanhaller added the enhancement New feature or request label Mar 27, 2024
Copy link

codacy-production bot commented Mar 27, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.04% (target: -2.00%) 54.90%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (1cedfa4) 50365 42372 84.13%
Head commit (5d509ef) 50405 (+40) 42388 (+16) 84.09% (-0.04%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3446) 51 28 54.90%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Comment on lines +247 to +250
if strings.HasSuffix(underlinedLink, "\x1b[0m") {
// Replace the "all styles off" code with "underline off" code
underlinedLink = underlinedLink[:len(underlinedLink)-2] + "24m"
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty hacky, but we need it so that we don't cancel the bold text. I don't see a better way of doing this except by making changes to gookit/color.

@jesseduffield
Copy link
Owner

Thoughts on using tcell's terminal hyperlinks ability? gdamore/tcell#300

@stefanhaller
Copy link
Collaborator Author

I had no idea this existed. I'll play with this to see if it's useful for our case.

@stefanhaller
Copy link
Collaborator Author

So I'm not very thrilled by tcell's hyperlinks. I couldn't get it to work in Terminal.app, only in iTerm2 (but I may well have done something wrong). In general it's a bit unclear to me how widely supported the feature is yet.

Also, you have to hold down Command while clicking them (ctrl on Windows), which I find inconvenient, and hard to discover. I would prefer them to behave more like links on a web page; just click them.

Finally, it would take some effort to make this available in gocui, it's actually not quite clear to me how to design the APIs. There's plenty of code that just passes around fg and bg Attributes to functions (and those are enums); but we need to pass attached data for this one. It would take a while to add this to the current design of how attributes work in gocui.

To sum it up, I'd prefer to stick with the more pedestrian approach I'm taking here.

Copy link
Owner

@jesseduffield jesseduffield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, LGTM

Changing globals in the init() function of a test file is a bad idea, as it
affects all other tests that run after it. Do it explicitly in each test
function that needs it, and take care of restoring the previous value
afterwards.
Make it recognize URLs wrapped in angle brackets, and followed by punktuation.
We don't need this for the status panel, but we will need it for confirmation
panels.
This is not opt-in, we do it always. I can't imagine a situation where we
wouldn't want it.
@stefanhaller stefanhaller force-pushed the clickable-links-in-confirmation-panels branch from 5795f23 to 5d509ef Compare March 29, 2024 09:56
@stefanhaller stefanhaller merged commit 2385c1d into master Mar 29, 2024
14 checks passed
@stefanhaller stefanhaller deleted the clickable-links-in-confirmation-panels branch March 29, 2024 09:58
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.

None yet

2 participants