示例#1
0
 def electricDelete(self, stc):
     """Delete all whitespace after the cursor unless in a string or comment
     """
     start, end = stc.GetSelection()
     if start != end:
         stc.ReplaceSelection("")
         return
     pos = stc.GetCurrentPos()
     s = stc.GetStyleAt(pos)
     if stc.isStyleComment(s) or stc.isStyleString(s):
         stc.CmdKeyExecute(wx.stc.STC_CMD_CLEAR)
     else:
         self.dprint("deleting from pos %d" % pos)
         end = pos
         while end < stc.GetLength():
             c = stc.GetCharAt(end)
             if c == ord(' ') or c == ord('\t') or c == 10 or c == 13:
                 end += 1
             else:
                 break
         if end > pos:
             stc.SetTargetStart(pos)
             stc.SetTargetEnd(end)
             stc.ReplaceTarget('')
         else:
             stc.CmdKeyExecute(wx.stc.STC_CMD_CLEAR)
示例#2
0
    def StyleText(self, evt):
        """Handle the EVT_STC_STYLENEEDED event."""
        stc = evt.GetEventObject()
        last_styled_pos = stc.GetEndStyled()
        line = stc.LineFromPosition(last_styled_pos)
        start_pos = stc.PositionFromLine(line)
        end_pos = evt.GetPosition()

        while start_pos < end_pos:
            stc.StartStyling(start_pos, 0x1f)
            curchar = chr(stc.GetCharAt(start_pos))
            if curchar in self.alpha:
                start = stc.WordStartPosition(start_pos, True)
                end = start + 1
                while chr(stc.GetCharAt(end)) != " " and end < stc.GetLength():
                    end += 1
                word = stc.GetTextRange(start, end)
                if word in self.keywords:
                    style = self.STC_EXPR_KEYWORD
                    stc.SetStyling(len(word), style)
                elif word in self.keywords2:
                    style = self.STC_EXPR_KEYWORD2
                    stc.SetStyling(len(word), style)
                else:
                    style = self.STC_EXPR_DEFAULT
                    stc.SetStyling(len(word), style)
                start_pos += len(word)
            elif curchar == ";":
                eol = stc.GetLineEndPosition(stc.LineFromPosition(start_pos))
                style = self.STC_EXPR_COMMENT
                stc.SetStyling(eol - start_pos, style)
                start_pos = eol
            else:
                style = self.STC_EXPR_DEFAULT
                stc.SetStyling(1, style)
                start_pos += 1
 def DeleteAll(self, stc):
     """Overrode to handle refresh issue"""
     super(ErrorMarker, self).DeleteAll(stc)
     stc.Colourise(0, stc.GetLength())
 def DeleteAll(self, stc):
     """Overrode to handle refresh issue"""
     super(BreakpointStep, self).DeleteAll(stc)
     stc.Colourise(0, stc.GetLength())