1 'Provides "Strip trailing whitespace" under the "Format" menu.'
3 __author__
= "Roger D. Serwy <roger.serwy at gmail.com>"
9 ('Strip trailing whitespace', '<<do-rstrip>>'),
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()