mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Move generic checklist code into its own package
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/checklist"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@@ -11,7 +12,7 @@ const checkWidth = 4
|
||||
|
||||
func (widget *Widget) display() {
|
||||
str := ""
|
||||
newList := wtf.NewChecklist()
|
||||
newList := checklist.NewChecklist()
|
||||
|
||||
for _, item := range widget.list.UncheckedItems() {
|
||||
str = str + widget.formattedItemLine(item, widget.list.SelectedItem(), widget.list.LongestLine())
|
||||
@@ -30,7 +31,7 @@ func (widget *Widget) display() {
|
||||
widget.View.SetText(str)
|
||||
}
|
||||
|
||||
func (widget *Widget) formattedItemLine(item *wtf.ChecklistItem, selectedItem *wtf.ChecklistItem, maxLen int) string {
|
||||
func (widget *Widget) formattedItemLine(item *checklist.ChecklistItem, selectedItem *checklist.ChecklistItem, maxLen int) string {
|
||||
foreColor, backColor := "white", wtf.Config.UString("wtf.colors.background", "black")
|
||||
|
||||
if item.Checked {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/cfg"
|
||||
"github.com/senorprogrammer/wtf/checklist"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
@@ -39,7 +40,7 @@ type Widget struct {
|
||||
|
||||
app *tview.Application
|
||||
filePath string
|
||||
list wtf.Checklist
|
||||
list checklist.Checklist
|
||||
pages *tview.Pages
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
|
||||
app: app,
|
||||
filePath: wtf.Config.UString("wtf.mods.todo.filename"),
|
||||
list: wtf.NewChecklist(),
|
||||
list: checklist.NewChecklist(),
|
||||
pages: pages,
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ func (widget *Widget) Refresh() {
|
||||
widget.display()
|
||||
}
|
||||
|
||||
func (widget *Widget) SetList(newList wtf.Checklist) {
|
||||
func (widget *Widget) SetList(newList checklist.Checklist) {
|
||||
widget.list = newList
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user