diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 88fa1af045454..b0f883c74255f 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -130,6 +130,7 @@ ifeq ($(MICROPY_USE_READLINE),1) INC += -I$(TOP)/shared/readline CFLAGS += -DMICROPY_USE_READLINE=1 SHARED_SRC_C_EXTRA += readline/readline.c +SHARED_SRC_C_EXTRA += runtime/pyexec.c endif ifeq ($(MICROPY_PY_TERMIOS),1) CFLAGS += -DMICROPY_PY_TERMIOS=1 diff --git a/ports/unix/main.c b/ports/unix/main.c index 9f51573fbfbe9..f199a54f920d2 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -177,6 +177,9 @@ static int execute_from_lexer(int source_kind, const void *source, mp_parse_inpu #if MICROPY_USE_READLINE == 1 #include "shared/readline/readline.h" +#ifdef __linux__ +#include "shared/runtime/pyexec.h" +#endif #else static char *strjoin(const char *s1, int sep_char, const char *s2) { int l1 = strlen(s1); @@ -216,6 +219,19 @@ static int do_repl(void) { // cancel input mp_hal_stdout_tx_str("\r\n"); goto input_restart; + #ifdef __linux__ + } else if (ret == CHAR_CTRL_A) { + // Enter raw REPL + pyexec_mode_kind = PYEXEC_MODE_RAW_REPL; + mp_hal_stdout_tx_str("\r\n"); + int status = pyexec_raw_repl(); + if (status != 0) { + mp_hal_stdio_mode_orig(); + vstr_clear(&line); + return status; + } + goto input_restart; + #endif } else if (ret == CHAR_CTRL_D) { // EOF printf("\n"); diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index c828c75817940..9653582f837c8 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -39,6 +39,7 @@ #include "irq.h" #include "usb.h" #endif +#include "extmod/modplatform.h" #include "shared/readline/readline.h" #include "shared/runtime/pyexec.h" #include "genhdr/mpversion.h"