Lines Matching refs:line

1 """Format all or a selected region (line slice) of text.
23 * If there is a selection marked, and the first line of the
90 line = text.get("%d.0" % lineno, "%d.end" % lineno)
92 # Look for start of next paragraph if the index passed in is a blank line
93 while text.compare("%d.0" % lineno, "<", "end") and is_all_white(line):
95 line = text.get("%d.0" % lineno, "%d.end" % lineno)
97 comment_header = get_comment_header(line)
100 # Once start line found, search for end of paragraph (a blank line)
101 while get_comment_header(line)==comment_header and \
102 not is_all_white(line[comment_header_len:]):
104 line = text.get("%d.0" % lineno, "%d.end" % lineno)
107 # Search back to beginning of paragraph (first blank line before)
109 line = text.get("%d.0" % lineno, "%d.end" % lineno)
111 get_comment_header(line)==comment_header and \
112 not is_all_white(line[comment_header_len:]):
114 line = text.get("%d.0" % lineno, "%d.end" % lineno)
142 continue # Can happen when line ends in whitespace
161 data = "\n".join(line[lc:] for line in data.split("\n"))
176 return '\n'.join(comment_header+line for line in newdata) + block_suffix
178 def is_all_white(line):
179 """Return True if line is empty or all whitespace."""
181 return re.match(r"^\s*$", line) is not None
183 def get_indent(line):
184 """Return the initial space or tab indent of line."""
185 return re.match(r"^([ \t]*)", line).group()
187 def get_comment_header(line):
188 """Return string with leading whitespace and '#' from line or ''.
190 A null return indicates that the line is not a comment line. A non-
194 m = re.match(r"^([ \t]*#*)", line)
202 def get_line_indent(line, tabwidth):
203 """Return a line's indentation as (# chars, effective # of spaces).
208 m = _line_indent_re.match(line)
219 """Return line information about the selected text region.
268 line = lines[pos]
269 if line:
270 raw, effective = get_line_indent(line, self.editwin.tabwidth)
272 lines[pos] = self.editwin._make_blanks(effective) + line[raw:]
280 line = lines[pos]
281 if line:
282 raw, effective = get_line_indent(line, self.editwin.tabwidth)
284 lines[pos] = self.editwin._make_blanks(effective) + line[raw:]
289 """Comment out each line in region.
291 ## is appended to the beginning of each line to comment it out.
295 line = lines[pos]
296 lines[pos] = '##' + line
301 """Uncomment each line in region.
303 Remove ## or # in the first positions of a line. If the comment
308 line = lines[pos]
309 if not line:
311 if line[:2] == '##':
312 line = line[2:]
313 elif line[:1] == '#':
314 line = line[1:]
315 lines[pos] = line
320 "Convert leading spaces to tabs for each line in selected region."
326 line = lines[pos]
327 if line:
328 raw, effective = get_line_indent(line, tabwidth)
330 lines[pos] = '\t' * ntabs + ' ' * nspaces + line[raw:]
335 "Expand tabs to spaces for each line in region."