MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / recall

Method recall

tools/python-3.11.9-amd64/Lib/idlelib/pyshell.py:1326–1352  ·  view source on GitHub ↗
(self, s, event)

Source from the content-addressed store, hash-verified

1324 return "break"
1325
1326 def recall(self, s, event):
1327 # remove leading and trailing empty or whitespace lines
1328 s = re.sub(r'^\s*\n', '', s)
1329 s = re.sub(r'\n\s*$', '', s)
1330 lines = s.split('\n')
1331 self.text.undo_block_start()
1332 try:
1333 self.text.tag_remove("sel", "1.0", "end")
1334 self.text.mark_set("insert", "end-1c")
1335 prefix = self.text.get("insert linestart", "insert")
1336 if prefix.rstrip().endswith(':'):
1337 self.newline_and_indent_event(event)
1338 prefix = self.text.get("insert linestart", "insert")
1339 self.text.insert("insert", lines[0].strip(),
1340 self.user_input_insert_tags)
1341 if len(lines) > 1:
1342 orig_base_indent = re.search(r'^([ \t]*)', lines[0]).group(0)
1343 new_base_indent = re.search(r'^([ \t]*)', prefix).group(0)
1344 for line in lines[1:]:
1345 if line.startswith(orig_base_indent):
1346 # replace orig base indentation with new indentation
1347 line = new_base_indent + line[len(orig_base_indent):]
1348 self.text.insert('insert', '\n' + line.rstrip(),
1349 self.user_input_insert_tags)
1350 finally:
1351 self.text.see("insert")
1352 self.text.undo_block_stop()
1353
1354 _last_newline_re = re.compile(r"[ \t]*(\n[ \t]*)?\Z")
1355 def runit(self):

Callers 1

enter_callbackMethod · 0.95

Calls 15

endswithMethod · 0.80
stripMethod · 0.80
startswithMethod · 0.80
subMethod · 0.45
splitMethod · 0.45
undo_block_startMethod · 0.45
tag_removeMethod · 0.45
mark_setMethod · 0.45
getMethod · 0.45
rstripMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected