diff options
author | Raymond Hettinger <python@rcn.com> | 2004-06-04 06:31:08 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-06-04 06:31:08 (GMT) |
commit | 4e49b836db96264b3b5236794a3200eea32b2519 (patch) | |
tree | a4c87341cc817962277444d7f8e3fccee9e4cff8 /Lib/idlelib/FormatParagraph.py | |
parent | 3c145449daa8356c6ae4c296ffb24b5214647442 (diff) | |
download | cpython-4e49b836db96264b3b5236794a3200eea32b2519.zip cpython-4e49b836db96264b3b5236794a3200eea32b2519.tar.gz cpython-4e49b836db96264b3b5236794a3200eea32b2519.tar.bz2 |
SF patch #961387: Make IDLE's paragraph reformatting width configurable
Diffstat (limited to 'Lib/idlelib/FormatParagraph.py')
-rw-r--r-- | Lib/idlelib/FormatParagraph.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py index eb0e693..80c654e 100644 --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -15,6 +15,7 @@ # * Fancy comments, like this bulleted list, arent handled :-) import re +from configHandler import idleConf class FormatParagraph: @@ -31,6 +32,7 @@ class FormatParagraph: self.editwin = None def format_paragraph_event(self, event): + maxformatwidth = int(idleConf.GetOption('main','FormatParagraph','paragraph')) text = self.editwin.text first, last = self.editwin.get_selection_indices() if first and last: @@ -44,8 +46,8 @@ class FormatParagraph: lines = data.split("\n") lines = map(lambda st, l=len(comment_header): st[l:], lines) data = "\n".join(lines) - # Reformat to 70 chars or a 20 char width, whichever is greater. - format_width = max(70-len(comment_header), 20) + # Reformat to maxformatwidth chars or a 20 char width, whichever is greater. + format_width = max(maxformatwidth, len(comment_header), 20) newdata = reformat_paragraph(data, format_width) # re-split and re-insert the comment header. newdata = newdata.split("\n") @@ -62,7 +64,7 @@ class FormatParagraph: newdata = '\n'.join(map(builder, newdata)) + block_suffix else: # Just a normal text format - newdata = reformat_paragraph(data) + newdata = reformat_paragraph(data, maxformatwidth) text.tag_remove("sel", "1.0", "end") if newdata != data: text.mark_set("insert", first) @@ -99,7 +101,7 @@ def find_paragraph(text, mark): first = "%d.0" % (lineno+1) return first, last, comment_header, text.get(first, last) -def reformat_paragraph(data, limit=70): +def reformat_paragraph(data, limit): lines = data.split("\n") i = 0 n = len(lines) |