From da0a275cc33482bc183baddb27d501559e45cb52 Mon Sep 17 00:00:00 2001 From: Mecaneer23 <74385377+Mecaneer23@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:04:53 -0500 Subject: [PATCH] refactor: use Key.ctrl_c rather than KeyboardInterrupt when possible --- src/class_cursor.py | 2 +- src/get_todo.py | 2 +- src/menus.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/class_cursor.py b/src/class_cursor.py index 125b64a..ef6e4fb 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 KeyboardInterrupt: # exit on ^C + except Key.ctrl_c: return operation = self._set_to_clamp if not single: diff --git a/src/get_todo.py b/src/get_todo.py index fea490c..07c3923 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 KeyboardInterrupt: + except Key.ctrl_c: return None if input_char == Key.ctrl_delete: return _handle_ctrl_delete(chars, position) diff --git a/src/menus.py b/src/menus.py index 933721a..2c6f8ec 100644 --- a/src/menus.py +++ b/src/menus.py @@ -180,7 +180,7 @@ def color_menu(parent_win: curses.window, original: Color) -> Color: ) try: key = win.getch() - except KeyboardInterrupt: + except Key.ctrl_c: 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 KeyboardInterrupt: + except Key.ctrl_c: return todos return_options: dict[int, Callable[..., Todos]] = { Key.q: lambda: todos,