From 80a83ccd7964f587b492b9567ebce22bc251fe15 Mon Sep 17 00:00:00 2001 From: Mecaneer23 <74385377+Mecaneer23@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:39:45 -0500 Subject: [PATCH] fix: enable keyboardinterrupts throughout the app --- src/class_cursor.py | 2 +- src/get_todo.py | 4 ++-- src/keys.py | 5 ----- src/menus.py | 6 +++--- todo.py | 2 +- todo.txt | 3 --- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/class_cursor.py b/src/class_cursor.py index ef6e4fb..79a6389 100644 --- a/src/class_cursor.py +++ b/src/class_cursor.py @@ -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: diff --git a/src/get_todo.py b/src/get_todo.py index 674f515..79c7e19 100644 --- a/src/get_todo.py +++ b/src/get_todo.py @@ -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) @@ -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: diff --git a/src/keys.py b/src/keys.py index f23342a..e1b4ab8 100644 --- a/src/keys.py +++ b/src/keys.py @@ -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 - """ diff --git a/src/menus.py b/src/menus.py index 94a3737..2e6613e 100644 --- a/src/menus.py +++ b/src/menus.py @@ -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) @@ -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, @@ -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, diff --git a/todo.py b/todo.py index 2969670..b07f6d7 100755 --- a/todo.py +++ b/todo.py @@ -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 diff --git a/todo.txt b/todo.txt index 2e941cd..d3eeed1 100644 --- a/todo.txt +++ b/todo.txt @@ -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 \ No newline at end of file