'Provides "Strip trailing whitespace" under the "Format" menu.'
('format', [None, ('Strip trailing whitespace', '<<do-rstrip>>'), ] ), ]
def __init__(self, editwin):
self.editwin.text.bind("<<do-rstrip>>", self.do_rstrip)
def do_rstrip(self, event=None):
end_line = int(float(text.index('end')))
for cur in range(1, end_line):
txt = text.get('%i.0' % cur, '%i.end' % cur)
# Since text.delete() marks file as changed, even if not,
# only call it when needed to actually delete something.
text.delete('%i.%i' % (cur, cut), '%i.end' % cur)
if __name__ == "__main__":
unittest.main('idlelib.idle_test.test_rstrip', verbosity=2, exit=False)