dabo Commit
Revision 4249
Date: 2008-07-08 12:42:16 -0700 (Tue, 08 Jul 2008)
Author: Nate
Trac: http://svn.dabodev.com/trac/dabo/changeset/4249

Changed:
U   trunk/dabo/ui/uiwx/dEditor.py

Log:
Added an EOLMode property.  The property the is stored as a string and allows 
you to set the EOLMode of the file to CRLF, LF, or CR standards.  If not 
explicitly set by the user, the standard will default to the OS standard.  Upon 
setting the EOLMode, all end of line markers are automatically converted to the 
new standard.

Diff:
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py       2008-07-08 17:02:22 UTC (rev 4248)
+++ trunk/dabo/ui/uiwx/dEditor.py       2008-07-08 19:42:16 UTC (rev 4249)
@@ -241,6 +241,7 @@
                self._hiliteCharsBeyondLimit = False
                self._hiliteLimitColumn = 79
                self._encoding = self.Application.Encoding
+               self._eolMode = ""
                self._useAntiAliasing = True
                self._codeFolding = True
                self._showLineNumbers = True
@@ -675,9 +676,9 @@
 
                ## Seems that eolmode is CRLF on Mac by default... explicitly 
set it!
                if wx.Platform == "__WXMSW__":
-                       self.SetEOLMode(stc.STC_EOL_CRLF)
+                       self.EOLMode = "CRLF"
                else:
-                       self.SetEOLMode(stc.STC_EOL_LF)
+                       self.EOLMode = "LF"
 
                if self.HiliteCharsBeyondLimit:
                        self.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
@@ -1929,6 +1930,29 @@
                        self._properties["Encoding"] = val
 
 
+       def _getEOLMode(self):
+               return self._eolMode
+
+       def _setEOLMode(self, val):
+               if _constructer():
+                       if val.lower() == "crlf":
+                               self.SetEOLMode(stc.STC_EOL_CRLF)
+                               self.ConvertEOLs(stc.STC_EOL_CRLF)
+                               self._eolMode = "CRLF"
+                       elif val.lower() == "lf":
+                               self.SetEOLMode(stc.STC_EOL_LF)
+                               self.ConvertEOLs(stc.STC_EOL_LF)
+                               self._eolMode = "LF"
+                       elif val.lower() == "cr":
+                               self.SetEOLMode(stc.STC_EOL_CR)
+                               self.ConvertEOLs(stc.STC_EOL_CR)
+                               self._eolMode = "CR"
+                       else:
+                               raise ValueError, "EOLMode value must be either 
'LFCR', 'LF', or 'CR'"
+               else:
+                       self._properties["EOLMode"] = val
+
+
        def _getFileName(self):
                return os.path.split(self._fileName)[1]
 
@@ -2299,6 +2323,9 @@
        Encoding = property(_getEncoding, _setEncoding, None,
                        _("Type of encoding to use. Defaults to the 
application's default encoding.  (str)"))
        
+       EOLMode = property(_getEOLMode, _setEOLMode, None,
+                       _("End of line characters. Allowed values are 'CRLF', 
'LF' and 'CR'. (default=os dependent) (str)"))
+       
        FileName = property(_getFileName, None, None,
                        _("Name of the file being edited (without path info)  
(str)"))
        




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to