Cannot select text from the terminal nor click links with style.Url(someUrl)
otaxhu opened this issue · 5 comments
otaxhu commented
I'm using windows 10, literally this is my code:
package main
import (
"log"
"github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
)
func main() {
s, err := tcell.NewConsoleScreen()
if err != nil {
log.Fatal(err)
}
if err := s.Init(); err != nil {
log.Fatal(err)
}
s.EnableMouse()
renderUi := func() {
s.Clear()
w, h := s.Size()
h = h - 2
msg := "app started in this url "
appUrl := "http://127.0.0.1:" + fmt.Sprint(cfg.Server.Port)
x := (w - len(msg) - len(appUrl)) / 2
y := h / 2
x = emitStr(s, x, y, tcell.StyleDefault, msg)
emitStr(s, x, y, tcell.StyleDefault.Underline(true).Url(appUrl), appUrl)
exitMsg := "Press any key to exit the program..."
emitStr(s, (w-len(exitMsg))/2, y+2, tcell.StyleDefault.Background(tcell.NewRGBColor(0, 0, 135)), exitMsg)
s.Show()
}
renderUi()
PollEventLoop:
for {
switch s.PollEvent().(type) {
case *tcell.EventResize:
renderUi()
case *tcell.EventKey:
s.Fini()
break PollEventLoop
}
}
}
func emitStr(s tcell.Screen, x, y int, style tcell.Style, str string) int {
for _, c := range str {
var comb []rune
w := runewidth.RuneWidth(c)
if w == 0 {
comb = []rune{c}
c = ' '
w = 1
}
s.SetContent(x, y, c, comb, style)
x += w
}
return x
}
gdamore commented
Are you using Windows Terminal, or some other emulator?
otaxhu commented
Using cmd.exe.
gdamore commented
So style.Url is dependent entirely on your terminal emulator. Only a few terminal emulators support it. CMD.exe is not one. Sorry, but there is nothing I can do about it.
otaxhu commented
Which terminals are supported?
gdamore commented
I am not sure on Windows. ConEmu is probably one of the ones more likely to do so. Its a relatively new feature mostly found on Linux terminals.
• Garrett
…On Dec 4, 2023 at 6:33 AM -0800, Oscar Pernia ***@***.***>, wrote:
Which terminals are supported?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>