jedib0t / go-pretty

Table-writer and more in golang!
MIT License
2.82k stars 113 forks source link

[Feature Request || Question] - Table - Clickable Results #326

Closed ondrovic closed 4 weeks ago

ondrovic commented 4 weeks ago

Is your feature request related to a problem? Please describe. No really a problem, not sure it even can be done

Describe the solution you'd like Using Table I would find it helpful if you somehow make it so the rows are clickable, I know you can open a file using

import "os/exec"
exec.Command(`explorer`, `/select,`, `File.txt`)

But for example image

I so I am thinking I would love it if somehow you could click the directory path and it would open. This might be way out of the scope of the table tool, since it would almost need to register some type of callback action to handle the clicks

Describe alternatives you've considered None yet

Additional context Add any other context or screenshots about the feature request here.

jedib0t commented 4 weeks ago

Maybe this is what you want: text/hyperlink.go

ondrovic commented 4 weeks ago

Maybe this is what you want: text/hyperlink.go

Ill give it a try and see

ondrovic commented 4 weeks ago

found another solution using another package ;-)

jedib0t commented 4 weeks ago

Can you share it here for posterity?

ondrovic commented 4 weeks ago

sure "github.com/logrusorgru/aurora/v4" is the package

in my case they are both set to the dir column
aurora.Hyperlink(label, link),

It does allow for doing the ctrl+click and open (although there is some formatting issues, which I am trying to figure out still)

image

image

Update:

Even using the default text.Htyperlink(dir, dir) as provided results in alignment issues

for _, result := range results.([]types.EntryResults) {
     dir = commonFormatters.FormatPath(result.Directory, runtime.GOOS)
     t.AppendRow(table.Row{
          text.Hyperlink(dir, dir),
      result.FileName,
      result.FileSize,
    })
}

image image