More Progress
* List by default, UI only if specified * Archive tasks to done list * Fix filter
This commit is contained in:
parent
9bc8de8700
commit
d11bf67196
@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
todotxt "github.com/JamesClonk/go-todotxt"
|
todotxt "github.com/br0xen/go-todotxt"
|
||||||
"github.com/br0xen/user-config"
|
"github.com/br0xen/user-config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
4
main.go
4
main.go
@ -18,8 +18,8 @@ func main() {
|
|||||||
if len(os.Args) > 1 {
|
if len(os.Args) > 1 {
|
||||||
parms = os.Args[1:]
|
parms = os.Args[1:]
|
||||||
} else {
|
} else {
|
||||||
// If no parameters were passed, just do an ls
|
// If no parameters were passed, do a list
|
||||||
parms = append(parms, "ui")
|
parms = append(parms, "ls")
|
||||||
}
|
}
|
||||||
os.Exit(app.run(parms))
|
os.Exit(app.run(parms))
|
||||||
}
|
}
|
||||||
|
8
model.go
8
model.go
@ -4,7 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
todotxt "github.com/JamesClonk/go-todotxt"
|
todotxt "github.com/br0xen/go-todotxt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *AppState) addTask(taskString string) error {
|
func (a *AppState) addTask(taskString string) error {
|
||||||
@ -39,9 +39,11 @@ func (a *AppState) archiveTask(id int) error {
|
|||||||
if task, err = a.TaskList.GetTask(id); err != nil {
|
if task, err = a.TaskList.GetTask(id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
a.TaskList.RemoveTask(*task)
|
|
||||||
task.Completed = true
|
task.Completed = true
|
||||||
a.DoneList.AddTask(task)
|
if err := a.TaskList.ArchiveTaskToFile(*task, app.getDoneFile()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
a.TaskList.RemoveTask(*task)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
todotxt "github.com/JamesClonk/go-todotxt"
|
todotxt "github.com/br0xen/go-todotxt"
|
||||||
"github.com/br0xen/termbox-util"
|
"github.com/br0xen/termbox-util"
|
||||||
termbox "github.com/nsf/termbox-go"
|
termbox "github.com/nsf/termbox-go"
|
||||||
)
|
)
|
||||||
@ -159,15 +159,15 @@ func (screen *MainScreen) handleConfirmKeyEvent(event termbox.Event) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (screen *MainScreen) handleInputKeyEvent(event termbox.Event) int {
|
func (screen *MainScreen) handleInputKeyEvent(event termbox.Event) int {
|
||||||
screen.inputField.SetID("add task")
|
|
||||||
id := screen.inputField.GetID()
|
id := screen.inputField.GetID()
|
||||||
if id == "filter" {
|
if id == "filter" {
|
||||||
if event.Key == termbox.KeyEnter {
|
if event.Key == termbox.KeyEnter {
|
||||||
// Apply the filter
|
// Apply the filter
|
||||||
screen.backspaceDoes = MainBackspaceFilter
|
filter := screen.inputField.GetValue()
|
||||||
screen.reloadList(screen.buildBundle(screen.currentList, screen.inputField.GetValue()))
|
|
||||||
screen.inputField.SetID("")
|
screen.inputField.SetID("")
|
||||||
screen.inputField.SetValue("")
|
screen.inputField.SetValue("")
|
||||||
|
screen.backspaceDoes = MainBackspaceFilter
|
||||||
|
screen.reloadList(screen.buildBundle(screen.currentList, filter))
|
||||||
return ScreenMain
|
return ScreenMain
|
||||||
}
|
}
|
||||||
} else if id == "add task" {
|
} else if id == "add task" {
|
||||||
@ -177,13 +177,13 @@ func (screen *MainScreen) handleInputKeyEvent(event termbox.Event) int {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
screen.setMessage(err.Error())
|
screen.setMessage(err.Error())
|
||||||
}
|
}
|
||||||
|
screen.inputField.SetID("")
|
||||||
|
screen.inputField.SetValue("")
|
||||||
if err = app.WriteList(); err != nil {
|
if err = app.WriteList(); err != nil {
|
||||||
screen.setMessage(err.Error())
|
screen.setMessage(err.Error())
|
||||||
return ScreenMain
|
return ScreenMain
|
||||||
}
|
}
|
||||||
screen.reloadList(screen.buildBundle(screen.currentList, screen.currentFilter))
|
screen.reloadList(screen.buildBundle(screen.currentList, screen.currentFilter))
|
||||||
screen.inputField.SetID("")
|
|
||||||
screen.inputField.SetValue("")
|
|
||||||
return ScreenMain
|
return ScreenMain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,12 +211,20 @@ func (screen *MainScreen) drawScreen() {
|
|||||||
screen.setMessageWithTimeout("Press '?' for help", -1)
|
screen.setMessageWithTimeout("Press '?' for help", -1)
|
||||||
}
|
}
|
||||||
screen.drawHeader()
|
screen.drawHeader()
|
||||||
|
topId := 0
|
||||||
|
for _, v := range screen.displayList {
|
||||||
|
if v.Id > topId {
|
||||||
|
topId = v.Id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
padCnt := fmt.Sprintf("%d", topId)
|
||||||
for k, v := range screen.displayList {
|
for k, v := range screen.displayList {
|
||||||
|
pad := strings.Repeat(" ", len(padCnt)-len(fmt.Sprintf("%d", v.Id)))
|
||||||
useFg, useBg := DefaultFg, DefaultBg
|
useFg, useBg := DefaultFg, DefaultBg
|
||||||
if k == screen.viewPort.cursor {
|
if k == screen.viewPort.cursor {
|
||||||
useFg, useBg = CursorFg, CursorBg
|
useFg, useBg = CursorFg, CursorBg
|
||||||
}
|
}
|
||||||
termboxUtil.DrawStringAtPoint(app.getTaskString(v), 0, k+1, useFg, useBg)
|
termboxUtil.DrawStringAtPoint(pad+app.getTaskString(v), 0, k+1, useFg, useBg)
|
||||||
}
|
}
|
||||||
screen.drawFooter()
|
screen.drawFooter()
|
||||||
}
|
}
|
||||||
@ -249,25 +257,27 @@ func (screen *MainScreen) drawFooter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (screen *MainScreen) archiveCurrentItem() int {
|
func (screen *MainScreen) archiveCurrentItem() int {
|
||||||
/*
|
if screen.currentList != MainBundleListTodo {
|
||||||
// Find the task under the cursor
|
screen.setMessage("Task is already archived")
|
||||||
if len(screen.displayList) > screen.viewPort.cursor {
|
return ScreenMain
|
||||||
t := screen.displayList[screen.viewPort.cursor]
|
}
|
||||||
// Load the task screen with this task
|
// Find the task under the cursor
|
||||||
if err := a.archiveTask(t.Id); err != nil {
|
if len(screen.displayList) > screen.viewPort.cursor {
|
||||||
screen.setMessage(error.Error())
|
t := screen.displayList[screen.viewPort.cursor]
|
||||||
}
|
if err := app.archiveTask(t.Id); err != nil {
|
||||||
|
screen.setMessage(err.Error())
|
||||||
|
return ScreenMain
|
||||||
|
|
||||||
b := Bundle{}
|
|
||||||
b.setValue(TaskBundleTaskIdKey, t.Id)
|
|
||||||
if err := app.screens[ScreenTask].initialize(b); err != nil {
|
|
||||||
screen.setMessage(err.Error())
|
|
||||||
}
|
|
||||||
return ScreenTask
|
|
||||||
}
|
}
|
||||||
*/
|
if err := app.WriteList(); err != nil {
|
||||||
|
screen.setMessage(err.Error())
|
||||||
|
return ScreenMain
|
||||||
|
}
|
||||||
|
// Reload the list
|
||||||
|
b := screen.buildBundle(screen.currentList, screen.currentFilter)
|
||||||
|
if err := screen.reloadList(b); err != nil {
|
||||||
|
screen.setMessage(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
return ScreenMain
|
return ScreenMain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
todotxt "github.com/JamesClonk/go-todotxt"
|
todotxt "github.com/br0xen/go-todotxt"
|
||||||
"github.com/br0xen/termbox-util"
|
"github.com/br0xen/termbox-util"
|
||||||
termbox "github.com/nsf/termbox-go"
|
termbox "github.com/nsf/termbox-go"
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
todotxt "github.com/JamesClonk/go-todotxt"
|
todotxt "github.com/br0xen/go-todotxt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *AppState) opListTasks(args []string) int {
|
func (a *AppState) opListTasks(args []string) int {
|
||||||
|
Loading…
Reference in New Issue
Block a user