Skip to content

Commit

Permalink
make escape much more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
mecaneer23 committed Oct 3, 2023
1 parent cc3c7ba commit e565fa0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/get_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,9 @@ def handle_escape(
todo: Todo,
) -> tuple[list[str], int] | None:
stdscr_win[1].nodelay(True)
escape = stdscr_win[1].getch() # skip `[`
escape_table: dict[
int, tuple[Callable[..., tuple[list[str], int] | None], tuple[Any, ...]]
] = {
-1: (set_mode_true, (mode,)), # escape
}
if escape in escape_table:
func, args = escape_table[escape]
return func(*args)
if stdscr_win[1].getch() == -1: # skip `[` and check for escape
set_mode_true(mode)
return None
stdscr_win[1].nodelay(False)
try:
subch = stdscr_win[1].getch()
Expand Down

0 comments on commit e565fa0

Please sign in to comment.