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

Todo and TextFile have keyboard short-cut to open file in OS

This commit is contained in:
Chris Cummer
2018-04-24 11:00:59 -07:00
parent 42559c396d
commit ed52835650
3 changed files with 36 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package todo
import (
"fmt"
"io/ioutil"
//"os/exec"
"time"
"github.com/gdamore/tcell"
@@ -82,6 +83,11 @@ func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
case "n":
// Add a new item
return nil
case "o":
// Open the file
//widget.openFile()
wtf.OpenFile(widget.FilePath)
return nil
}
switch event.Key() {
@@ -133,6 +139,14 @@ func (widget *Widget) load() {
yaml.Unmarshal(fileData, &widget.list)
}
//func (widget *Widget) openFile() {
//confDir, _ := wtf.ConfigDir()
//filePath := fmt.Sprintf("%s/%s", confDir, widget.FilePath)
//cmd := exec.Command("open", filePath)
//wtf.ExecuteCommand(cmd)
//}
// persist writes the todo list to Yaml file
func (widget *Widget) persist() {
confDir, _ := wtf.ConfigDir()