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

Properly scope Config to the wtf package and remove it as a dependency from everywhere else

This commit is contained in:
Chris Cummer
2018-06-16 14:59:22 -07:00
parent abedee0ce0
commit 66b69471d0
42 changed files with 126 additions and 251 deletions

View File

@@ -33,15 +33,15 @@ func (widget *Widget) display() {
}
func (widget *Widget) formattedItemLine(item *Item, selectedItem *Item, maxLen int) string {
foreColor, backColor := "white", Config.UString("wtf.colors.background", "black")
foreColor, backColor := "white", wtf.Config.UString("wtf.colors.background", "black")
if item.Checked {
foreColor = Config.UString("wtf.mods.todo.colors.checked", "white")
foreColor = wtf.Config.UString("wtf.mods.todo.colors.checked", "white")
}
if widget.View.HasFocus() && (item == selectedItem) {
foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black")
backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white")
foreColor = wtf.Config.UString("wtf.mods.todo.colors.highlight.fore", "black")
backColor = wtf.Config.UString("wtf.mods.todo.colors.highlight.back", "white")
}
str := fmt.Sprintf(

View File

@@ -1,5 +1,9 @@
package todo
import (
"github.com/senorprogrammer/wtf/wtf"
)
type Item struct {
Checked bool
Text string
@@ -7,7 +11,7 @@ type Item struct {
func (item *Item) CheckMark() string {
if item.Checked {
return Config.UString("wtf.mods.todo.checkedIcon", "x")
return wtf.Config.UString("wtf.mods.todo.checkedIcon", "x")
} else {
return " "
}

View File

@@ -5,16 +5,12 @@ import (
"io/ioutil"
"github.com/gdamore/tcell"
"github.com/olebedev/config"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/cfg"
"github.com/senorprogrammer/wtf/wtf"
"gopkg.in/yaml.v2"
)
// Config is a pointer to the global config object
var Config *config.Config
const HelpText = `
Keyboard commands for Todo:
@@ -52,7 +48,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
TextWidget: wtf.NewTextWidget(" Todo ", "todo", true),
app: app,
filePath: Config.UString("wtf.mods.todo.filename"),
filePath: wtf.Config.UString("wtf.mods.todo.filename"),
list: &List{selected: -1},
pages: pages,
}