X Tutup
Skip to content

Commit 11cfe84

Browse files
curtsies Repl cleanup
1 parent a583105 commit 11cfe84

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,13 @@ def readline(self):
123123
return value
124124

125125
class Repl(BpythonRepl):
126-
"""
126+
"""Python Repl
127127
128-
takes in:
128+
Reacts to events like
129129
-terminal dimensions and change events
130130
-keystrokes
131-
-number of scroll downs necessary to render array
131+
Behavior altered by
132+
-number of scroll downs that were necessary to render array after each display
132133
-initial cursor position
133134
outputs:
134135
-2D array to be rendered
@@ -142,18 +143,26 @@ class Repl(BpythonRepl):
142143

143144
## initialization, cleanup
144145
def __init__(self, locals_=None, config=None, stuff_a_refresh_request=lambda: None, banner=None, interp=None):
146+
"""
147+
locals_ is a mapping of locals to pass into the interpreter
148+
config is a bpython config.Struct with config attributes
149+
stuff_a_refresh_request is a function that will be called when the Repl
150+
wants to refresh the display, but wants control returned to it afterwards
151+
banner is a string to display briefly in the status bar
152+
interp is an interpreter to use
153+
"""
154+
145155
logging.debug("starting init")
146156

147157
if config is None:
148158
config = Struct()
149159
loadini(config, default_config_path())
150160

151-
self.weak_rewind = bool(locals_ or interp)
152-
161+
self.weak_rewind = bool(locals_ or interp) # If creating a new interpreter on undo
162+
# would be unsafe because initial
163+
# state was passed in
153164
if interp is None:
154165
interp = code.InteractiveInterpreter(locals=locals_)
155-
156-
157166
if banner is None:
158167
banner = _('welcome to bpython')
159168

@@ -163,10 +172,10 @@ def __init__(self, locals_=None, config=None, stuff_a_refresh_request=lambda: No
163172
config.cli_suggestion_width = 1
164173

165174
self.reevaluating = False
166-
self.fake_refresh_request = False
175+
self.fake_refresh_requested = False
167176
def request_refresh():
168177
if self.reevaluating or self.paste_mode:
169-
self.fake_refresh_request = True
178+
self.fake_refresh_requested = True
170179
else:
171180
stuff_a_refresh_request()
172181
self.stuff_a_refresh_request = request_refresh
@@ -844,8 +853,8 @@ def reevaluate(self, insert_into_history=False):
844853
for line in old_logical_lines:
845854
self._current_line = line
846855
self.on_enter(insert_into_history=insert_into_history)
847-
while self.fake_refresh_request:
848-
self.fake_refresh_request = False
856+
while self.fake_refresh_requested:
857+
self.fake_refresh_requested = False
849858
self.process_event(events.RefreshRequestEvent())
850859
sys.stdin = self.stdin
851860
self.reevaluating = False
@@ -899,8 +908,8 @@ def send_current_block_to_external_editor(self, filename=None):
899908
def process_simple_event(self, e):
900909
if e in ("\n", "\r", "PAD_ENTER"):
901910
self.on_enter()
902-
while self.fake_refresh_request:
903-
self.fake_refresh_request = False
911+
while self.fake_refresh_requested:
912+
self.fake_refresh_requested = False
904913
self.process_event(events.RefreshRequestEvent())
905914
elif isinstance(e, events.Event):
906915
pass # ignore events

0 commit comments

Comments
 (0)
X Tutup