diff options
author | Damien George <damien.p.george@gmail.com> | 2015-12-22 22:06:09 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-12-22 22:06:09 +0000 |
commit | e9751d2ac057070c52a7a67bd6e8b97e944ee088 (patch) | |
tree | 532b044a9324d0bc155c8797984337f2093133bd /unix | |
parent | 401af50dc081faa421e7caef18fde2beb15632e4 (diff) | |
download | micropython-e9751d2ac057070c52a7a67bd6e8b97e944ee088.tar.gz micropython-e9751d2ac057070c52a7a67bd6e8b97e944ee088.zip |
unix: Properly cancel REPL input when Ctrl-C is pressed.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/main.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/unix/main.c b/unix/main.c index da618d566b..e7fce873b2 100644 --- a/unix/main.c +++ b/unix/main.c @@ -176,7 +176,11 @@ STATIC int do_repl(void) { int ret = readline(&line, ">>> "); mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT; - if (ret == CHAR_CTRL_D) { + if (ret == CHAR_CTRL_C) { + // cancel input + mp_hal_stdout_tx_str("\r\n"); + goto input_restart; + } else if (ret == CHAR_CTRL_D) { // EOF printf("\n"); mp_hal_stdio_mode_orig(); |