Skip to content

Commit

Permalink
[mouse] onclick with url launches $BROWSER with url; add displayer_url
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Sep 26, 2023
1 parent 3c0ff87 commit 13cf61a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions visidata/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ def formatValue(self, typedval, width=None):

return vd.getType(self.type).formatter(self.fmtstr, typedval)

def displayer_url(self, dw:DisplayWrapper, width=None):
yield ('onclick '+dw.text, dw.text)

def displayer_generic(self, dw:DisplayWrapper, width=None):
'''Fit *dw.text* into *width* charcells.
Generate list of (attr:str, text:str) suitable for clipdraw_chunks.
Expand Down
5 changes: 4 additions & 1 deletion visidata/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def handleMouse(vd, sheet):
if f:
if isinstance(f, str):
if f.startswith('onclick'):
sheet.execCommand(f[8:])
if '://' in f:
vd.launchBrowser(f[8:])
else:
sheet.execCommand(f[8:])
else:
for cmd in f.split():
sheet.execCommand(cmd)
Expand Down

0 comments on commit 13cf61a

Please sign in to comment.