Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added shortcuts '+', '-' and 'o', underlining for those and 'e' #26

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Moved set due date logic in separate functions
  • Loading branch information
sdrwtf committed Oct 6, 2021
commit 3af36bdea9a6d018f390ae5f354b8958560be86b
36 changes: 18 additions & 18 deletions app/task_detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,15 @@ func (td *TaskDetailPane) makeDateRow() *tview.Flex {
app.SetFocus(td)
})

todaySelector := func() {
td.setTaskDate(parseDateInputOrCurrent("").Unix(), true)
}

nextDaySelector := func() {
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, 1).Unix(), true)
}

prevDaySelector := func() {
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, -1).Unix(), true)
}

return tview.NewFlex().
AddItem(td.taskDateDisplay, 0, 2, true).
AddItem(td.taskDate, 14, 0, true).
AddItem(blankCell, 1, 0, false).
AddItem(makeButton("t[::u]o[::-]day", todaySelector), 8, 1, false).
AddItem(makeButton("t[::u]o[::-]day", td.todaySelector), 8, 1, false).
AddItem(blankCell, 1, 0, false).
AddItem(makeButton("[::u]+[::-]1", nextDaySelector), 4, 1, false).
AddItem(makeButton("[::u]+[::-]1", td.nextDaySelector), 4, 1, false).
AddItem(blankCell, 1, 0, false).
AddItem(makeButton("[::u]-[::-]1", prevDaySelector), 4, 1, false)
AddItem(makeButton("[::u]-[::-]1", td.prevDaySelector), 4, 1, false)
}

func (td *TaskDetailPane) updateToggleDisplay() {
Expand Down Expand Up @@ -329,13 +317,13 @@ func (td *TaskDetailPane) handleShortcuts(event *tcell.EventKey) *tcell.EventKey
td.Export()
return nil
case 'o':
td.setTaskDate(parseDateInputOrCurrent("").Unix(), true)
td.todaySelector()
return nil
case '+':
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, 1).Unix(), true)
td.nextDaySelector()
return nil
case '-':
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, -1).Unix(), true)
td.prevDaySelector()
return nil
}
}
Expand All @@ -355,3 +343,15 @@ func (td *TaskDetailPane) SetTask(task *model.Task) {
td.updateToggleDisplay()
td.deactivateEditor()
}

func (td *TaskDetailPane) todaySelector() {
td.setTaskDate(parseDateInputOrCurrent("").Unix(), true)
}

func (td *TaskDetailPane) nextDaySelector() {
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, 1).Unix(), true)
}

func (td *TaskDetailPane) prevDaySelector() {
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, -1).Unix(), true)
}