Skip to content

Commit 18f3d51

Browse files
committed
Issue #123 fixed
1 parent ad4a73e commit 18f3d51

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

bpython/cli.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,14 @@ def __init__(self, config, statusbar=None):
237237

238238
def confirm(self, q):
239239
"""Ask for yes or no and return boolean"""
240-
return self.statusbar.prompt(q).lower().startswith('y')
241-
240+
try:
241+
reply = self.statusbar.prompt(q)
242+
except ValueError:
243+
return False
244+
245+
return reply.lower() in ('y', 'yes')
246+
247+
242248
def notify(self, s, n=10):
243249
return self.statusbar.message(s, n)
244250

@@ -1414,22 +1420,20 @@ def bs(s):
14141420
while True:
14151421
c = self.win.getch()
14161422

1423+
# '\b'
14171424
if c == 127:
14181425
o = bs(o)
1419-
continue
1420-
1421-
if c == 27:
1422-
raise ValueError
1423-
1424-
if not c or c < 0 or c > 127:
1425-
continue
1426-
c = chr(c)
1427-
1428-
if c == '\n':
1426+
# '\n'
1427+
elif c == 10:
14291428
break
1430-
1431-
self.win.addstr(c, get_colpair(self.config, 'prompt'))
1432-
o += c
1429+
# ESC
1430+
elif c == 27:
1431+
raise ValueError
1432+
# literal
1433+
elif 0 <= c < 127:
1434+
c = chr(c)
1435+
self.win.addstr(c, get_colpair(self.config, 'prompt'))
1436+
o += c
14331437

14341438
self.settext(self._s)
14351439
return o

0 commit comments

Comments
 (0)