Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 379fd21

Browse files
committed
Re-enable and handle sigint while processing syntax, throw KeyboardException
1 parent ab07174 commit 379fd21

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

bim.c

+11
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,15 @@ void recalculate_syntax(line_t * line, int line_no) {
967967
s->state.i = 0;
968968

969969
while (1) {
970+
struct termios old, new;
971+
tcgetattr(global_config.tty_in, &old);
972+
new = old; new.c_lflag |= ISIG;
973+
tcsetattr(global_config.tty_in, TCSAFLUSH, &new);
970974
ptrdiff_t before = krk_currentThread.stackTop - krk_currentThread.stack;
971975
krk_push(OBJECT_VAL(env->syntax->krkFunc));
972976
krk_push(OBJECT_VAL(s));
973977
KrkValue result = krk_callStack(1);
978+
tcsetattr(global_config.tty_in, TCSAFLUSH, &old);
974979
krk_currentThread.stackTop = krk_currentThread.stack + before;
975980
if (IS_NONE(result) && (krk_currentThread.flags & KRK_THREAD_HAS_EXCEPTION)) {
976981
render_error("Exception occurred in plugin: %s", AS_INSTANCE(krk_currentThread.currentException)->_class->name->chars);
@@ -3437,6 +3442,11 @@ void SIGCONT_handler(int sig) {
34373442
signal(SIGTSTP, SIGTSTP_handler);
34383443
}
34393444

3445+
void SIGINT_handler(int sig) {
3446+
krk_currentThread.flags |= KRK_THREAD_SIGNALLED;
3447+
signal(SIGINT, SIGINT_handler);
3448+
}
3449+
34403450
void try_to_center() {
34413451
int half_a_screen = (global_config.term_height - 3) / 2;
34423452
if (half_a_screen < env->line_no) {
@@ -11127,6 +11137,7 @@ void init_terminal(void) {
1112711137
signal(SIGWINCH, SIGWINCH_handler);
1112811138
signal(SIGCONT, SIGCONT_handler);
1112911139
signal(SIGTSTP, SIGTSTP_handler);
11140+
signal(SIGINT, SIGINT_handler);
1113011141
}
1113111142

1113211143
struct action_def * find_action(void (*action)()) {

0 commit comments

Comments
 (0)