X Tutup
Skip to content

Commit a583105

Browse files
remove a function
1 parent 8e2c0fc commit a583105

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

bpython/curtsiesfrontend/coderunner.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ class SystemExitRequest(RequestFromCodeGreenlet):
4343
class CodeRunner(object):
4444
"""Runs user code in an interpreter.
4545
46-
Running code requests a refresh by calling refresh_and_get_value(), which
46+
Running code requests a refresh by calling
47+
request_from_main_greenlet(force_refresh=True), which
4748
suspends execution of the code and switches back to the main greenlet
4849
4950
After load_code() is called with the source code to be run,
5051
the run_code() method should be called to start running the code.
5152
The running code may request screen refreshes and user input
52-
by calling the refresh_and_get_value and wait_and_get_value calls
53-
respectively. When these are called, the running source code cedes
53+
by calling request_from_main_greenlet.
54+
When this are called, the running source code cedes
5455
control, and the current run_code() method call returns.
5556
5657
The return value of run_code() determines whether the method ought
@@ -154,19 +155,15 @@ def _blocking_run_code(self):
154155
return SystemExitRequest
155156
return Unfinished if unfinished else Done
156157

157-
def wait_and_get_value(self):
158+
def request_from_main_greenlet(self, force_refresh=False):
158159
"""Return the argument passed in to .run_code(for_code)
159160
160-
Nothing means calls to run_code must be...
161+
Nothing means calls to run_code must be... ???
161162
"""
162-
value = self.main_greenlet.switch(Wait)
163-
if value is SigintHappened:
164-
raise KeyboardInterrupt()
165-
return value
166-
167-
def refresh_and_get_value(self):
168-
"""Returns the argument passed in to .run_code(for_code) """
169-
value = self.main_greenlet.switch(Refresh)
163+
if force_refresh:
164+
value = self.main_greenlet.switch(Refresh)
165+
else:
166+
value = self.main_greenlet.switch(Wait)
170167
if value is SigintHappened:
171168
raise KeyboardInterrupt()
172169
return value
@@ -177,7 +174,7 @@ def __init__(self, coderunner, on_write):
177174
self.on_write = on_write
178175
def write(self, *args, **kwargs):
179176
self.on_write(*args, **kwargs)
180-
return self.coderunner.refresh_and_get_value()
177+
return self.coderunner.request_from_main_greenlet(force_refresh=True)
181178
def writelines(self, l):
182179
for s in l:
183180
self.write(s)

bpython/curtsiesfrontend/repl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FakeStdin(object):
4141
def __init__(self, coderunner, repl):
4242
self.coderunner = coderunner
4343
self.repl = repl
44-
self.has_focus = False
44+
self.has_focus = False # whether FakeStdin receives keypress events
4545
self.current_line = ''
4646
self.cursor_offset_in_line = 0
4747
self.old_num_lines = 0
@@ -85,7 +85,7 @@ def add_normal_character(self, e):
8585
def readline(self):
8686
self.has_focus = True
8787
self.repl.send_to_stdin(self.current_line)
88-
value = self.coderunner.wait_and_get_value()
88+
value = self.coderunner.request_from_main_greenlet()
8989
self.readline_results.append(value)
9090
return value
9191

0 commit comments

Comments
 (0)
X Tutup