Skip to content

Commit

Permalink
refactor: remove _handle_edit()
Browse files Browse the repository at this point in the history
  • Loading branch information
mecaneer23 committed Apr 30, 2024
1 parent 0520765 commit 28abf16
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def edit_todo(
Open a get_todo input box with the current todo contents. Set
the todo to the edited contents.
"""
if len(todos) <= 0:
return todos
max_y, max_x = stdscr.getmaxyx()
todo = todos[selected].get_display_text()
ncols = (
Expand Down Expand Up @@ -286,17 +288,6 @@ def _handle_redo(selected: Cursor, history: UndoRedo) -> Todos:
return todos


def _handle_edit(
stdscr: curses.window,
todos: Todos,
selected: Cursor,
mode: SingleLineModeImpl,
) -> Todos:
if len(todos) <= 0:
return todos
return edit_todo(stdscr, todos, int(selected), mode)


def _handle_todo_down(
todos: Todos,
selected: Cursor,
Expand Down Expand Up @@ -567,7 +558,7 @@ def main(stdscr: curses.window) -> int:
Key.d: (delete_todo, "stdscr, todos, selected, copied_todo"),
Key.g: (selected.to_top, "None"),
Key.h: (help_menu, "stdscr"),
Key.i: (_handle_edit, "stdscr, todos, selected, single_line_state"),
Key.i: (edit_todo, "stdscr, todos, int(selected), single_line_state"),
Key.j: (selected.single_down, "len(todos)"),
Key.k: (selected.single_up, "len(todos)"),
Key.o: (new_todo_next, "stdscr, todos, selected, Todo(), single_line_state"),
Expand Down

0 comments on commit 28abf16

Please sign in to comment.