Skip to content

Commit 0fba7ef

Browse files
fix simple repl demo
--HG-- branch : scroll-frontend
1 parent 9d9e587 commit 0fba7ef

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

bpython/scrollfrontend/repl.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def read(self, n=None):
6060
return data
6161
def write(self, msg):
6262
if isinstance(msg, bytes):
63-
return self.data.write(msg.encode('uft8'))
63+
return self.data.write(msg.encode('utf8'))
6464
else:
6565
return self.data.write(msg)
6666

@@ -618,23 +618,23 @@ def my_print(msg):
618618
my_print(' use "$" to pastebin '.center(self.width+8, 'X'))
619619
my_print(' "~" is the cursor '.center(self.width+8, 'X'))
620620
my_print('X'*(self.width+8))
621-
my_print('X..'+('.'*(self.width+2))+'..X')
621+
my_print('Xxx'+('x'*(self.width+2))+'xxX')
622622
for line in arr:
623-
my_print('X...'+(line if line else ' '*len(line))+'...X')
623+
my_print('Xxxx'+(line if line else ' '*len(line))+'xxxX')
624624
logging.debug('line:')
625625
logging.debug(repr(line))
626-
my_print('X..'+('.'*(self.width+2))+'..X')
626+
my_print('Xxx'+('x'*(self.width+2))+'xxX')
627627
my_print('X'*(self.width+8))
628628
return max(len(arr) - self.height, 0)
629629

630630
def dumb_input(self):
631-
for c in raw_input('>'):
631+
for c in self.orig_stdin.readline()[:-1]:
632632
if c in '/':
633633
c = '\n'
634634
elif c in '\\':
635635
c = ''
636636
elif c in '|':
637-
def r(): raise Exception('real errors should look like this')
637+
def r(): raise Exception('errors in other threads should look like this')
638638
t = threading.Thread(target=r)
639639
t.daemon = True
640640
t.start()
@@ -703,8 +703,7 @@ def getstdout(self):
703703
for x in lines]) if lines else ''
704704
return s
705705

706-
707-
def test():
706+
def simple_repl():
708707
with Repl() as r:
709708
r.width = 50
710709
r.height = 10
@@ -714,4 +713,4 @@ def test():
714713
r.dumb_input()
715714

716715
if __name__ == '__main__':
717-
test()
716+
simple_repl()

0 commit comments

Comments
 (0)