Merge pull request #531 from Xenopathic/taskwarrior-reset-next-task

taskwarrior: Add reset_next_task callback
This commit is contained in:
facetoe 2017-01-23 20:55:46 +08:00 committed by GitHub
commit 821bd950da

View File

@ -8,12 +8,19 @@ class Taskwarrior(IntervalModule):
Check Taskwarrior for pending tasks
Requires `json`
Formaters:
.. rubric:: Available formatters (uses :ref:`formatp`)
* `{ready}` contains number of tasks returned by ready_filter
* `{urgent}` contains number of tasks returned by urgent_filter
* `{ready}` contains number of tasks returned by `ready_filter`
* `{urgent}` contains number of tasks returned by `urgent_filter`
* `{next}` contains the description of next task
* `{project}` contains the projects the next task belongs to
.. rubric:: Available callbacks
* ``get_next_task`` Display the next most urgent task.
* ``get_prev_task`` Display the previous most urgent task.
* ``reset_next_task`` Display the most urgent task, resetting any \
switching by other callbacks.
"""
format = 'Task: {next}'
@ -31,6 +38,7 @@ class Taskwarrior(IntervalModule):
on_upscroll = "get_prev_task"
on_downscroll = "get_next_task"
on_rightclick = 'mark_task_as_done'
on_leftclick = "reset_next_task"
settings = (
('format', 'format string'),
@ -41,6 +49,10 @@ class Taskwarrior(IntervalModule):
('color_ready', '#78EAF2')
)
def reset_next_task(self):
self.next_id = 0
self.next_task = self.current_tasks[self.next_id]
def get_next_task(self):
self.next_id = (self.next_id + 1) % len(self.current_tasks)
self.next_task = self.current_tasks[self.next_id]