@@ -78,6 +78,8 @@ static REBCHR *Std_Buf = 0; // for input and output
78
78
static BOOL Redir_Out = 0 ;
79
79
static BOOL Redir_Inp = 0 ;
80
80
81
+ static BOOL Handled_Break = 0 ;
82
+
81
83
// Since some Windows10 version it's possible to use the new terminal processing,
82
84
// of ANSI escape sequences. From my tests its not faster than my emulation, but
83
85
// may be used for functionalities which are not handled in the emulation.
@@ -140,6 +142,12 @@ const REBYTE* Parse_ANSI_sequence(const REBYTE *cp, const REBYTE *ep);
140
142
141
143
BOOL WINAPI Handle_Break (DWORD dwCtrlType )
142
144
{
145
+ //printf("\nHandle_Break %i\n", dwCtrlType);
146
+ if (Handled_Break ) {
147
+ // CTRL-C was catched durring ReadConsoleW and was already processed
148
+ Handled_Break = FALSE;
149
+ return TRUE;
150
+ }
143
151
// Handle the MS CMD console CTRL-C, BREAK, and other events:
144
152
if (dwCtrlType >= CTRL_CLOSE_EVENT ) OS_Exit (100 ); // close button, shutdown, etc.
145
153
RL_Escape (0 );
@@ -531,6 +539,8 @@ static void close_stdio(void)
531
539
if (ok ) {
532
540
if (total == 0 ) {
533
541
// CTRL-C pressed
542
+ Handled_Break = TRUE; // let the break handler (which is signaled later) to know,
543
+ // that we handled it already
534
544
SetConsoleTextAttribute (Std_Out , FOREGROUND_INTENSITY | FOREGROUND_MAGENTA );
535
545
WriteConsoleW (Std_Out , L"[ESC]\r\n" , 7 , NULL , 0 );
536
546
SetConsoleTextAttribute (Std_Out , 0 );
0 commit comments