From 1b52ba02d11a0e04f72884675b4d5a6532d120d3 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 31 Dec 2022 23:02:15 -0800 Subject: [PATCH] trying to make ctrl-c work on windows. --- windows/interp.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/windows/interp.h b/windows/interp.h index 2566098..9abc6f4 100644 --- a/windows/interp.h +++ b/windows/interp.h @@ -25,6 +25,15 @@ enum { #undef Z }; +static BOOL WINAPI forth_ctrl_handler(DWORD fdwCtrlType) { + if (fdwCtrlType == CTRL_C_EVENT || + fdwCtrlType == CTRL_BREAK_EVENT) { +// RaiseException(EXCEPTION_BREAKPOINT, 0, 0, 0); + return TRUE; + } + return FALSE; +} + static cell_t *forth_run(cell_t *init_rp) { static const BUILTIN_WORD builtins[] = { #define Z(flags, name, op, code) \ @@ -45,6 +54,7 @@ static cell_t *forth_run(cell_t *init_rp) { } register cell_t *ip, *rp, *sp, tos, w; register float *fp, ft; + SetConsoleCtrlHandler(forth_ctrl_handler, TRUE); rp = init_rp; UNPARK; for (;;) { __try {