commit 88456a57925361c3c48b64d19a6377bf7ac971c2
parent 273788f0d122096a01dcbdcee174f27a320b2664
Author: mtmn <miro@haravara.org>
Date: Fri, 10 Jul 2026 17:04:04 +0200
wrd: add option to open dilo
Diffstat:
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/wrd/tui.go b/wrd/tui.go
@@ -119,7 +119,7 @@ func (a *app) handle(b []byte) bool {
case c == 13 || c == 10: // enter
a.open()
case c == 15: // ctrl-o
- a.openURL()
+ a.openDillo()
case c == 25: // ctrl-y
a.yank()
case c == 14: // ctrl-n
@@ -271,11 +271,26 @@ func (a *app) open() {
})
}
-func (a *app) openURL() {
- if m, ok := a.cur(); ok {
- u := url(m.d.rel)
- a.withExternal(func() { runTTY(exec.Command("cha", u)) })
+func (a *app) openDillo() {
+ m, ok := a.cur()
+ if !ok {
+ return
}
+ src := m.d.src
+ a.withExternal(func() {
+ if strings.HasSuffix(strings.ToLower(src), ".md") {
+ tmp, err := os.CreateTemp("", "wrd-*.html")
+ if err != nil {
+ return
+ }
+ defer func() { _ = os.Remove(tmp.Name()) }()
+ out, _ := exec.Command("lowdown", src).Output()
+ _, _ = tmp.Write(out)
+ _ = tmp.Close()
+ src = tmp.Name()
+ }
+ runTTY(exec.Command("dillo", src))
+ })
}
func (a *app) yank() {