1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Added HTTP/HTTPS handling in OpenFile() function in wtf/utils.go to manage proper URL openings

This commit is contained in:
Johan Denoyer 2019-01-18 16:33:27 +01:00
parent 1d888118c5
commit 5adfbfb066

View File

@ -7,6 +7,7 @@ import (
"regexp"
"strings"
//"sync"
"runtime"
"github.com/rivo/tview"
)
@ -95,12 +96,23 @@ func NamesFromEmails(emails []string) []string {
// OpenFile opens the file defined in `path` via the operating system
func OpenFile(path string) {
if (strings.HasPrefix(path,"http://"))||(strings.HasPrefix(path,"https://")) {
switch runtime.GOOS {
case "linux":
exec.Command("xdg-open", path).Start()
case "windows":
exec.Command("rundll32", "url.dll,FileProtocolHandler", path).Start()
case "darwin":
exec.Command("open", path).Start()
default:
}
}else {
filePath, _ := ExpandHomeDir(path)
openFileUtil := Config.UString("wtf.openFileUtil", "open")
cmd := exec.Command(openFileUtil, filePath)
ExecuteCommand(cmd)
}
}
// PadRow returns a padding for a row to make it the full width of the containing widget.
// Useful for ensurig row highlighting spans the full width (I suspect tcell has a better