|
|
d88811 |
commit 701138a380fac06023e5915448af92ba13614cb9
|
|
|
d88811 |
Author: aszlig <aszlig@redmoonstudios.org>
|
|
|
d88811 |
Date: Thu Feb 11 03:14:07 2016 +0100
|
|
|
d88811 |
|
|
|
d88811 |
vterm: Fix handling of NUL characters
|
|
|
d88811 |
|
|
|
d88811 |
According to the VT100 programmers manual, the NUL character has to be
|
|
|
d88811 |
ignored (at least on our side, because we are not a printer):
|
|
|
d88811 |
|
|
|
d88811 |
http://vt100.net/docs/tp83/appendixb.html
|
|
|
d88811 |
|
|
|
d88811 |
According to the bug reporter the VMS console driver inserts NUL
|
|
|
d88811 |
characters after line feeds and our implementation prints those as "?".
|
|
|
d88811 |
|
|
|
d88811 |
Tested against Python 2.7, 3.2, 3.3, 3.4 and 3.5.
|
|
|
d88811 |
|
|
|
d88811 |
Signed-off-by: aszlig <aszlig@redmoonstudios.org>
|
|
|
d88811 |
Reported-by: Robert Urban <urban@unix-beratung.de>
|
|
|
d88811 |
|
|
|
d88811 |
diff --git a/urwid/tests/test_vterm.py b/urwid/tests/test_vterm.py
|
|
|
d88811 |
index 59fe166..4dadfcc 100644
|
|
|
d88811 |
--- a/urwid/tests/test_vterm.py
|
|
|
d88811 |
+++ b/urwid/tests/test_vterm.py
|
|
|
d88811 |
@@ -143,6 +143,10 @@ class TermTest(unittest.TestCase):
|
|
|
d88811 |
self.write('1\n2\n3\n4\e[2;1f\e[2M')
|
|
|
d88811 |
self.expect('1\n4')
|
|
|
d88811 |
|
|
|
d88811 |
+ def test_nul(self):
|
|
|
d88811 |
+ self.write('a\0b')
|
|
|
d88811 |
+ self.expect('ab')
|
|
|
d88811 |
+
|
|
|
d88811 |
def test_movement(self):
|
|
|
d88811 |
self.write('\e[10;20H11\e[10;0f\e[20C\e[K')
|
|
|
d88811 |
self.expect('\n' * 9 + ' ' * 19 + '1')
|
|
|
d88811 |
diff --git a/urwid/vterm.py b/urwid/vterm.py
|
|
|
d88811 |
index cc4eb7f..0f091ea 100644
|
|
|
d88811 |
--- a/urwid/vterm.py
|
|
|
d88811 |
+++ b/urwid/vterm.py
|
|
|
d88811 |
@@ -671,7 +671,7 @@ class TermCanvas(Canvas):
|
|
|
d88811 |
self.widget.beep()
|
|
|
d88811 |
elif not dc and char in B("\x18\x1a"): # CAN/SUB
|
|
|
d88811 |
self.leave_escape()
|
|
|
d88811 |
- elif not dc and char == B("\x7f"): # DEL
|
|
|
d88811 |
+ elif not dc and char in B("\x00\x7f"): # NUL/DEL
|
|
|
d88811 |
pass # this is ignored
|
|
|
d88811 |
elif self.within_escape:
|
|
|
d88811 |
self.parse_escape(char)
|