Subject: | Allow handler for "screen too small" cntl-c to get run before the exit |
In an app I do, the curses interface is run in a fork.
I bind 'q' and '\cC' to a handler that touches a file then exit's.
After the fork exits if that file exists the parent program gives an error and exits otherwise it
continues on as normal.
The problem is if the screen is too small and they hit ctrl-c that handler is never run.
That means the app "continues on as normal" when it should bail.
Adding support for small screen pre exit handler is very trivial:
In Curses/UI.pm do_one_event() (and elsewhere ???)
This:
# If the screen is too small, then <CTRL+C> will exit.
# Else the next event loop will be started.
if ($Curses::UI::screen_too_small) {
exit(1) if $key eq "\cC";
return $this;
}
Would need to do this:
# If the screen is too small, then <CTRL+C> will exit.
# Else the next event loop will be started.
if ($Curses::UI::screen_too_small) {
if($key eq "\cC") {
$Curses::UI::pre_screen_too_small_cntl_c_exit_hanlder->()
if ref $Curses::UI::pre_screen_too_small_cntl_c_exit_hanlder eq 'CODE';
exit(1);
}
return $this;
}