mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
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>
This commit is contained in:
@@ -433,7 +433,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
|
||||
|
||||
vstr_add_byte(MP_STATE_VM(repl_line), '\n');
|
||||
repl.cont_line = true;
|
||||
readline_note_newline("... ");
|
||||
readline_note_newline(mp_repl_get_ps2());
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
@@ -454,7 +454,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
|
||||
|
||||
if (mp_repl_continue_with_input(vstr_null_terminated_str(MP_STATE_VM(repl_line)))) {
|
||||
vstr_add_byte(MP_STATE_VM(repl_line), '\n');
|
||||
readline_note_newline("... ");
|
||||
readline_note_newline(mp_repl_get_ps2());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
|
||||
vstr_reset(MP_STATE_VM(repl_line));
|
||||
repl.cont_line = false;
|
||||
repl.paste_mode = false;
|
||||
readline_init(MP_STATE_VM(repl_line), ">>> ");
|
||||
readline_init(MP_STATE_VM(repl_line), mp_repl_get_ps1());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -598,7 +598,7 @@ friendly_repl_reset:
|
||||
}
|
||||
|
||||
vstr_reset(&line);
|
||||
int ret = readline(&line, ">>> ");
|
||||
int ret = readline(&line, mp_repl_get_ps1());
|
||||
mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT;
|
||||
|
||||
if (ret == CHAR_CTRL_A) {
|
||||
@@ -651,7 +651,7 @@ friendly_repl_reset:
|
||||
// got a line with non-zero length, see if it needs continuing
|
||||
while (mp_repl_continue_with_input(vstr_null_terminated_str(&line))) {
|
||||
vstr_add_byte(&line, '\n');
|
||||
ret = readline(&line, "... ");
|
||||
ret = readline(&line, mp_repl_get_ps2());
|
||||
if (ret == CHAR_CTRL_C) {
|
||||
// cancel everything
|
||||
mp_hal_stdout_tx_str("\r\n");
|
||||
|
||||
Reference in New Issue
Block a user