Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
1129de5a
Commit
1129de5a
authored
10 years ago
by
Paul Sokolovsky
Committed by
Damien George
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
unix: Support readline history saving to file, improves interactive usage.
parent
143c3410
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
unix/input.c
+13
-0
13 additions, 0 deletions
unix/input.c
unix/input.h
+2
-1
2 additions, 1 deletion
unix/input.h
unix/main.c
+3
-0
3 additions, 0 deletions
unix/main.c
unix/mpconfigport.h
+1
-0
1 addition, 0 deletions
unix/mpconfigport.h
with
19 additions
and
1 deletion
unix/input.c
+
13
−
0
View file @
1129de5a
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
unix/input.h
+
2
−
1
View file @
1129de5a
char
*
prompt
(
char
*
p
);
void
prompt_read_history
(
void
);
void
prompt_write_history
(
void
);
This diff is collapsed.
Click to expand it.
unix/main.c
+
3
−
0
View file @
1129de5a
...
...
@@ -301,6 +301,8 @@ STATIC void set_sys_argv(char *argv[], int argc, int start_arg) {
#endif
int
main
(
int
argc
,
char
**
argv
)
{
prompt_read_history
();
mp_stack_set_limit
(
32768
);
pre_process_options
(
argc
,
argv
);
...
...
@@ -477,6 +479,7 @@ int main(int argc, char **argv) {
#endif
//printf("total bytes = %d\n", m_get_total_bytes_allocated());
prompt_write_history
();
return
ret
&
0xff
;
}
...
...
This diff is collapsed.
Click to expand it.
unix/mpconfigport.h
+
1
−
0
View file @
1129de5a
...
...
@@ -46,6 +46,7 @@
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_ENABLE_SOURCE_LINE (1)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment