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

Basic selectable todo functionality working

Can:
- move between todo items
- toggle checked/unchecked state

Cannot:
- persiste changes to file
- add items
- delete items
This commit is contained in:
Chris Cummer
2018-04-20 15:19:54 -07:00
parent 67e02bf4f5
commit a0ce5eb412
12 changed files with 279 additions and 28 deletions

View File

@@ -2,7 +2,6 @@ package textfile
import (
"fmt"
"io/ioutil"
"time"
"github.com/olebedev/config"
@@ -20,8 +19,8 @@ type Widget struct {
func NewWidget() *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(" Text File ", "textfile"),
FilePath: Config.UString("wtf.mods.textfile.filepath"),
TextWidget: wtf.NewTextWidget(" 📄 Text File ", "textfile"),
FilePath: Config.UString("wtf.mods.textfile.filename"),
}
widget.View.SetWrap(true)
@@ -41,7 +40,7 @@ func (widget *Widget) Refresh() {
widget.View.Clear()
fileData, err := widget.readFile()
fileData, err := wtf.ReadFile(widget.FilePath)
if err != nil {
fmt.Fprintf(widget.View, "%s", err)
@@ -49,16 +48,3 @@ func (widget *Widget) Refresh() {
fmt.Fprintf(widget.View, "%s", fileData)
}
}
/* -------------------- Uneported Functions -------------------- */
func (widget *Widget) readFile() (string, error) {
absPath, _ := wtf.ExpandHomeDir(widget.FilePath)
bytes, err := ioutil.ReadFile(absPath)
if err != nil {
return "", err
}
return string(bytes), nil
}