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
b7a4f15b
Commit
b7a4f15b
authored
Apr 26, 2015
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
mp-readline: Save "prompt" string in readline state.
parent
ad9daadf
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/mp-readline/readline.c
+8
-4
8 additions, 4 deletions
lib/mp-readline/readline.c
lib/mp-readline/readline.h
+2
-2
2 additions, 2 deletions
lib/mp-readline/readline.h
stmhal/pyexec.c
+6
-10
6 additions, 10 deletions
stmhal/pyexec.c
with
16 additions
and
16 deletions
lib/mp-readline/readline.c
+
8
−
4
View file @
b7a4f15b
...
@@ -85,6 +85,7 @@ typedef struct _readline_t {
...
@@ -85,6 +85,7 @@ typedef struct _readline_t {
int
hist_cur
;
int
hist_cur
;
int
cursor_pos
;
int
cursor_pos
;
char
escape_seq_buf
[
1
];
char
escape_seq_buf
[
1
];
const
char
*
prompt
;
}
readline_t
;
}
readline_t
;
STATIC
readline_t
rl
;
STATIC
readline_t
rl
;
...
@@ -260,23 +261,26 @@ end_key:
...
@@ -260,23 +261,26 @@ end_key:
return
-
1
;
return
-
1
;
}
}
void
readline_note_newline
(
void
)
{
void
readline_note_newline
(
const
char
*
prompt
)
{
rl
.
orig_line_len
=
rl
.
line
->
len
;
rl
.
orig_line_len
=
rl
.
line
->
len
;
rl
.
cursor_pos
=
rl
.
orig_line_len
;
rl
.
cursor_pos
=
rl
.
orig_line_len
;
rl
.
prompt
=
prompt
;
mp_hal_stdout_tx_str
(
prompt
);
}
}
void
readline_init
(
vstr_t
*
line
)
{
void
readline_init
(
vstr_t
*
line
,
const
char
*
prompt
)
{
rl
.
line
=
line
;
rl
.
line
=
line
;
rl
.
orig_line_len
=
line
->
len
;
rl
.
orig_line_len
=
line
->
len
;
rl
.
escape_seq
=
ESEQ_NONE
;
rl
.
escape_seq
=
ESEQ_NONE
;
rl
.
escape_seq_buf
[
0
]
=
0
;
rl
.
escape_seq_buf
[
0
]
=
0
;
rl
.
hist_cur
=
-
1
;
rl
.
hist_cur
=
-
1
;
rl
.
cursor_pos
=
rl
.
orig_line_len
;
rl
.
cursor_pos
=
rl
.
orig_line_len
;
rl
.
prompt
=
prompt
;
mp_hal_stdout_tx_str
(
prompt
);
}
}
int
readline
(
vstr_t
*
line
,
const
char
*
prompt
)
{
int
readline
(
vstr_t
*
line
,
const
char
*
prompt
)
{
mp_hal_stdout_tx_str
(
prompt
);
readline_init
(
line
,
prompt
);
readline_init
(
line
);
for
(;;)
{
for
(;;)
{
int
c
=
mp_hal_stdin_rx_chr
();
int
c
=
mp_hal_stdin_rx_chr
();
int
r
=
readline_process_char
(
c
);
int
r
=
readline_process_char
(
c
);
...
...
This diff is collapsed.
Click to expand it.
lib/mp-readline/readline.h
+
2
−
2
View file @
b7a4f15b
...
@@ -33,6 +33,6 @@
...
@@ -33,6 +33,6 @@
void
readline_init0
(
void
);
void
readline_init0
(
void
);
int
readline
(
vstr_t
*
line
,
const
char
*
prompt
);
int
readline
(
vstr_t
*
line
,
const
char
*
prompt
);
void
readline_init
(
vstr_t
*
line
);
void
readline_init
(
vstr_t
*
line
,
const
char
*
prompt
);
void
readline_note_newline
(
void
);
void
readline_note_newline
(
const
char
*
prompt
);
int
readline_process_char
(
int
c
);
int
readline_process_char
(
int
c
);
This diff is collapsed.
Click to expand it.
stmhal/pyexec.c
+
6
−
10
View file @
b7a4f15b
...
@@ -181,14 +181,13 @@ friendly_repl_t repl;
...
@@ -181,14 +181,13 @@ friendly_repl_t repl;
void
pyexec_friendly_repl_init
(
void
)
{
void
pyexec_friendly_repl_init
(
void
)
{
vstr_init
(
&
repl
.
line
,
32
);
vstr_init
(
&
repl
.
line
,
32
);
repl
.
cont_line
=
false
;
repl
.
cont_line
=
false
;
readline_init
(
&
repl
.
line
);
readline_init
(
&
repl
.
line
,
">>> "
);
mp_hal_stdout_tx_str
(
">>> "
);
}
}
void
pyexec_friendly_repl_reset
()
{
void
pyexec_friendly_repl_reset
(
void
)
{
repl
.
cont_line
=
false
;
vstr_reset
(
&
repl
.
line
);
vstr_reset
(
&
repl
.
line
);
readline_init
(
&
repl
.
line
);
repl
.
cont_line
=
false
;
readline_init
(
&
repl
.
line
,
">>> "
);
}
}
int
pyexec_friendly_repl_process_char
(
int
c
)
{
int
pyexec_friendly_repl_process_char
(
int
c
)
{
...
@@ -229,8 +228,7 @@ int pyexec_friendly_repl_process_char(int c) {
...
@@ -229,8 +228,7 @@ int pyexec_friendly_repl_process_char(int c) {
vstr_add_byte
(
&
repl
.
line
,
'\n'
);
vstr_add_byte
(
&
repl
.
line
,
'\n'
);
repl
.
cont_line
=
true
;
repl
.
cont_line
=
true
;
mp_hal_stdout_tx_str
(
"... "
);
readline_note_newline
(
"... "
);
readline_note_newline
();
return
0
;
return
0
;
}
else
{
}
else
{
...
@@ -251,8 +249,7 @@ int pyexec_friendly_repl_process_char(int c) {
...
@@ -251,8 +249,7 @@ int pyexec_friendly_repl_process_char(int c) {
if
(
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
&
repl
.
line
)))
{
if
(
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
&
repl
.
line
)))
{
vstr_add_byte
(
&
repl
.
line
,
'\n'
);
vstr_add_byte
(
&
repl
.
line
,
'\n'
);
mp_hal_stdout_tx_str
(
"... "
);
readline_note_newline
(
"... "
);
readline_note_newline
();
return
0
;
return
0
;
}
}
...
@@ -270,7 +267,6 @@ exec: ;
...
@@ -270,7 +267,6 @@ exec: ;
friendly_repl_reset:
// TODO
friendly_repl_reset:
// TODO
input_restart:
input_restart:
pyexec_friendly_repl_reset
();
pyexec_friendly_repl_reset
();
mp_hal_stdout_tx_str
(
">>> "
);
return
0
;
return
0
;
}
}
}
}
...
...
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