Skip to content

Commit 281eb05

Browse files
FakeStdin works, includes curtsies version bump
1 parent 829b186 commit 281eb05

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(self, coderunner, repl):
5757

5858
def process_event(self, e):
5959
assert self.has_focus
60+
logger.debug('fake input processing event %r', e)
6061
if isinstance(e, events.PasteEvent):
6162
for ee in e.events:
6263
if ee not in rl_char_sequences:
@@ -71,13 +72,22 @@ def process_event(self, e):
7172
self.repl.run_code_and_maybe_finish()
7273
elif e in ["<ESC>"]:
7374
pass
75+
elif e in ['<Ctrl-d>']:
76+
if self.current_line == '':
77+
self.repl.send_to_stdin('\n')
78+
self.has_focus = False
79+
self.current_line = ''
80+
self.cursor_offset = 0
81+
self.repl.run_code_and_maybe_finish(for_code='')
82+
else:
83+
pass
7484
elif e in ["\n", "\r", "<Ctrl-j>", "<Ctrl-m>"]:
7585
line = self.current_line
7686
self.repl.send_to_stdin(line + '\n')
7787
self.has_focus = False
7888
self.current_line = ''
7989
self.cursor_offset = 0
80-
self.repl.run_code_and_maybe_finish(for_code=line)
90+
self.repl.run_code_and_maybe_finish(for_code=line+'\n')
8191
else: # add normal character
8292
self.add_input_character(e)
8393

@@ -406,7 +416,6 @@ def process_event(self, e):
406416
raise SystemExit()
407417
elif e in ("\n", "\r", "<PADENTER>", "<Ctrl-j>", "<Ctrl-m>"):
408418
self.on_enter()
409-
self.update_completion()
410419
elif e == '<TAB>': # tab
411420
self.on_tab()
412421
self.rl_history.reset()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def initialize_options(self):
151151

152152
if sys.version_info[:2] >= (2, 6):
153153
# curtsies only supports 2.6 and onwards
154-
extras_require['curtsies'] = ['curtsies >=0.1.5, <0.2.0', 'greenlet']
154+
extras_require['curtsies'] = ['curtsies >=0.1.6, <0.2.0', 'greenlet']
155155
packages.append("bpython.curtsiesfrontend")
156156
entry_points['console_scripts'].append(
157157
'bpython-curtsies = bpython.curtsies:main [curtsies]')

0 commit comments

Comments
 (0)