diff --git a/linenoise.c b/linenoise.c index 574ab1f1..689a793e 100644 --- a/linenoise.c +++ b/linenoise.c @@ -159,6 +159,7 @@ enum KEY_ACTION{ }; static void linenoiseAtExit(void); +int linenoiseWasInterrupted = 0; int linenoiseHistoryAdd(const char *line); #define REFRESH_CLEAN (1<<0) // Clean the old prompt from the screen #define REFRESH_WRITE (1<<1) // Rewrite the prompt on the screen. @@ -964,6 +965,7 @@ char *linenoiseEditFeed(struct linenoiseState *l) { return strdup(l->buf); case CTRL_C: /* ctrl-c */ errno = EAGAIN; + linenoiseWasInterrupted = 1; return NULL; case BACKSPACE: /* backspace */ case 8: /* ctrl-h */ diff --git a/linenoise.h b/linenoise.h index 3f0270e3..1ec7e475 100644 --- a/linenoise.h +++ b/linenoise.h @@ -45,6 +45,7 @@ extern "C" { #include /* For size_t. */ +extern int linenoiseWasInterrupted; /* nonzero if last keystroke was ctrl-c */ extern char *linenoiseEditMore; /* The linenoiseState structure represents the state during line editing.