diff options
author | Just van Rossum <just@lettererror.com> | 1999-05-21 21:42:27 (GMT) |
---|---|---|
committer | Just van Rossum <just@lettererror.com> | 1999-05-21 21:42:27 (GMT) |
commit | c7ba0800dd8493d0f44264eb50dcddaf02eeb40b (patch) | |
tree | 1d273925b1818b93f000222b1c08063c4de9f5bc /Mac/Tools | |
parent | 8bfefce75e2f7a55e82a88f080d40da60defe95c (diff) | |
download | cpython-c7ba0800dd8493d0f44264eb50dcddaf02eeb40b.zip cpython-c7ba0800dd8493d0f44264eb50dcddaf02eeb40b.tar.gz cpython-c7ba0800dd8493d0f44264eb50dcddaf02eeb40b.tar.bz2 |
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
Diffstat (limited to 'Mac/Tools')
-rw-r--r-- | Mac/Tools/IDE/PyEdit.py | 22 |
1 files 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): |