Server IP : 85.193.89.191 / Your IP : 3.145.201.35 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/983/cwd/lib64/python2.7/idlelib/ |
Upload File : |
'Provides "Strip trailing whitespace" under the "Format" menu.' __author__ = "Roger D. Serwy <roger.serwy at gmail.com>" class RstripExtension: menudefs = [ ('format', [None, ('Strip trailing whitespace', '<<do-rstrip>>'), ]),] def __init__(self, editwin): self.editwin = editwin self.editwin.text.bind("<<do-rstrip>>", self.do_rstrip) def do_rstrip(self, event=None): text = self.editwin.text undo = self.editwin.undo undo.undo_block_start() end_line = int(float(text.index('end'))) + 1 for cur in range(1, end_line): txt = text.get('%i.0' % cur, '%i.0 lineend' % cur) cut = len(txt.rstrip()) text.delete('%i.%i' % (cur, cut), '%i.0 lineend' % cur) undo.undo_block_stop()