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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user