@@ -410,6 +410,8 @@ def __init__(
410
410
refresh_interval : float = 0 ,
411
411
input : Input | None = None ,
412
412
output : Output | None = None ,
413
+ interrupt_exception : type [BaseException ] = KeyboardInterrupt ,
414
+ eof_exception : type [BaseException ] = EOFError ,
413
415
) -> None :
414
416
history = history or InMemoryHistory ()
415
417
clipboard = clipboard or InMemoryClipboard ()
@@ -459,6 +461,8 @@ def __init__(
459
461
self .reserve_space_for_menu = reserve_space_for_menu
460
462
self .tempfile_suffix = tempfile_suffix
461
463
self .tempfile = tempfile
464
+ self .interrupt_exception = interrupt_exception
465
+ self .eof_exception = eof_exception
462
466
463
467
# Create buffers, layout and Application.
464
468
self .history = history
@@ -811,7 +815,7 @@ def _complete_like_readline(event: E) -> None:
811
815
@handle ("<sigint>" )
812
816
def _keyboard_interrupt (event : E ) -> None :
813
817
"Abort when Control-C has been pressed."
814
- event .app .exit (exception = KeyboardInterrupt , style = "class:aborting" )
818
+ event .app .exit (exception = self . interrupt_exception () , style = "class:aborting" )
815
819
816
820
@Condition
817
821
def ctrl_d_condition () -> bool :
@@ -826,7 +830,7 @@ def ctrl_d_condition() -> bool:
826
830
@handle ("c-d" , filter = ctrl_d_condition & default_focused )
827
831
def _eof (event : E ) -> None :
828
832
"Exit when Control-D has been pressed."
829
- event .app .exit (exception = EOFError , style = "class:exiting" )
833
+ event .app .exit (exception = self . eof_exception () , style = "class:exiting" )
830
834
831
835
suspend_supported = Condition (suspend_to_background_supported )
832
836
0 commit comments