From 13cf61a5fb8eb53fbf21207e118240830d5f2ecd Mon Sep 17 00:00:00 2001 From: Saul Pwanson Date: Tue, 26 Sep 2023 15:48:18 -0700 Subject: [PATCH] [mouse] onclick with url launches $BROWSER with url; add displayer_url #2031 --- visidata/column.py | 3 +++ visidata/mouse.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/visidata/column.py b/visidata/column.py index d36795e6e..ef13c0d71 100644 --- a/visidata/column.py +++ b/visidata/column.py @@ -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. diff --git a/visidata/mouse.py b/visidata/mouse.py index 1df218bf0..b62679f4e 100644 --- a/visidata/mouse.py +++ b/visidata/mouse.py @@ -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)