Skip to content

Commit

Permalink
Merge pull request #1 from AnthonyDiGirolamo/master
Browse files Browse the repository at this point in the history
update to new version
  • Loading branch information
fdlm committed Aug 17, 2014
2 parents 63eefb6 + 5e1a8b3 commit 8484161
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Key Bindings

? - display this help message
q, ctrl-c - quit
w - save current todo file

### Movement

Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ General

? - display this help message
q, ctrl-c - quit
w - save current todo file

Movement
~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down
2 changes: 1 addition & 1 deletion todotxt_machine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down
27 changes: 26 additions & 1 deletion todotxt_machine/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -317,6 +322,7 @@ def display_help(self):
? - display this help message
q, ctrl-c - quit
w - save current todo file
### Movement
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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":
Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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))

Expand Down
2 changes: 2 additions & 0 deletions todotxt_machine/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "":
Expand Down

0 comments on commit 8484161

Please sign in to comment.