MCPcopy Index your code
hub / github.com/python/cpython / set_region

Method set_region

Lib/idlelib/format.py:240–262  ·  view source on GitHub ↗

Replace the text between the given indices. Args: head: Starting index of text to replace. tail: Ending index of text to replace. chars: Expected to be string of current text between head and tail. lines: List of new lines to i

(self, head, tail, chars, lines)

Source from the content-addressed store, hash-verified

238 return head, tail, chars, lines
239
240 def set_region(self, head, tail, chars, lines):
241 """Replace the text between the given indices.
242
243 Args:
244 head: Starting index of text to replace.
245 tail: Ending index of text to replace.
246 chars: Expected to be string of current text
247 between head and tail.
248 lines: List of new lines to insert between head
249 and tail.
250 """
251 text = self.editwin.text
252 newchars = "\n".join(lines)
253 if newchars == chars:
254 text.bell()
255 return
256 text.tag_remove("sel", "1.0", "end")
257 text.mark_set("insert", head)
258 text.undo_block_start()
259 text.delete(head, tail)
260 text.insert(head, newchars)
261 text.undo_block_stop()
262 text.tag_add("sel", head, "insert")
263
264 def indent_region_event(self, event=None):
265 "Indent region by indentwidth spaces."

Callers 8

indent_region_eventMethod · 0.95
dedent_region_eventMethod · 0.95
comment_region_eventMethod · 0.95
tabify_region_eventMethod · 0.95
untabify_region_eventMethod · 0.95
applyFunction · 0.80

Calls 9

tag_addMethod · 0.80
joinMethod · 0.45
bellMethod · 0.45
tag_removeMethod · 0.45
mark_setMethod · 0.45
undo_block_startMethod · 0.45
deleteMethod · 0.45
insertMethod · 0.45
undo_block_stopMethod · 0.45

Tested by 1