anufrievroman / calcure

Modern TUI calendar and task manager with minimal and customizable UI.
https://anufrievroman.gitbook.io/calcure
MIT License
1.51k stars 43 forks source link

Keyboard interrupt not handled when waiting for user input #67

Closed jose1711 closed 9 months ago

jose1711 commented 10 months ago

To reproduce:

Receive KeyboardInterrupt message:

..
  File "/usr/lib/python3.11/site-packages/calcure/__main__.py", line 1066, in cli
    curses.wrapper(main)
  File "/usr/lib/python3.11/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/calcure/__main__.py", line 1025, in main
    control_monthly_screen(stdscr, screen, user_events, importer)
  File "/usr/lib/python3.11/site-packages/calcure/controls.py", line 39, in inner
    confirmed = ask_confirmation(stdscr, MSG_EXIT, cf.ASK_CONFIRMATIONS)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/calcure/dialogues.py", line 99, in ask_confirmation
    key = stdscr.getkey()
          ^^^^^^^^^^^^^^^
_curses.error: no input
anufrievroman commented 9 months ago

Indeed, I was aware of this possibility for a while. I think I should write an error handling decorator in dialogues.py module.

jose1711 commented 9 months ago

Thanks, I believe user should be given an option to use Ctrl+c as a way of terminating the current action. Example:

anufrievroman commented 9 months ago

Fixed it with commit 013b5202cac90ed98d7edf383d4385eb0cbff398