mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
unix: Support readline history saving to file, improves interactive usage.
This commit is contained in:
committed by
Damien George
parent
143c34109c
commit
1129de5ac0
13
unix/input.c
13
unix/input.c
@@ -35,6 +35,7 @@
|
||||
#if MICROPY_USE_READLINE
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <readline/tilde.h>
|
||||
#endif
|
||||
|
||||
char *prompt(char *p) {
|
||||
@@ -62,6 +63,18 @@ char *prompt(char *p) {
|
||||
return line;
|
||||
}
|
||||
|
||||
void prompt_read_history(void) {
|
||||
#if MICROPY_USE_READLINE_HISTORY
|
||||
read_history(tilde_expand("~/.micropython.history"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void prompt_write_history(void) {
|
||||
#if MICROPY_USE_READLINE_HISTORY
|
||||
write_history(tilde_expand("~/.micropython.history"));
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mp_builtin_input(uint n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
mp_obj_print(args[0], PRINT_STR);
|
||||
|
||||
Reference in New Issue
Block a user