summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/unix/mphalport.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/ports/unix/mphalport.h b/ports/unix/mphalport.h
index e3e045aed..cb86e7048 100644
--- a/ports/unix/mphalport.h
+++ b/ports/unix/mphalport.h
@@ -35,7 +35,21 @@ void mp_hal_set_interrupt_char(char c);
void mp_hal_stdio_mode_raw(void);
void mp_hal_stdio_mode_orig(void);
-#if MICROPY_USE_READLINE == 1 && MICROPY_PY_BUILTINS_INPUT
+#if MICROPY_PY_BUILTINS_INPUT && MICROPY_USE_READLINE == 0
+
+#include <malloc.h>
+#include "py/misc.h"
+#include "input.h"
+#define mp_hal_readline mp_hal_readline
+static inline int mp_hal_readline(vstr_t *vstr, const char *p) {
+ char *line = prompt((char*)p);
+ vstr_add_str(vstr, line);
+ free(line);
+ return 0;
+}
+
+#elif MICROPY_PY_BUILTINS_INPUT && MICROPY_USE_READLINE == 1
+
#include "py/misc.h"
#include "lib/mp-readline/readline.h"
// For built-in input() we need to wrap the standard readline() to enable raw mode
@@ -46,6 +60,7 @@ static inline int mp_hal_readline(vstr_t *vstr, const char *p) {
mp_hal_stdio_mode_orig();
return ret;
}
+
#endif
// TODO: POSIX et al. define usleep() as guaranteedly capable only of 1s sleep: