summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/paragraph.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/paragraph.py')
-rw-r--r--Lib/idlelib/paragraph.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/idlelib/paragraph.py b/Lib/idlelib/paragraph.py
index f11bdae..cf8dfdb 100644
--- a/Lib/idlelib/paragraph.py
+++ b/Lib/idlelib/paragraph.py
@@ -1,4 +1,4 @@
-"""Extension to format a paragraph or selection to a max width.
+"""Format a paragraph, comment block, or selection to a max width.
Does basic, standard text formatting, and also understands Python
comment blocks. Thus, for editing Python source code, this
@@ -21,15 +21,14 @@ from idlelib.config import idleConf
class FormatParagraph:
- menudefs = [
- ('format', [ # /s/edit/format dscherer@cmu.edu
- ('Format Paragraph', '<<format-paragraph>>'),
- ])
- ]
-
def __init__(self, editwin):
self.editwin = editwin
+ @classmethod
+ def reload(cls):
+ cls.max_width = idleConf.GetOption('extensions', 'FormatParagraph',
+ 'max-width', type='int', default=72)
+
def close(self):
self.editwin = None
@@ -45,11 +44,7 @@ class FormatParagraph:
The length limit parameter is for testing with a known value.
"""
- if limit is None:
- # The default length limit is that defined by pep8
- limit = idleConf.GetOption(
- 'extensions', 'FormatParagraph', 'max-width',
- type='int', default=72)
+ limit = self.max_width if limit is None else limit
text = self.editwin.text
first, last = self.editwin.get_selection_indices()
if first and last:
@@ -75,6 +70,9 @@ class FormatParagraph:
text.see("insert")
return "break"
+
+FormatParagraph.reload()
+
def find_paragraph(text, mark):
"""Returns the start/stop indices enclosing the paragraph that mark is in.