diff options
author | Damien George <damien@micropython.org> | 2021-07-27 00:43:35 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-03-10 10:58:33 +1100 |
commit | ac2293161e98e73d39434628f995e85bd97e52c2 (patch) | |
tree | 6cc14ad736b124e085371ec47e734b90f7e98ddd /py/repl.h | |
parent | cac939ddc3625da7e6cf1cf0309daba25fc1cedb (diff) |
py/modsys: Add optional mutable attributes sys.ps1/ps2 and use them.
This allows customising the REPL prompt strings.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/repl.h')
-rw-r--r-- | py/repl.h | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -31,8 +31,34 @@ #include "py/mpprint.h" #if MICROPY_HELPER_REPL + +#if MICROPY_PY_SYS_PS1_PS2 + +const char *mp_repl_get_psx(unsigned int entry); + +static inline const char *mp_repl_get_ps1(void) { + return mp_repl_get_psx(MP_SYS_MUTABLE_PS1); +} + +static inline const char *mp_repl_get_ps2(void) { + return mp_repl_get_psx(MP_SYS_MUTABLE_PS2); +} + +#else + +static inline const char *mp_repl_get_ps1(void) { + return ">>> "; +} + +static inline const char *mp_repl_get_ps2(void) { + return "... "; +} + +#endif + bool mp_repl_continue_with_input(const char *input); size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print, const char **compl_str); + #endif #endif // MICROPY_INCLUDED_PY_REPL_H |