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
3ca84026
Commit
3ca84026
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
unix: Enable REPL auto-indent.
parent
0af73014
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
tests/cmdline/repl_cont.py
+2
-2
2 additions, 2 deletions
tests/cmdline/repl_cont.py
tests/cmdline/repl_cont.py.exp
+2
-2
2 additions, 2 deletions
tests/cmdline/repl_cont.py.exp
unix/main.c
+58
-0
58 additions, 0 deletions
unix/main.c
unix/mpconfigport.h
+1
-0
1 addition, 0 deletions
unix/mpconfigport.h
with
63 additions
and
4 deletions
tests/cmdline/repl_cont.py
+
2
−
2
View file @
3ca84026
...
...
@@ -17,5 +17,5 @@ d = {1:'one',
print
(
d
[
2
])
def
f
(
x
):
print
(
x
)
f
(
3
)
This diff is collapsed.
Click to expand it.
tests/cmdline/repl_cont.py.exp
+
2
−
2
View file @
3ca84026
...
...
@@ -26,7 +26,7 @@ Micro Python \.\+ version
two
>>> def f(x):
... print(x)
...
...
[K
>>> f(3)
3
>>>
This diff is collapsed.
Click to expand it.
unix/main.c
+
58
−
0
View file @
3ca84026
...
...
@@ -134,6 +134,9 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
}
}
#if MICROPY_USE_READLINE == 1
#include
"lib/mp-readline/readline.h"
#else
STATIC
char
*
strjoin
(
const
char
*
s1
,
int
sep_char
,
const
char
*
s2
)
{
int
l1
=
strlen
(
s1
);
int
l2
=
strlen
(
s2
);
...
...
@@ -147,10 +150,63 @@ STATIC char *strjoin(const char *s1, int sep_char, const char *s2) {
s
[
l1
+
l2
]
=
0
;
return
s
;
}
#endif
STATIC
int
do_repl
(
void
)
{
mp_hal_stdout_tx_str
(
"Micro Python "
MICROPY_GIT_TAG
" on "
MICROPY_BUILD_DATE
"; "
MICROPY_PY_SYS_PLATFORM
" version
\n
"
);
#if MICROPY_USE_READLINE == 1
// use MicroPython supplied readline
vstr_t
line
;
vstr_init
(
&
line
,
16
);
for
(;;)
{
input_restart:
vstr_reset
(
&
line
);
mp_hal_stdio_mode_raw
();
int
ret
=
readline
(
&
line
,
">>> "
);
if
(
ret
==
CHAR_CTRL_D
)
{
// EOF
printf
(
"
\n
"
);
mp_hal_stdio_mode_orig
();
vstr_clear
(
&
line
);
return
0
;
}
else
if
(
line
.
len
==
0
)
{
if
(
ret
!=
0
)
{
printf
(
"
\n
"
);
}
mp_hal_stdio_mode_orig
();
continue
;
}
while
(
mp_repl_continue_with_input
(
vstr_null_terminated_str
(
&
line
)))
{
vstr_add_byte
(
&
line
,
'\n'
);
ret
=
readline
(
&
line
,
"... "
);
if
(
ret
==
CHAR_CTRL_C
)
{
// cancel everything
printf
(
"
\n
"
);
mp_hal_stdio_mode_orig
();
goto
input_restart
;
}
else
if
(
ret
==
CHAR_CTRL_D
)
{
// stop entering compound statement
break
;
}
}
mp_hal_stdio_mode_orig
();
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR__lt_stdin_gt_
,
line
.
buf
,
line
.
len
,
false
);
ret
=
execute_from_lexer
(
lex
,
MP_PARSE_SINGLE_INPUT
,
true
);
if
(
ret
&
FORCED_EXIT
)
{
return
ret
;
}
}
#else
// use GNU or simple readline
for
(;;)
{
char
*
line
=
prompt
(
">>> "
);
if
(
line
==
NULL
)
{
...
...
@@ -175,6 +231,8 @@ STATIC int do_repl(void) {
}
free
(
line
);
}
#endif
}
STATIC
int
do_file
(
const
char
*
file
)
{
...
...
This diff is collapsed.
Click to expand it.
unix/mpconfigport.h
+
1
−
0
View file @
3ca84026
...
...
@@ -53,6 +53,7 @@
#define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_REPL_EMACS_KEYS (1)
#define MICROPY_REPL_AUTO_INDENT (1)
#define MICROPY_HELPER_LEXER_UNIX (1)
#define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
...
...
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