round(0, "ermintrude") succeeded instead of producing a TypeError. Fix this.
[python.git] / Lib / idlelib / RstripExtension.py
blob19e35d4d4815233709f38b53eb056e5b8ee5b033
1 'Provides "Strip trailing whitespace" under the "Format" menu.'
3 __author__ = "Roger D. Serwy <roger.serwy at gmail.com>"
5 class RstripExtension:
7 menudefs = [
8 ('format', [None,
9 ('Strip trailing whitespace', '<<do-rstrip>>'),
10 ]),]
12 def __init__(self, editwin):
13 self.editwin = editwin
14 self.editwin.text.bind("<<do-rstrip>>", self.do_rstrip)
16 def do_rstrip(self, event=None):
18 text = self.editwin.text
19 undo = self.editwin.undo
21 undo.undo_block_start()
23 end_line = int(float(text.index('end'))) + 1
24 for cur in range(1, end_line):
25 txt = text.get('%i.0' % cur, '%i.0 lineend' % cur)
26 cut = len(txt.rstrip())
27 text.delete('%i.%i' % (cur, cut), '%i.0 lineend' % cur)
29 undo.undo_block_stop()