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"
|
||||
"strings"
|
||||
|
||||
todotxt "github.com/JamesClonk/go-todotxt"
|
||||
todotxt "github.com/br0xen/go-todotxt"
|
||||
"github.com/br0xen/user-config"
|
||||
)
|
||||
|
||||
|
4
main.go
4
main.go
@ -18,8 +18,8 @@ func main() {
|
||||
if len(os.Args) > 1 {
|
||||
parms = os.Args[1:]
|
||||
} else {
|
||||
// If no parameters were passed, just do an ls
|
||||
parms = append(parms, "ui")
|
||||
// If no parameters were passed, do a list
|
||||
parms = append(parms, "ls")
|
||||
}
|
||||
os.Exit(app.run(parms))
|
||||
}
|
||||
|
8
model.go
8
model.go
@ -4,7 +4,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
todotxt "github.com/JamesClonk/go-todotxt"
|
||||
todotxt "github.com/br0xen/go-todotxt"
|
||||
)
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
a.TaskList.RemoveTask(*task)
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
todotxt "github.com/JamesClonk/go-todotxt"
|
||||
todotxt "github.com/br0xen/go-todotxt"
|
||||
"github.com/br0xen/termbox-util"
|
||||
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 {
|
||||
screen.inputField.SetID("add task")
|
||||
id := screen.inputField.GetID()
|
||||
if id == "filter" {
|
||||
if event.Key == termbox.KeyEnter {
|
||||
// Apply the filter
|
||||
screen.backspaceDoes = MainBackspaceFilter
|
||||
screen.reloadList(screen.buildBundle(screen.currentList, screen.inputField.GetValue()))
|
||||
filter := screen.inputField.GetValue()
|
||||
screen.inputField.SetID("")
|
||||
screen.inputField.SetValue("")
|
||||
screen.backspaceDoes = MainBackspaceFilter
|
||||
screen.reloadList(screen.buildBundle(screen.currentList, filter))
|
||||
return ScreenMain
|
||||
}
|
||||
} else if id == "add task" {
|
||||
@ -177,13 +177,13 @@ func (screen *MainScreen) handleInputKeyEvent(event termbox.Event) int {
|
||||
if err != nil {
|
||||
screen.setMessage(err.Error())
|
||||
}
|
||||
screen.inputField.SetID("")
|
||||
screen.inputField.SetValue("")
|
||||
if err = app.WriteList(); err != nil {
|
||||
screen.setMessage(err.Error())
|
||||
return ScreenMain
|
||||
}
|
||||
screen.reloadList(screen.buildBundle(screen.currentList, screen.currentFilter))
|
||||
screen.inputField.SetID("")
|
||||
screen.inputField.SetValue("")
|
||||
return ScreenMain
|
||||
}
|
||||
}
|
||||
@ -211,12 +211,20 @@ func (screen *MainScreen) drawScreen() {
|
||||
screen.setMessageWithTimeout("Press '?' for help", -1)
|
||||
}
|
||||
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 {
|
||||
pad := strings.Repeat(" ", len(padCnt)-len(fmt.Sprintf("%d", v.Id)))
|
||||
useFg, useBg := DefaultFg, DefaultBg
|
||||
if k == screen.viewPort.cursor {
|
||||
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()
|
||||
}
|
||||
@ -249,25 +257,27 @@ func (screen *MainScreen) drawFooter() {
|
||||
}
|
||||
|
||||
func (screen *MainScreen) archiveCurrentItem() int {
|
||||
/*
|
||||
if screen.currentList != MainBundleListTodo {
|
||||
screen.setMessage("Task is already archived")
|
||||
return ScreenMain
|
||||
}
|
||||
// Find the task under the cursor
|
||||
if len(screen.displayList) > screen.viewPort.cursor {
|
||||
t := screen.displayList[screen.viewPort.cursor]
|
||||
// Load the task screen with this task
|
||||
if err := a.archiveTask(t.Id); err != nil {
|
||||
screen.setMessage(error.Error())
|
||||
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 {
|
||||
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 ScreenTask
|
||||
}
|
||||
*/
|
||||
return ScreenMain
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
todotxt "github.com/JamesClonk/go-todotxt"
|
||||
todotxt "github.com/br0xen/go-todotxt"
|
||||
"github.com/br0xen/termbox-util"
|
||||
termbox "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
todotxt "github.com/JamesClonk/go-todotxt"
|
||||
todotxt "github.com/br0xen/go-todotxt"
|
||||
)
|
||||
|
||||
func (a *AppState) opListTasks(args []string) int {
|
||||
|
Loading…
Reference in New Issue
Block a user