implemented status switching on tasks
This commit is contained in:
@@ -24,6 +24,8 @@ STATUS_DONE = WHITE_GREEN
|
|||||||
STATUS_WORKING = WHITE_CYAN
|
STATUS_WORKING = WHITE_CYAN
|
||||||
STATUS_IDLE = WHITE_MAGENTA
|
STATUS_IDLE = WHITE_MAGENTA
|
||||||
|
|
||||||
|
statuses = [STATUS_WORKING,STATUS_IDLE,STATUS_DONE,0]
|
||||||
|
|
||||||
|
|
||||||
# TODO add status editing of tasks
|
# TODO add status editing of tasks
|
||||||
# TODO add description viewing
|
# TODO add description viewing
|
||||||
@@ -58,13 +60,31 @@ class Project:
|
|||||||
class Task:
|
class Task:
|
||||||
def __init__(self,title: str,desc=""):
|
def __init__(self,title: str,desc=""):
|
||||||
self.title = title
|
self.title = title
|
||||||
self.status = Status.IDLE
|
self.status = Status.NONE
|
||||||
|
|
||||||
class Status(Enum):
|
class Status(Enum):
|
||||||
NONE = 1
|
WORKING = 0
|
||||||
|
IDLE = 1
|
||||||
DONE = 2
|
DONE = 2
|
||||||
WORKING = 3
|
NONE = 3
|
||||||
IDLE = 4
|
|
||||||
|
def prev(self):
|
||||||
|
print("previous of {}".format(self))
|
||||||
|
v = self.value - 1
|
||||||
|
if v < 0:
|
||||||
|
v = 3
|
||||||
|
print("previous is {}".format(Status(v)))
|
||||||
|
return Status(v)
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
print("next of {}".format(self))
|
||||||
|
v = self.value + 1
|
||||||
|
if v > 3:
|
||||||
|
v = 0
|
||||||
|
print("next is {}".format(Status(v)))
|
||||||
|
return Status(v)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO maybe get rid of this enum and just use a number
|
# TODO maybe get rid of this enum and just use a number
|
||||||
class SelectedWindow(Enum):
|
class SelectedWindow(Enum):
|
||||||
@@ -127,10 +147,15 @@ def draw_tasks(stdscr, tasks, selected_window,idx):
|
|||||||
# draw task names
|
# draw task names
|
||||||
y = 1
|
y = 1
|
||||||
for i, task in enumerate(tasks):
|
for i, task in enumerate(tasks):
|
||||||
|
stdscr.attron(curses.color_pair(statuses[task.status.value]))
|
||||||
|
stdscr.addstr(y,menu_width+1," " * (width-1))
|
||||||
if i == idx and SelectedWindow(selected_window) == SelectedWindow.TASKS:
|
if i == idx and SelectedWindow(selected_window) == SelectedWindow.TASKS:
|
||||||
stdscr.addstr(y, menu_width + 1, task.title,curses.A_REVERSE)
|
stdscr.addstr(y, menu_width + 1, task.title, curses.A_REVERSE)
|
||||||
else:
|
else:
|
||||||
stdscr.addstr(y, menu_width + 1, task.title)
|
stdscr.addstr(y, menu_width + 1, task.title)
|
||||||
|
if task.status != Status.NONE:
|
||||||
|
stdscr.addstr(y, menu_width + width - len(task.status.name), task.status.name)
|
||||||
|
stdscr.attroff(curses.color_pair(statuses[task.status.value]))
|
||||||
y = y + 1
|
y = y + 1
|
||||||
|
|
||||||
# draw color instructions
|
# draw color instructions
|
||||||
@@ -148,6 +173,8 @@ def draw_tasks(stdscr, tasks, selected_window,idx):
|
|||||||
stdscr.addstr(instructions_start + 3,menu_width + 4 + width - int(1.5*len("WORKING")+1),"WORKING",curses.color_pair(STATUS_WORKING))
|
stdscr.addstr(instructions_start + 3,menu_width + 4 + width - int(1.5*len("WORKING")+1),"WORKING",curses.color_pair(STATUS_WORKING))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main(stdscr):
|
def main(stdscr):
|
||||||
|
|
||||||
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_MAGENTA)
|
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_MAGENTA)
|
||||||
@@ -223,6 +250,11 @@ def main(stdscr):
|
|||||||
# so we don't want the index to be out of bounds
|
# so we don't want the index to be out of bounds
|
||||||
if SelectedWindow(selected_window) == SelectedWindow.PROJECTS: task_index = 0
|
if SelectedWindow(selected_window) == SelectedWindow.PROJECTS: task_index = 0
|
||||||
|
|
||||||
|
elif k == 32: # space key
|
||||||
|
projects[project_index].tasks[task_index].status = projects[project_index].tasks[task_index].status.next()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stdscr.clear()
|
stdscr.clear()
|
||||||
draw_menu(stdscr, projects, project_index, selected_window)
|
draw_menu(stdscr, projects, project_index, selected_window)
|
||||||
|
|||||||
Reference in New Issue
Block a user