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)
| 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." |