diff --git a/README.md b/README.md index 96bb72e..f7f1e12 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Key Bindings ? - display this help message q, ctrl-c - quit + w - save current todo file ### Movement diff --git a/README.rst b/README.rst index 7921461..15fadbd 100644 --- a/README.rst +++ b/README.rst @@ -104,6 +104,7 @@ General ? - display this help message q, ctrl-c - quit + w - save current todo file Movement ~~~~~~~~ diff --git a/setup.py b/setup.py index e80c6a3..ce8a4f3 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ Requirements ------------ -Python 2.7.5 or Python 3.3.2 with readline support. +Python 2.7 or Python 3.3 with readline support. Documentation ------------- diff --git a/todotxt_machine/__init__.py b/todotxt_machine/__init__.py index 6569516..7abd71f 100644 --- a/todotxt_machine/__init__.py +++ b/todotxt_machine/__init__.py @@ -13,7 +13,7 @@ __title__ = "todotxt_machine" __author__ = "Anthony DiGirolamo" __license__ = "GPL3" -__version__ = (1, 1, 6) +__version__ = (1, 1, 8) version = "%s.%s.%s" % __version__ diff --git a/todotxt_machine/screen.py b/todotxt_machine/screen.py index 3b252fc..d1374dd 100644 --- a/todotxt_machine/screen.py +++ b/todotxt_machine/screen.py @@ -66,6 +66,7 @@ def __init__(self, todo, readline_editing_mode='vi'): self.todo = todo self.sorting_names = ["Unsorted", "Ascending ", "Descending"] self.sorting = 0 + self.saved_message = "" self.clear_search_term() self.readline_editing_mode = readline_editing_mode self.update_todos(todo) @@ -136,7 +137,11 @@ def update(self): else: right_header = " {0} ".format( self.todo.file_path[:].replace(os.environ['HOME'], '~') - ).rjust(columns-left_header_size)[:columns-left_header_size] + ) + if len(self.saved_message) > 0: + right_header = self.saved_message + right_header + self.saved_message = "" + right_header = right_header.rjust(columns-left_header_size)[:columns-left_header_size] term.output( term.clear_formatting() ) term.move_cursor(1, 1) @@ -317,6 +322,7 @@ def display_help(self): ? - display this help message q, ctrl-c - quit + w - save current todo file ### Movement @@ -397,6 +403,7 @@ def search_loop(self): self.selected_project = 0 self.update() self.draw_search_prompt() + while True: if sys.stdin in select.select([sys.stdin], [], [], 0.1)[0]: c = sys.stdin.read(1) @@ -420,6 +427,11 @@ def search_loop(self): self.update() self.draw_search_prompt() + # if we have no search results when return is hit, exit search mode + if len(self.items) <= 0: + self.clear_search_term() + self.update() + def main_loop(self): self.set_raw_input() self.update() @@ -434,6 +446,9 @@ def main_loop(self): if c != "": if c == "?": self.display_help() + elif c == "w": + self.todo.save() + self.saved_message = "Saved!" elif c == "j": self.move_selection_down() elif c == "k": @@ -460,8 +475,12 @@ def main_loop(self): elif self.sorting == 2: self.todo.sorted_raw() self.sorting = 0 + self.move_selection_top() elif c == "x": i = self.items[self.selected_item].raw_index + if self.sorting > 0: + i = self.selected_item + if self.todo[i].is_complete(): self.todo[i].incomplete() else: @@ -520,6 +539,8 @@ def restore_normal_input(self): def delete_item(self): raw_index = self.items[self.selected_item].raw_index + if self.sorting > 0: + raw_index = self.selected_item self.todo.delete(raw_index) if self.selected_item == len(self.items): self.move_selection_up() @@ -539,6 +560,8 @@ def edit_item(self, new=False): elif new == 'insert_before' or new == 'insert_after': if len(self.todo) > 0: raw_index = self.items[self.selected_item].raw_index + if self.sorting > 0: + raw_index = self.selected_item if new == 'insert_after': raw_index += 1 else: @@ -552,6 +575,8 @@ def edit_item(self, new=False): else: # starting_row = self.selected_row raw_index = self.items[self.selected_item].raw_index + if self.sorting > 0: + raw_index = self.selected_item new_todo_line = self.items[self.selected_item].raw.strip() readline.set_startup_hook(lambda: readline.insert_text(new_todo_line)) diff --git a/todotxt_machine/todo.py b/todotxt_machine/todo.py index a311610..2072dc6 100644 --- a/todotxt_machine/todo.py +++ b/todotxt_machine/todo.py @@ -115,10 +115,12 @@ def complete(self): today = date.today() self.raw = "x {0} ".format(today) + self.raw self.completed_date = "{0}".format(today) + self.update(self.raw) def incomplete(self): self.raw = re.sub(Todos._completed_regex, "", self.raw) self.completed_date = "" + self.update(self.raw) def add_creation_date(self): if self.creation_date == "":