unix: Support readline history saving to file, improves interactive usage.

This commit is contained in:
Paul Sokolovsky
2015-03-13 09:45:42 +02:00
committed by Damien George
parent 143c34109c
commit 1129de5ac0
4 changed files with 19 additions and 1 deletions

View File

@@ -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);