diff options
Diffstat (limited to 'Lib/idlelib/FormatParagraph.py')
| -rw-r--r-- | Lib/idlelib/FormatParagraph.py | 16 | 
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py index ae4e6e7..7a9d185 100644 --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/FormatParagraph.py @@ -32,7 +32,7 @@ class FormatParagraph:      def close(self):          self.editwin = None -    def format_paragraph_event(self, event): +    def format_paragraph_event(self, event, limit=None):          """Formats paragraph to a max width specified in idleConf.          If text is selected, format_paragraph_event will start breaking lines @@ -41,9 +41,14 @@ class FormatParagraph:          If no text is selected, format_paragraph_event uses the current          cursor location to determine the paragraph (lines of text surrounded          by blank lines) and formats it. + +        The length limit parameter is for testing with a known value.          """ -        maxformatwidth = idleConf.GetOption( -                'main', 'FormatParagraph', 'paragraph', type='int') +        if limit is None: +            # The default length limit is that defined by pep8 +            limit = idleConf.GetOption( +                'extensions', 'FormatParagraph', 'max-width', +                type='int', default=72)          text = self.editwin.text          first, last = self.editwin.get_selection_indices()          if first and last: @@ -53,9 +58,9 @@ class FormatParagraph:              first, last, comment_header, data = \                      find_paragraph(text, text.index("insert"))          if comment_header: -            newdata = reformat_comment(data, maxformatwidth, comment_header) +            newdata = reformat_comment(data, limit, comment_header)          else: -            newdata = reformat_paragraph(data, maxformatwidth) +            newdata = reformat_paragraph(data, limit)          text.tag_remove("sel", "1.0", "end")          if newdata != data: @@ -185,7 +190,6 @@ def get_comment_header(line):      return m.group(1)  if __name__ == "__main__": -    from test import support; support.use_resources = ['gui']      import unittest      unittest.main('idlelib.idle_test.test_formatparagraph',              verbosity=2, exit=False)  | 
