Exemple #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)
Exemple #2
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)
Exemple #3
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)
Exemple #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)
Exemple #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
Exemple #6
0
 def __init__(self):
     QTextBlockUserData.__init__(self)
     self.data = {}
Exemple #7
0
 def __init__(self, log_lvl):
     QTextBlockUserData.__init__(self)
     self.log_lvl = log_lvl
Exemple #8
0
 def __init__(self):
     QTextBlockUserData.__init__(self)
Exemple #9
0
 def __init__(self, configuration_line):
     QTextBlockUserData.__init__(self)
     self.configuration_line = configuration_line
Exemple #10
0
 def __init__(self, configuration_line):
     QTextBlockUserData.__init__(self)
     self.configuration_line = configuration_line
Exemple #11
0
 def __init__(self, log_lvl):
     QTextBlockUserData.__init__(self)
     self.log_lvl = log_lvl
Exemple #12
0
 def __init__(self, data):
     QTextBlockUserData.__init__(self)
     self.data = data