コード例 #1
0
    def _updateStringIndex(self, text):
        """Regenerate index of found strings.
        
        This algorythm is suitable for either multiline strings and multiline comments.
        There are no any difference for highlighter
        """
        block = self.currentBlock()
        if block.previous().isValid():
            prevState = block.previous().userState()
        else:
            prevState = 0

        start = 0
        state = prevState
        foundStrings = []
        for match in re.finditer('"', text):
            if state:  # string end
                foundStrings.append(
                    _FoundString(start,
                                 match.start() + 1 - start))
                state = 0
            else:  # string start
                state = 1
                start = match.start()
        if state:
            foundStrings.append(_FoundString(start, len(text) - start))

        block.setUserState(state)

        data = self.currentBlockUserData()
        if data is None:
            data = QTextBlockUserData()
        data.foundStrings = foundStrings
        self.setCurrentBlockUserData(data)
コード例 #2
0
ファイル: highlighter.py プロジェクト: hlamer/mit-scheme-gui
    def _updateStringIndex(self, text):
        """Regenerate index of found strings.
        
        This algorythm is suitable for either multiline strings and multiline comments.
        There are no any difference for highlighter
        """
        block = self.currentBlock()
        if block.previous().isValid():
            prevState = block.previous().userState()
        else:
            prevState = 0
        
        start = 0
        state = prevState
        foundStrings = []
        for match in re.finditer('"', text):
            if state:  # string end
                foundStrings.append(_FoundString(start, match.start() + 1 - start))
                state = 0
            else:  # string start
                state = 1
                start = match.start()
        if state:
            foundStrings.append(_FoundString(start, len(text) - start))
        
        block.setUserState(state)

        data = self.currentBlockUserData()
        if data is None:
            data = QTextBlockUserData()
        data.foundStrings = foundStrings
        self.setCurrentBlockUserData(data)
コード例 #3
0
ファイル: highlighter.py プロジェクト: hlamer/mit-scheme-gui
 def _updateBraceIndex(self, text):
     """Regenerate index of found braces for a block
     """
     foundBraces = []
     for match in self._bracePattern.finditer(text):
         if not self._insideString(match.start()):
             foundBraces.append(_FoundBrace(self.currentBlock(), match.start(), match.group(0)))
     
     data = self.currentBlockUserData()
     if data is None:
         data = QTextBlockUserData()
     data.foundBraces = foundBraces
     self.setCurrentBlockUserData(data)
コード例 #4
0
    def _updateBraceIndex(self, text):
        """Regenerate index of found braces for a block
        """
        foundBraces = []
        for match in self._bracePattern.finditer(text):
            if not self._insideString(match.start()):
                foundBraces.append(
                    _FoundBrace(self.currentBlock(), match.start(),
                                match.group(0)))

        data = self.currentBlockUserData()
        if data is None:
            data = QTextBlockUserData()
        data.foundBraces = foundBraces
        self.setCurrentBlockUserData(data)
コード例 #5
0
def data(block):
    """Get the block's QTextBlockUserData, creating it if necessary."""
    data = block.userData()
    if not data:
        data = QTextBlockUserData()
        block.setUserData(data)
    return data
コード例 #6
0
ファイル: textblock.py プロジェクト: jonathanverner/qidle
 def __init__(self):
     QTextBlockUserData.__init__(self)
     self.data = {}
コード例 #7
0
ファイル: log_report.py プロジェクト: EricRahm/mozregression
 def __init__(self, log_lvl):
     QTextBlockUserData.__init__(self)
     self.log_lvl = log_lvl
コード例 #8
0
 def __init__(self):
     QTextBlockUserData.__init__(self)
コード例 #9
0
ファイル: highlighter.py プロジェクト: berland/ert
 def __init__(self, configuration_line):
     QTextBlockUserData.__init__(self)
     self.configuration_line = configuration_line
コード例 #10
0
 def __init__(self, configuration_line):
     QTextBlockUserData.__init__(self)
     self.configuration_line = configuration_line
コード例 #11
0
 def __init__(self, log_lvl):
     QTextBlockUserData.__init__(self)
     self.log_lvl = log_lvl
コード例 #12
0
 def __init__(self, data):
     QTextBlockUserData.__init__(self)
     self.data = data