From c7ba0800dd8493d0f44264eb50dcddaf02eeb40b Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Fri, 21 May 1999 21:42:27 +0000 Subject: Oliver Steele writes: """Despite the best intentions of Anarchie and Internet Explorer, I often end up with Python source files (and other text files that I'd like to edit with PythonIDE) that use '\n' instead of '\r' as a line separator (and therefore sh --- Mac/Tools/IDE/PyEdit.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Mac/Tools/IDE/PyEdit.py b/Mac/Tools/IDE/PyEdit.py index dfc21c5..35a5c1e 100644 --- a/Mac/Tools/IDE/PyEdit.py +++ b/Mac/Tools/IDE/PyEdit.py @@ -46,6 +46,21 @@ class Editor(W.Window): raise IOError, "file '%s' does not exist" % path self.path = path + if '\n' in text: + import EasyDialogs + if string.find(text, '\r\n') >= 0: + sourceOS = 'DOS' + searchString = '\r\n' + else: + sourceOS = 'UNIX' + searchString = '\n' + change = EasyDialogs.AskYesNoCancel('³%s² contains %s-style line feeds. Change them to MacOS carriage returns?' % (self.title, sourceOS), 1) + # bug: Cancel is treated as No + if change > 0: + text = string.replace(text, searchString, '\r') + else: + change = 0 + self.settings = {} if self.path: self.readwindowsettings() @@ -64,9 +79,12 @@ class Editor(W.Window): self.tabsettings = defaulttabsettings else: self.tabsettings = defaulttabsettings - W.Window.__init__(self, bounds, self.title, minsize = (330, 120), tabbable = 0) + W.Window.__init__(self, bounds, self.title, minsize = (330, 120), tabbable = 0) self.setupwidgets(text) + if change > 0: + self.editgroup.editor.changed = 1 + if self.settings.has_key("selection"): selstart, selend = self.settings["selection"] self.setselection(selstart, selend) @@ -319,7 +337,7 @@ class Editor(W.Window): return 1 elif save < 0: return 1 - self.globals = None # XXX doesn't help... all globals leak :-( + self.globals = None # XXX doesn't help... all globals leak :-( W.Window.close(self) def domenu_close(self, *args): -- cgit v0.12