当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QRegExp方法代码示例

本文整理汇总了Python中PySide.QtCore.QRegExp方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QRegExp方法的具体用法?Python QtCore.QRegExp怎么用?Python QtCore.QRegExp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtCore的用法示例。


在下文中一共展示了QtCore.QRegExp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: filterRegExpChanged

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QRegExp [as 别名]
def filterRegExpChanged(self, value):
        regExp = QtCore.QRegExp(value)
        self.xrefwindow.proxyModel.setFilterRegExp(regExp) 
开发者ID:DroidTest,项目名称:TimeMachine,代码行数:5,代码来源:xrefwindow.py

示例2: filterRegExpChanged

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QRegExp [as 别名]
def filterRegExpChanged(self, value):
        regExp = QtCore.QRegExp(value)
        self.stringswindow.proxyModel.setFilterRegExp(regExp) 
开发者ID:DroidTest,项目名称:TimeMachine,代码行数:5,代码来源:stringswindow.py

示例3: match_multiline

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QRegExp [as 别名]
def match_multiline(self, text, delimiter, in_state, style):
        """Do highlighting of multi-line strings. ``delimiter`` should be a
        ``QRegExp`` for triple-single-quotes or triple-double-quotes, and
        ``in_state`` should be a unique integer to represent the corresponding
        state changes when inside those strings. Returns True if we're still
        inside a multi-line string when this function is finished.
        """
        # If inside triple-single quotes, start at 0
        if self.previousBlockState() == in_state:
            start = 0
            add = 0
        # Otherwise, look for the delimiter on this line
        else:
            start = delimiter.indexIn(text)
            # Move past this match
            add = delimiter.matchedLength()

        # As long as there's a delimiter match on this line...
        while start >= 0:
            # Look for the ending delimiter
            end = delimiter.indexIn(text, start + add)
            # Ending delimiter on this line?
            if end >= add:
                length = end - start + add + delimiter.matchedLength()
                self.setCurrentBlockState(0)
            # No; multi-line string
            else:
                self.setCurrentBlockState(in_state)
                length = len(text) - start + add
            # Apply formatting
            self.setFormat(start, length, style)
            # Look for the next match
            start = delimiter.indexIn(text, start + length)

        # Return True if still inside a multi-line string, False otherwise
        if self.currentBlockState() == in_state:
            return True
        else:
            return False 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:41,代码来源:CodeEditor.py

示例4: highlightBlock

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QRegExp [as 别名]
def highlightBlock(self, text):
        '''Highlight block.'''

        for pattern, hl_format in self._highlighting_rules:
            expression = QtCore.QRegExp(pattern)
            index = expression.indexIn(text)
            while index >= 0:
                length = expression.matchedLength()
                self.setFormat(index, length, hl_format)
                index = expression.indexIn(text, index + length)

        self.setCurrentBlockState(0)

        start_index = 0
        if self.previousBlockState() != 1:
            start_index = self.comment_start_expression.indexIn(text)

        while start_index >= 0:
            end_index = self.comment_end_expression.indexIn(text, start_index)

            if end_index == -1:
                self.setCurrentBlockState(1)
                comment_length = text.length() - start_index
            else:
                comment_length = end_index - \
                                 start_index + \
                                 self.comment_end_expression.matchedLength()

            multi_line_comment_format = QtGui.QTextCharFormat()
            multiline_color = self.config_theme.get('tokens_highlight',
                                                    'quotation_color')
            multi_line_comment_format.setForeground(QtGui.QColor(multiline_color))
            self.setFormat(start_index, comment_length,
                           multi_line_comment_format)
            start_index = self.comment_start_expression.indexIn(text,
                                                                start_index +
                                                                comment_length)
        return 
开发者ID:ax330d,项目名称:hrdev,代码行数:40,代码来源:syntax.py

示例5: _toggle_casts

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QRegExp [as 别名]
def _toggle_casts(self):
            '''TODO: feature to toggle casting.'''

            if self._casts_marked:
                for selection in self._casts_selections:
                    selection.cursor.clearSelection()
                self._casts_marked = False
                self._casts_selections = None
                return
            search_flag = QTextDocument.FindFlags(0)
            search_flag |= QTextDocument.FindWholeWords
            search_flag |= QTextDocument.FindCaseSensitively
            marker_color = self.config_theme.get('editor', 'hidden_color')

            self._casts_selections = []
            selection = QTextEdit.ExtraSelection()

            cursor = self.document().find(QtCore.QRegExp(r'\(\w+\s\*\)'))
            cursor.select(QTextCursor.WordUnderCursor)

            cursor.movePosition(QTextCursor.Start)

            selection.format.setBackground(QColor(marker_color))
            selection.cursor = cursor
            self._casts_selections.append(selection)

            while cursor:
                cursor = self.document().find(QtCore.QRegExp(r'\(\w+\s\*\)'),
                                              cursor, search_flag)
                if not cursor:
                    break
                selection = QTextEdit.ExtraSelection()
                selection.format.setBackground(QColor(marker_color))
                selection.cursor = cursor
                self._casts_selections.append(selection)
            self.setExtraSelections(self._casts_selections)
            self._casts_marked = True
            return 
开发者ID:ax330d,项目名称:hrdev,代码行数:40,代码来源:gui.py

示例6: __init__

# 需要导入模块: from PySide import QtCore [as 别名]
# 或者: from PySide.QtCore import QRegExp [as 别名]
def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        # Multi-line strings (expression, flag, style)
        # FIXME: The triple-quotes in these two lines will mess up the
        # syntax highlighting from this point onward
        self.tri_single = (QRegExp("'''"), 1, STYLES['string2'])
        self.tri_double = (QRegExp('"""'), 2, STYLES['string2'])

        rules = []

        # Keyword, operator, and brace rules
        rules += [(r'\b%s\b' % w, 0, STYLES['keyword'])
            for w in PythonHighlighter.keywords]
        rules += [(r'%s' % o, 0, STYLES['operator'])
            for o in PythonHighlighter.operators]
        rules += [(r'%s' % b, 0, STYLES['brace'])
            for b in PythonHighlighter.braces]

        # All other rules
        rules += [
            # 'self'
            (r'\bself\b', 0, STYLES['self']),

            # Double-quoted string, possibly containing escape sequences
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),
            # Single-quoted string, possibly containing escape sequences
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']),

            # 'def' followed by an identifier
            (r'\bdef\b\s*(\w+)', 1, STYLES['defclass']),
            # 'class' followed by an identifier
            (r'\bclass\b\s*(\w+)', 1, STYLES['defclass']),

            # From '#' until a newline
            (r'#[^\n]*', 0, STYLES['comment']),

            # Numeric literals
            (r'\b[+-]?[0-9]+[lL]?\b', 0, STYLES['numbers']),
            (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, STYLES['numbers']),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, STYLES['numbers']),
        ]

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
            for (pat, index, fmt) in rules] 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:48,代码来源:CodeEditor.py


注:本文中的PySide.QtCore.QRegExp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。