dabo Commit
Revision 6968
Date: 2011-11-09 14:27:11 -0800 (Wed, 09 Nov 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6968

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

Log:
No logic changes - just cleaned up some formatting.

Diff:
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py       2011-11-09 17:06:16 UTC (rev 6967)
+++ trunk/dabo/ui/uiwx/dEditor.py       2011-11-09 22:27:11 UTC (rev 6968)
@@ -638,9 +638,9 @@
        def selectLine(self):
                start =self.GetLineEndPosition(self.LineNumber-1)
                if self.Value[start] == "\r":
-                       start+=2
+                       start += 2
                else:
-                       start+=1
+                       start += 1
                end = self.GetLineEndPosition(self.LineNumber)
                self.SelectionPosition = (start, end)
 
@@ -648,22 +648,23 @@
        def selectWord(self):
                whiteSpace = " \t\r\n"
                syntaxDelimeters = """()[]{}"+-*/&%=\\;:"""
+               boundaries = whiteSpace + syntaxDelimeters
                curPos = self.GetCurrentPos()
                val = self.Value
                if val[curPos] in syntaxDelimeters:
-                       start=curPos
-                       end=start+1
+                       start = curPos
+                       end = start + 1
                else:
-                       start=curPos
-                       while start-1 > 0:
-                               if val[start-1] not in (whiteSpace + 
syntaxDelimeters):
+                       start = curPos
+                       while start - 1 > 0:
+                               if val[start - 1] not in boundaries:
                                        start -= 1
                                else:
                                        break
 
                        end = curPos
                        while end < len(val):
-                               if val[end] in (whiteSpace + syntaxDelimeters):
+                               if val[end] in boundaries:
                                        break
                                end += 1
                self.SelectionPosition = (start, end)
@@ -707,8 +708,10 @@
 
                ## Autocomplete settings:
                self.AutoCompSetIgnoreCase(True)
-               self.AutoCompSetAutoHide(True)   ## hide when the typed string 
no longer matches
-               self.AutoCompStops(" ")  ## characters that will stop the 
autocomplete
+               # hide when the typed string no longer matches
+               self.AutoCompSetAutoHide(True)
+               # characters that will stop the autocomplete
+               self.AutoCompStops(" ")
                self.AutoCompSetFillUps(".(")
                # This lets you go all the way back to the '.' without losing 
the AutoComplete
                self.AutoCompSetCancelAtStart(False)
@@ -956,25 +959,25 @@
        def onCommentLine(self, evt):
                sel = self.GetSelection()
                begLine = self.LineFromPosition(sel[0])
-               endLine = self.LineFromPosition(sel[1]-1)
+               endLine = self.LineFromPosition(sel[1] - 1)
 
                self.BeginUndoAction()
-               for line in range(begLine, endLine+1):
+               for line in range(begLine, endLine + 1):
                        pos = self.PositionFromLine(line)
                        self.InsertText(pos, self.CommentString)
                self.EndUndoAction()
 
                self.SetSelection(self.PositionFromLine(begLine),
-                       self.PositionFromLine(endLine+1))
+                       self.PositionFromLine(endLine + 1))
 
 
        def onUncommentLine(self, evt):
                sel = self.GetSelection()
                begLine = self.LineFromPosition(sel[0])
-               endLine = self.LineFromPosition(sel[1]-1)
+               endLine = self.LineFromPosition(sel[1] - 1)
 
                self.BeginUndoAction()
-               for line in range(begLine, endLine+1):
+               for line in range(begLine, endLine + 1):
                        pos = self.PositionFromLine(line)
                        self.SetTargetStart(pos)
                        self.SetTargetEnd(pos + len(self.CommentString))
@@ -983,7 +986,7 @@
                self.EndUndoAction()
 
                self.SetSelection(self.PositionFromLine(begLine),
-                       self.PositionFromLine(endLine+1))
+                       self.PositionFromLine(endLine + 1))
 
 
        def __onKeyDown(self, evt):
@@ -1331,8 +1334,8 @@
                lineNum = 0
                while lineNum < lineCount:
                        level = self.GetFoldLevel(lineNum)
-                       if level & stc.STC_FOLDLEVELHEADERFLAG and \
-                       (level & stc.STC_FOLDLEVELNUMBERMASK) == 
stc.STC_FOLDLEVELBASE:
+                       if level & stc.STC_FOLDLEVELHEADERFLAG and (
+                                       level & stc.STC_FOLDLEVELNUMBERMASK) == 
stc.STC_FOLDLEVELBASE:
                                if expanding:
                                        self.SetFoldExpanded(lineNum, True)
                                        lineNum = self.Expand(lineNum, True)
@@ -1345,9 +1348,9 @@
                                                self.HideLines(lineNum+1, 
lastChild)
                        lineNum = lineNum + 1
 
+
        def FoldAllCode(self, expand):
                lineCount = self.GetLineCount()
-
                lineNum = 0
                while lineNum < lineCount:
                        level = self.GetFoldLevel(lineNum)
@@ -1446,7 +1449,8 @@
                        if fname is None:
                                break
                        if os.path.exists(fname):
-                               r = dabo.ui.areYouSure(_("File '%s' already 
exists. Do you want to overwrite it?") % fname, defaultNo=True)
+                               r = dabo.ui.areYouSure(_("File '%s' already 
exists. Do you "
+                                               "want to overwrite it?") % 
fname, defaultNo=True)
                                if r is None:
                                        # user canceled.
                                        fname = None
@@ -1694,26 +1698,26 @@
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # Auto-completion code, used mostly unchanged from SPE
        # Copyright www.stani.be
-       def autoComplete(self, object=0, minWordLen=0):
-               word    = self.getWord()
-               if isinstance(object, dEvents.KeyEvent):
-                       object = 0
+       def autoComplete(self, obj=0, minWordLen=0):
+               word = self.getWord()
+               if isinstance(obj, dEvents.KeyEvent):
+                       obj = 0
                if not word:
-                       if object:
+                       if obj:
                                self.AddText('.')
                        return
-               if object:
+               if obj:
                        self.AddText('.')
-                       word+='.'
+                       word += '.'
                if word and len(word) < minWordLen:
                        return
-               words   = self.getWords(word=word)
+               words = self.getWords(word=word)
                if word[-1] == '.':
                        try:
                                obj = self.getWordObject(word[:-1])
                                if obj:
                                        for attr in dir(obj):
-                                               attr = '%s%s'%(word,attr)
+                                               attr = '%s%s'%(word, attr)
                                                if attr not in words:
                                                                
words.append(attr)
                        except IndexError:
@@ -1729,27 +1733,31 @@
                        self.AutoCompShow(len(word), " ".join(wds))
 
 
-       def getWord(self,whole=None):
-               for delta in (0,-1,1):
-                       word    = self._getWord(whole=whole,delta=delta)
-                       if word: return word
+       def getWord(self, whole=None):
+               for delta in (0, -1, 1):
+                       word = self._getWord(whole=whole, delta=delta)
+                       if word:
+                               return word
                return ''
 
-       def _getWord(self,whole=None,delta=0):
-               pos = self.GetCurrentPos()+delta
+
+       def _getWord(self, whole=None, delta=0):
+               pos = self.GetCurrentPos() + delta
                line = self.GetCurrentLine()
                linePos = self.PositionFromLine(line)
                txt = self.GetLine(line)
-               start = self.WordStartPosition(pos,1)
+               start = self.WordStartPosition(pos, 1)
                if whole:
-                       end = self.WordEndPosition(pos,1)
+                       end = self.WordEndPosition(pos, 1)
                else:
                        end = pos
-               return txt[start-linePos:end-linePos]
+               return txt[start - linePos:end - linePos]
 
-       def getWords(self,word=None,whole=None):
-               if not word: word = self.getWord(whole=whole)
+
+       def getWords(self, word=None, whole=None):
                if not word:
+                       word = self.getWord(whole=whole)
+               if not word:
                        return []
                else:
                        if self.AutoCompGetIgnoreCase:
@@ -1761,17 +1769,20 @@
                        ret = dict.fromkeys(retAll).keys()
                        return ret
 
+
        def _getTextSource(self):
                """Override to include other sources."""
                return self.GetText()
 
 
-       def getWordObject(self,word=None,whole=None):
-               if not word: word=self.getWord(whole=whole)
+       def getWordObject(self, word=None, whole=None):
+               if not word:
+                       word=self.getWord(whole=whole)
                return self.evaluate(word)
        # End of auto-completion code
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+
        def _getRuntimeObjectName(self):
                """
                Go backwards from the current position and get the runtime 
object name



_______________________________________________
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