Adds support for Hyperlinks
Adds support for Hyperlinks in many modern terminal emulators, as described in this gist.
package main
import (
"fmt"
"github.com/logrusorgru/aurora"
)
func main() {
fmt.Println("Now with ", aurora.Link("links", "https://github.com/logrusorgru/aurora"))
}
Coverage remained the same at 100.0% when pulling c91a2c1016abae26b951524e50afc1189ef6cb2e on jphastings:feature/hyperlinks into 806901bec141cfa65f25b4472d5fb1b461609771 on logrusorgru:master.
These tests are a little awkward, as the hyperlink escape codes are of a very different structure to the colourising ones, but this gets coverage back to 100% and allows the PR to go green!
Do let me know if you think there's a better approach!
Hello, @jphastings! There are some notes...
- It should be implemented like this
func (v value) Link(url string) Value {
return valueLink{value: v, url: url}
}
// a value with a link
type valueLink struct {
value
url string
}
func (v valueLink) String() string {
// TODO: link
return v.value.String() // TODO: link
}
func (v valueLink) Reset() Value {
v.color, v.tailColor, v.url = 0, 0, ""
return v
}
func (v valueLink) Format(s fmt.State, verb rune) {
// TODO: with the link
}
func (v valueLink) Link(url string) Value {
v.url = url // change
return v
}
This way the value will not be encomplicated with additional 'url' that is not used in most cases. And the valueLink just overwrites required methods. Inheriting all other methods from the value type.
- The
Stringmethods also should return necessary escape sequences. - In reality it looks like something like

(example for XFCE4 terminal). No link target shown, no pointer cursor. Just a text. We need add this important note into README. Because users, I think, expect something other.
misfeature
Unfortunately, author of the feature https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda removes comments from the discussion. Thus, no explanation has survived.
Finally, I've got the explanation, I need some work around this PR and bump v4.... Soon.
You'd like some changes from me?
You'd like some changes from me?
No, thank, you, I will make them myself.
Feature included in #26. Thank you.