diff options
author | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-23 21:05:09 +0200 |
---|---|---|
committer | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-26 01:58:20 +0200 |
commit | 23fe0290ad37197cb80ca464a7287cd78191e91a (patch) | |
tree | acdbe053652a706413ca69751bec4ac05e058b80 /pkg | |
parent | ed2dcd9e461d99b7969dee73fb96233947ee0ecf (diff) |
add openFile to gui struct
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/files_panel.go | 9 | ||||
-rw-r--r-- | pkg/gui/status_panel.go | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index eb1fff94d..760dee934 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -248,7 +248,7 @@ func (gui *Gui) handleFileOpen(g *gocui.Gui, v *gocui.View) error { if err != nil { return err } - return gui.genericFileOpen(g, v, file.Name, func(filename string) (*exec.Cmd, error) { return nil, gui.OSCommand.OpenFile(filename) }) + return gui.openFile(file.Name) } func (gui *Gui) handleSublimeFileOpen(g *gocui.Gui, v *gocui.View) error { @@ -417,3 +417,10 @@ func (gui *Gui) handleResetHard(g *gocui.Gui, v *gocui.View) error { return gui.refreshFiles(g) }, nil) } + +func (gui *Gui) openFile(filename string) error { + if err := gui.OSCommand.OpenFile(filename); err != nil { + return gui.createErrorPanel(gui.g, err.Error()) + } + return nil +} diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 27e0aba5b..bad543880 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -2,7 +2,6 @@ package gui import ( "fmt" - "os/exec" "github.com/fatih/color" "github.com/jesseduffield/gocui" @@ -66,8 +65,7 @@ func (gui *Gui) handleStatusSelect(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleOpenConfig(g *gocui.Gui, v *gocui.View) error { - filename := gui.Config.GetUserConfig().ConfigFileUsed() - return gui.genericFileOpen(g, v, filename, func(filename string) (*exec.Cmd, error) { return nil, gui.OSCommand.OpenFile(filename) }) + return gui.openFile(gui.Config.GetUserConfig().ConfigFileUsed()) } func (gui *Gui) handleEditConfig(g *gocui.Gui, v *gocui.View) error { |