mirror of
https://github.com/wassname/pyreadline.git
synced 2026-06-27 16:10:38 +08:00
Merge pull request #6 from jstenar/unicode_write_scrolling
Fix unicode problem in write_scrolling
This commit is contained in:
@@ -293,7 +293,7 @@ class Console(object):
|
||||
|
||||
# This pattern should match all characters that change the cursor position differently
|
||||
# than a normal character.
|
||||
motion_char_re = re.compile('([\n\r\t\010\007])'.encode('ascii'))
|
||||
motion_char_re = re.compile('([\n\r\t\010\007])')
|
||||
|
||||
def write_scrolling(self, text, attr=None):
|
||||
'''write text at current cursor position while watching for scrolling.
|
||||
@@ -309,11 +309,12 @@ class Console(object):
|
||||
returns the number of lines that the buffer scrolled.
|
||||
|
||||
'''
|
||||
text = ensure_unicode(text)
|
||||
x, y = self.pos()
|
||||
w, h = self.size()
|
||||
scroll = 0 # the result
|
||||
# split the string into ordinary characters and funny characters
|
||||
chunks = self.motion_char_re.split(ensure_str(text))
|
||||
chunks = self.motion_char_re.split(text)
|
||||
for chunk in chunks:
|
||||
n = self.write_color(chunk, attr)
|
||||
if len(chunk) == 1: # the funny characters will be alone
|
||||
|
||||
Reference in New Issue
Block a user