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

Method tabify_region_event

Lib/idlelib/format.py:319–332  ·  view source on GitHub ↗

Convert leading spaces to tabs for each line in selected region.

(self, event=None)

Source from the content-addressed store, hash-verified

317 return "break"
318
319 def tabify_region_event(self, event=None):
320 "Convert leading spaces to tabs for each line in selected region."
321 head, tail, chars, lines = self.get_region()
322 tabwidth = self._asktabwidth()
323 if tabwidth is None:
324 return
325 for pos in range(len(lines)):
326 line = lines[pos]
327 if line:
328 raw, effective = get_line_indent(line, tabwidth)
329 ntabs, nspaces = divmod(effective, tabwidth)
330 lines[pos] = '\t' * ntabs + ' ' * nspaces + line[raw:]
331 self.set_region(head, tail, chars, lines)
332 return "break"
333
334 def untabify_region_event(self, event=None):
335 "Expand tabs to spaces for each line in region."

Callers 1

Calls 4

get_regionMethod · 0.95
_asktabwidthMethod · 0.95
set_regionMethod · 0.95
get_line_indentFunction · 0.70

Tested by 1