Index: Lib/idlelib/FileRevert.py =================================================================== --- Lib/idlelib/FileRevert.py (revision 0) +++ Lib/idlelib/FileRevert.py (revision 0) @@ -0,0 +1,36 @@ +""" +FileRevert is an extension that re-reads the currently open file and +displays the possibly updated content. +""" +import tkMessageBox + +class FileRevert: + + menudefs = [('file', [('Revert', '<>')])] + + def __init__(self, editwin): + self.text = editwin.text + self.io = editwin.io + + def revert_file_event(self, event): + fname = self.io.filename + if fname is None: + # No file associated. + return + + if not self.io.get_saved(): + msg = "Do you want to save a copy of %s before reverting?" % fname + res = tkMessageBox.askyesnocancel( + master=self.text, + title="Save a copy", + message=msg) + if res is None: + # Canceled. + return + elif res: + self.io.save_a_copy(event) + # XXX Maybe it would be better to not revert the file when + # user cancels the dialog that saves a copy of the current + # file. + + self.io.loadfile(fname) Property changes on: Lib/idlelib/FileRevert.py ___________________________________________________________________ Added: svn:eol-style + native Index: Lib/idlelib/config-extensions.def =================================================================== --- Lib/idlelib/config-extensions.def (revision 74276) +++ Lib/idlelib/config-extensions.def (working copy) @@ -29,6 +29,12 @@ # See config-keys.def for notes on specifying keys and extend.txt for # information on creating IDLE extensions. +[FileRevert] +enable=1 +enable_shell=0 +[FileRevert_cfgBindings] +revert-file= + [FormatParagraph] enable=1 [FormatParagraph_cfgBindings]