mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
lib/mp-readline: Add word-based move/delete EMACS key sequences.
This commit adds backward-word, backward-kill-word, forward-word, forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B, Alt+D and Alt+Backspace respectively. It is disabled by default and can be enabled via MICROPY_REPL_EMACS_WORDS_MOVE. Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W. The features are enabled on unix micropython-coverage and micropython-dev.
This commit is contained in:
committed by
Damien George
parent
dce590c29d
commit
853aaa06f2
31
tests/cmdline/repl_words_move.py
Normal file
31
tests/cmdline/repl_words_move.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# word movement
|
||||
# backward-word, start in word
|
||||
234b1
|
||||
# backward-word, don't start in word
|
||||
234 b1
|
||||
# backward-word on start of line. if cursor is moved, this will result in a SyntaxError
|
||||
1 2 + 3b+
|
||||
# forward-word, start in word
|
||||
1+2 12+f+3
|
||||
# forward-word, don't start in word
|
||||
1+ 12 3f+
|
||||
# forward-word on eol. if cursor is moved, this will result in a SyntaxError
|
||||
1 + 2 3f+
|
||||
|
||||
# kill word
|
||||
# backward-kill-word, start in word
|
||||
100 + 45623
|
||||
# backward-kill-word, don't start in word
|
||||
100 + 456231
|
||||
# forward-kill-word, start in word
|
||||
100 + 256d3
|
||||
# forward-kill-word, don't start in word
|
||||
1 + 256d2
|
||||
|
||||
# extra move/kill shortcuts
|
||||
# ctrl-left
|
||||
234[1;5D1
|
||||
# ctrl-right
|
||||
12[1;5C3
|
||||
# ctrl-w
|
||||
1231
|
||||
47
tests/cmdline/repl_words_move.py.exp
Normal file
47
tests/cmdline/repl_words_move.py.exp
Normal file
@@ -0,0 +1,47 @@
|
||||
MicroPython \.\+ version
|
||||
Use \.\+
|
||||
>>> # word movement
|
||||
>>> # backward-word, start in word
|
||||
>>> \.\+
|
||||
1234
|
||||
>>> # backward-word, don't start in word
|
||||
>>> \.\+
|
||||
1234
|
||||
>>> # backward-word on start of line. if cursor is moved, this will result in a SyntaxError
|
||||
>>> \.\+
|
||||
6
|
||||
>>> # forward-word, start in word
|
||||
>>> \.\+
|
||||
18
|
||||
>>> # forward-word, don't start in word
|
||||
>>> \.\+
|
||||
16
|
||||
>>> # forward-word on eol. if cursor is moved, this will result in a SyntaxError
|
||||
>>> \.\+
|
||||
6
|
||||
>>>
|
||||
>>> # kill word
|
||||
>>> # backward-kill-word, start in word
|
||||
>>> \.\+
|
||||
123
|
||||
>>> # backward-kill-word, don't start in word
|
||||
>>> \.\+
|
||||
101
|
||||
>>> # forward-kill-word, start in word
|
||||
>>> \.\+
|
||||
123
|
||||
>>> # forward-kill-word, don't start in word
|
||||
>>> \.\+
|
||||
3
|
||||
>>>
|
||||
>>> # extra move/kill shortcuts
|
||||
>>> # ctrl-left
|
||||
>>> \.\+
|
||||
1234
|
||||
>>> # ctrl-right
|
||||
>>> \.\+
|
||||
123
|
||||
>>> # ctrl-w
|
||||
>>> \.\+
|
||||
1
|
||||
>>>
|
||||
Reference in New Issue
Block a user