aboutsummaryrefslogtreecommitdiff
path: root/py/repl.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-07-27 00:43:35 +1000
committerDamien George <damien@micropython.org>2022-03-10 10:58:33 +1100
commitac2293161e98e73d39434628f995e85bd97e52c2 (patch)
tree6cc14ad736b124e085371ec47e734b90f7e98ddd /py/repl.h
parentcac939ddc3625da7e6cf1cf0309daba25fc1cedb (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.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/py/repl.h b/py/repl.h
index a7a4136ca..9e8f7f1dd 100644
--- a/py/repl.h
+++ b/py/repl.h
@@ -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