aboutsummaryrefslogtreecommitdiff
path: root/py/repl.c
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.c
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.c')
-rw-r--r--py/repl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/py/repl.c b/py/repl.c
index 822e385ab..4e47cf784 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -33,6 +33,16 @@
#if MICROPY_HELPER_REPL
+#if MICROPY_PY_SYS_PS1_PS2
+const char *mp_repl_get_psx(unsigned int entry) {
+ if (mp_obj_is_str(MP_STATE_VM(sys_mutable)[entry])) {
+ return mp_obj_str_get_str(MP_STATE_VM(sys_mutable)[entry]);
+ } else {
+ return "";
+ }
+}
+#endif
+
STATIC bool str_startswith_word(const char *str, const char *head) {
size_t i;
for (i = 0; str[i] && head[i]; i++) {