summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2016-07-31 20:58:11 +0200
committerJonathan Slenders <jonathan@slenders.be>2016-07-31 20:58:11 +0200
commitca8458ea65c01d232db542589ae423a5fc2d05c7 (patch)
treeaa57af019c49b27b629dd4393ef069810c3d0fc9
parent5400d0f5fe55b1174d4f6f5f4c23aef69653de37 (diff)
Added Keys.Enter for future compatibility.
-rw-r--r--prompt_toolkit/keys.py12
-rw-r--r--prompt_toolkit/terminal/vt100_input.py3
2 files changed, 14 insertions, 1 deletions
diff --git a/prompt_toolkit/keys.py b/prompt_toolkit/keys.py
index 9ed5da48..3c6f4d78 100644
--- a/prompt_toolkit/keys.py
+++ b/prompt_toolkit/keys.py
@@ -70,9 +70,19 @@ class Keys(object):
PageDown = Key('<PageDown>')
BackTab = Key('<BackTab>') # shift + tab
Insert = Key('<Insert>')
+ Backspace = Key('<Backspace>')
+ # Aliases.
Tab = ControlI
- Backspace = Key('<Backspace>')
+ Enter = ControlJ
+ # XXX: Actually Enter equals ControlM, not ControlJ,
+ # However, in prompt_toolkit, we made the mistake of translating
+ # \r into \n during the input, so everyone is now handling the
+ # enter key by binding ControlJ.
+
+ # From now on, it's better to bind `Keys.Enter` everywhere,
+ # because that's future compatible, and will still work when we
+ # stop replacing \r by \n.
F1 = Key('<F1>')
F2 = Key('<F2>')
diff --git a/prompt_toolkit/terminal/vt100_input.py b/prompt_toolkit/terminal/vt100_input.py
index 08cda426..6b74e7ba 100644
--- a/prompt_toolkit/terminal/vt100_input.py
+++ b/prompt_toolkit/terminal/vt100_input.py
@@ -382,6 +382,9 @@ class InputStream(object):
# (We remove ICRNL/INLCR/IGNCR below.)
# However, this breaks IPython and maybe other applications,
# because they bind ControlJ (\n) for handling the Enter key.
+
+ # When this is removed, replace Enter=ControlJ by
+ # Enter=ControlM in keys.py.
if c == '\r':
c = '\n'
self._input_parser.send(c)