From 414b8a3daf8e545bbd80e147256a3862f69bbdb4 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Wed, 18 Jun 2008 23:36:10 +0100 Subject: [PATCH] Unprintable character handling fix Things like C-p and C-n and all that were just being echoed as ^P, and only one character was being put into the buffer, whereas two were being echoed. Now only printable characters are accepted for regular input. --- bpython.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bpython.py b/bpython.py index eefda19..f60596d 100644 --- a/bpython.py +++ b/bpython.py @@ -41,6 +41,7 @@ import signal import struct import termios import fcntl +import string import ConfigParser from bpython.formatter import BPythonFormatter @@ -810,7 +811,7 @@ class Repl( object ): s = s.replace( '\x03', '' ) s = s.replace( '\x01', '' ) - + self.scr.addstr( s, a ) if redraw and not self.evaluating: @@ -953,7 +954,7 @@ class Repl( object ): elif self.c == '\t': return self.tab() - elif len( self.c ) == 1 and ord( self.c ) <= 127: + elif len( self.c ) == 1 and self.c in string.printable:#ord( self.c ) <= 127: self.addc( self.c ) self.print_line( self.s )