Skip to content

Commit

Permalink
fix: enable keyboardinterrupts throughout the app
Browse files Browse the repository at this point in the history
  • Loading branch information
mecaneer23 committed Jun 21, 2024
1 parent fa66fcc commit 80a83cc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/class_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def relative_to(
while True:
try:
key = stdscr.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
return
operation = self._set_to_clamp
if not single:
Expand Down
4 changes: 2 additions & 2 deletions src/get_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _handle_escape(
win.nodelay(False)
try:
input_char = win.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
return None
if input_char == Key.ctrl_delete:
return _handle_ctrl_delete(chars, position)
Expand Down Expand Up @@ -353,7 +353,7 @@ def get_todo(
win.refresh()
try:
input_char = win.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
mode.set_on()
return original
if input_char == Key.escape:
Expand Down
5 changes: 0 additions & 5 deletions src/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,3 @@ def normalize_ascii_digit_to_digit(ascii_digit: int) -> int:
if 48 <= ascii_digit <= 57:
return ascii_digit - 48
raise ValueError(f"Ascii digit `{ascii_digit}` must represent a digit.")

class ctrl_c(KeyboardInterrupt): # pylint: disable=invalid-name
"""
Wrapper for KeyboardInterrupt
"""
6 changes: 3 additions & 3 deletions src/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _simple_scroll_keybinds(
) -> int:
try:
key = win.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
return -1
if key in (Key.up_arrow, Key.k):
cursor = clamp(cursor - 1, 0, len_lines - 2)
Expand Down Expand Up @@ -180,7 +180,7 @@ def color_menu(parent_win: curses.window, original: Color) -> Color:
)
try:
key = win.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
return original
return_options: dict[int, Callable[[], Color]] = {
Key.q: lambda: original,
Expand Down Expand Up @@ -263,7 +263,7 @@ def sort_menu(parent_win: curses.window, todos: Todos, selected: Cursor) -> Todo
)
try:
key = win.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
return todos
return_options: dict[int, Callable[..., Todos]] = {
Key.q: lambda: todos,
Expand Down
2 changes: 1 addition & 1 deletion todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _get_main_input(
) -> int | Todos:
try:
key: int = stdscr.getch()
except Key.ctrl_c:
except KeyboardInterrupt:
return todos
if key == Key.q:
return todos
Expand Down
3 changes: 0 additions & 3 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
- refactor: simplify redundancy between _get_display_string and _print_todo (strikethrough)
- fix: reimplement acurses support for windows
- fix: if holding down a key in acurses, make sure it doesn't stay pressed longer than it should (i.e. holding j key) (only reproducible in some terminals)
- fix: enable keyboardinterrupts throughout the app
- in get_todo box
- in main window
- fix: acurses preserve terminal from prior to app instantiation
- fix: overflow in get_todo for lines with length > 2*width
- feat: migrate copied_todo to list of todos and add multiple line paste operation from in app copy

0 comments on commit 80a83cc

Please sign in to comment.