diff options
author | Damien George <damien.p.george@gmail.com> | 2017-06-01 16:01:27 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-06-01 16:02:49 +1000 |
commit | d92898a35acdb6fc665be75f7c53d0fec107c4c4 (patch) | |
tree | a1b968de0f5e79826c930a72e54b80f6e8b874ce /unix/mphalport.h | |
parent | 6ff0ecfffcea4e7aa6301c54870ae97aa4a0cf72 (diff) | |
download | micropython-d92898a35acdb6fc665be75f7c53d0fec107c4c4.tar.gz micropython-d92898a35acdb6fc665be75f7c53d0fec107c4c4.zip |
unix: Convert to use core-provided version of built-in import().
Diffstat (limited to 'unix/mphalport.h')
-rw-r--r-- | unix/mphalport.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/unix/mphalport.h b/unix/mphalport.h index 00e79ec17c..cf227872f9 100644 --- a/unix/mphalport.h +++ b/unix/mphalport.h @@ -34,6 +34,19 @@ 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 +#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 +#define mp_hal_readline mp_hal_readline +static inline int mp_hal_readline(vstr_t *vstr, const char *p) { + mp_hal_stdio_mode_raw(); + int ret = readline(vstr, p); + mp_hal_stdio_mode_orig(); + return ret; +} +#endif + // TODO: POSIX et al. define usleep() as guaranteedly capable only of 1s sleep: // "The useconds argument shall be less than one million." static inline void mp_hal_delay_ms(mp_uint_t ms) { usleep((ms) * 1000); } |