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

OSC 8 (hyperlink) supports. #220

Closed
tartavull opened this issue Aug 31, 2023 · 12 comments · May be fixed by #313
Closed

OSC 8 (hyperlink) supports. #220

tartavull opened this issue Aug 31, 2023 · 12 comments · May be fixed by #313
Labels
enhancement New feature or request

Comments

@tartavull
Copy link

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
OSC8 allows for hyperlinks in terminals that support them. But currently even in terminals that support OSC8, it brakes the rest of the formatting provided by lipgloss. I would love to contribute this if I can be offered some guidance.

@tartavull tartavull added the enhancement New feature or request label Aug 31, 2023
@tomgeorge
Copy link

I have this requirement, too.

It looks like termenv, one of the project dependencies, supports hyperlinks. I haven't looked into it other than glancing at hyperlink.go, but I think one could use that to render a hyperlink.

It would be nice to have it wrapped in lipgloss so I can use the same APIs.

aymanbagabas added a commit that referenced this issue Mar 14, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 15, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 17, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 28, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 28, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 28, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 28, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Mar 28, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
@aymanbagabas aymanbagabas reopened this Mar 29, 2024
aymanbagabas added a commit that referenced this issue Apr 23, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
aymanbagabas added a commit that referenced this issue Apr 29, 2024
Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220
@testinfected
Copy link

Hi guys, what's the status of this? Displaying links works but width calculation is all wrong

@meowgorithm
Copy link
Member

Hey, @testinfected! In terms of width calculation, I believe it's correct now (we've reworked a lot of the underpinnings):

package main

import (
	"fmt"

	"github.com/charmbracelet/lipgloss"
)

func main() {
	const x = "\x1B]8;;http://charm.sh\x1B\\Hello\x1B]8;;\x1B\\\n"
	fmt.Println(lipgloss.Width(x)) // 5
}

Playground

If not, mind opening a separate issue with code to reproduce?

@testinfected
Copy link

Hey @meowgorithm good to know, thank you. I'm displaying an hyperlink in the spinner title, but part of the hyperlink is not visible unless I resize the terminal horizontally.

Let me double check and open a new issue then.

@testinfected
Copy link

It seems ok with all the latest versions of the libraries. I guess you can close this issue

Thanks for the quick response :-)

@testinfected
Copy link

FYI I had bubbletea 0.25, seems fixed with 0.26.3

@meowgorithm
Copy link
Member

meowgorithm commented May 29, 2024

Okay awesome, that's good to hear. Bubble Tea v0.26.x and Lip Gloss v0.11.x both use our new low level stuff in /x.

Let's keep this issue open until we add an API for hyperlinks, i.e. something like:

lipgloss.Hyperlink("https://charm.sh/", "Charm!")

@meowgorithm
Copy link
Member

meowgorithm commented May 29, 2024

Actually, I'd probably implement it on a style for control over the output:

str := lipgloss.NewStyle().
    Foreground(lipgloss.Color(63)).
    Underline(true).
    Hyperlink("https://charm.sh").
    Render("Charm!")

@Delta456
Copy link

Delta456 commented Jun 3, 2024

I would want to work on this!

@meowgorithm
Copy link
Member

@Delta456 urgh, I actually have a hyperlink branch open with most of this in place. I'll open up a PR for it in a few minutes and mention you.

@Delta456
Copy link

Delta456 commented Jun 3, 2024

@Delta456 urgh, I actually have a hyperlink branch open with most of this in place. I'll open up a PR for it in a few minutes and mention you.

Ah well, no worries! The implementation is almost the same as yours 🌠

@meowgorithm
Copy link
Member

meowgorithm commented Jun 4, 2024

Just a note that you can follow progress on this is #313. Getting it right will be a bit more complicated than meets the eye.

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 a pull request may close this issue.

6 participants