def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        self.formats = []

        keywordFormat = QTextCharFormat()
        keywordFormat.setForeground(QColor(144, 83, 138))
        keywordPattern = "(?<!\\w)(node|way|rel|nwr|nw|nr|wr|w|n|r|derived|area|timeout|out|maxsize|bbox|date|diff|if" \
                         "|foreach|for|complete|retro|compare|delta|ids|skel|body|tags|meta|geom|bb|center|asc|qt" \
                         "|is_in|local|timeline|convert|make|id|around|poly|newer|changed|user|uid|pivot|type|t" \
                         "|is_tag|keys|version|timestamp|changeset|count_tags|count_members|count_distinct_members" \
                         "|count_by_role|count_distinct_by_role|per_member|per_vertex|pos|mtype|ref|role|is_closed" \
                         "|geom|length|lat|lon|lstr|min|max|sum|count|gcat|number|is_number|suffix|is_date|trace|hull" \
                         "|lrs_in|lrs_isect|lrs_union|lrs_min|lrs_max)(?!\\w)"

        self.formats.append((keywordPattern, keywordFormat, 0))

        numberFormat = QTextCharFormat()
        numberFormat.setForeground(QColor(104, 151, 187))
        numberPattern = "-?\\d+(\\.\\d+)?"

        self.formats.append((numberPattern, numberFormat, 0))

        setNameFormat = QTextCharFormat()
        setNameFormat.setForeground(QColor(197, 116, 50))
        setNamePattern = "\\.[a-zA-Z_]\\w*"

        self.formats.append((setNamePattern, setNameFormat, 0))

        stringFormat = QTextCharFormat()
        stringFormat.setForeground(QColor(105, 133, 88))
        stringPattern = r"([\"'])((?:[^\1\\]|\\.)*?)\1"

        self.formats.append((stringPattern, stringFormat, 0))
Пример #2
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)


        self.tri_single = (QRegularExpression("'''"), 1, STYLES['string2'])
        self.tri_double = (QRegularExpression('"""'), 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 += [
            (r'\bself\b', 0, STYLES['self']),
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']),
            (r'\bdef\b\s*(\w+)', 1, STYLES['defclass']),
            (r'\bclass\b\s*(\w+)', 1, STYLES['defclass']),
            (r'#[^\n]*', 0, STYLES['comment']),
            (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']),
        ]

        # Создайте QRegExp для каждого шаблона
        self.rules = [(QRegularExpression(pat), index, fmt)
            for (pat, index, fmt) in rules]
Пример #3
0
    def __init__(self, theDoc, mainGui, spEnchant):
        QSyntaxHighlighter.__init__(self, theDoc)

        logger.debug("Initialising GuiDocHighlighter ...")
        self.mainConf   = novelwriter.CONFIG
        self.theDoc     = theDoc
        self.spEnchant  = spEnchant
        self.mainGui    = mainGui
        self.mainTheme  = mainGui.mainTheme
        self.theProject = mainGui.theProject
        self.theHandle  = None
        self.spellCheck = False
        self.spellRx    = None
        self.hRules     = []
        self.hStyles    = {}

        self.colHead   = QColor(0, 0, 0)
        self.colHeadH  = QColor(0, 0, 0)
        self.colEmph   = QColor(0, 0, 0)
        self.colDialN  = QColor(0, 0, 0)
        self.colDialD  = QColor(0, 0, 0)
        self.colDialS  = QColor(0, 0, 0)
        self.colHidden = QColor(0, 0, 0)
        self.colKey    = QColor(0, 0, 0)
        self.colVal    = QColor(0, 0, 0)
        self.colSpell  = QColor(0, 0, 0)
        self.colError  = QColor(0, 0, 0)
        self.colRepTag = QColor(0, 0, 0)

        self.initHighlighter()

        logger.debug("GuiDocHighlighter initialisation complete")

        return
Пример #4
0
    def __init__(self, document, style):
        """
        Add syntax highlighter to editor text
        :param document: content of editor
        :param style: syntax highlighter styles
        """
        QSyntaxHighlighter.__init__(self, document)

        rules = []

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

        # Other rules
        rules += [
            # Numeric values
            (r'\b[+-]?[0-9]+[lL]?\b', 0, style['numbers']),
            (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, style['numbers']),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0,
             style['numbers']),
            # Double-Quote String
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, style['string']),
            # Single-Quote String
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, style['string']),
            # Single line Comment
            (r'\-\- [^\n]*', 0, style['comment']),
        ]

        self.rules = [(QRegExp(pattern, cs=Qt.CaseInsensitive), index, fmt)
                      for (pattern, index, fmt) in rules]
Пример #5
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        self.tri_single = (QRegExp("'''"), 1, STYLES['string2'])
        self.tri_double = (QRegExp('"""'), 2, STYLES['string2'])

        rules = []

        # All other rules
        rules += [
            (r'<[.,\w,:]*>', 0, STYLES["extension"]),
            (r'/[\w,/]*(.\w+)*', 0, STYLES['path']),
            (r'[\w]*://[\w,/]*.\w*', 0, STYLES["orkurl"]),
            (r'ERROR:[^\n]*', 0, STYLES["error"]),
            (r'FileError\([^\n]*', 0, STYLES["error"]),
            # Double-quoted string, possibly containing escape sequences
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),
            # Single-quoted string, possibly containing escape sequences
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']),

            # 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]
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        rules = []

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

        # All other rules
        rules += [
            # Comments
            (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']),

            # Labels
            (r'\:[a-zA-Z0-9_]+', 0, STYLES['label']),
            (r'^\s?BRK', 0, STYLES['breakpoint']),
        ]

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #7
0
    def __init__(self, editor):
        QSyntaxHighlighter.__init__(self, editor.document())

        self.editor = editor
        self._misspelledColor = Qt.red
        self._defaultBlockFormat = QTextBlockFormat()
        self._defaultCharFormat = QTextCharFormat()
Пример #8
0
    def __init__(self, document):
        # print(document.toPlainText())
        QSyntaxHighlighter.__init__(self, document)

        rules = [
            (r'(\(.*\))', 0, STYLES['group']),
        ]

        rules += [(r'%s' % o, 0, STYLES['operator'])
                  for o in RegexHighlighter.operators]
        rules += [(r'%s' % b, 0, STYLES['brace'])
                  for b in RegexHighlighter.braces]
        rules += [(r'%s' % l, 0, STYLES['literal'])
                  for l in RegexHighlighter.literals]

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

            # Numeric literals
            (r'\b[+-]?[0-9]+[lL]?\b', 0, STYLES['numbers']),
        ]

        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #9
0
    def __init__(self, parent):
        QSyntaxHighlighter.__init__(self, parent)
        self.parent = parent
        self.parent.setTabStopWidth(self.parent.fontMetrics().width(' ')*8)

        self.defaultTheme =  {"background-color":"#d7d7d7", "color":"#191970", "bold": {"color":"#859900", "font-weight":"bold", "font-style":"normal"}, "emphasis": {"color":"#b58900", "font-weight":"bold", "font-style":"italic"}, "link": {"color":"#cb4b16", "font-weight":"normal", "font-style":"normal"}, "image": {"color":"#cb4b16", "font-weight":"normal", "font-style":"normal"}, "header": {"color":"#2aa198", "font-weight":"bold", "font-style":"normal"}, "unorderedlist": {"color":"#dc322f", "font-weight":"normal", "font-style":"normal"}, "orderedlist": {"color":"#dc322f", "font-weight":"normal", "font-style":"normal"}, "blockquote": {"color":"#dc322f", "font-weight":"normal", "font-style":"normal"}, "codespan": {"color":"#dc322f", "font-weight":"normal", "font-style":"normal"}, "codeblock": {"color":"#ff9900", "font-weight":"normal", "font-style":"normal"}, "line": {"color":"#2aa198", "font-weight":"normal", "font-style":"normal"}, "html": {"color":"#c000c0", "font-weight":"normal", "font-style":"normal"}}
        self.setTheme(self.defaultTheme)
Пример #10
0
    def __init__(self, editor):
        QSyntaxHighlighter.__init__(self, editor.document())

        self.editor = editor
        self._misspelledColor = Qt.red
        self._defaultBlockFormat = QTextBlockFormat()
        self._defaultCharFormat = QTextCharFormat()
Пример #11
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)
        self.tri_single = (QRegExp("'''"), 1, STYLES['string2'])
        self.tri_double = (QRegExp('"""'), 2, STYLES['string2'])

        rules = []
        rules += [(r"\b(\w)+\(", 0, STYLES['funcs'])]

        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]

        rules += [
            (r"\bself\b", 0, STYLES['self']),
            (r'\b[+-]?[0-9]+[lL]?\b', 0, STYLES['numbers']),
            (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, STYLES['numbers']),
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']),
            (r'#[^\n]*', 0, STYLES['comment']),
            (r'\bdef\b\s*(\w+)', 1, STYLES['defclass']),
            (r'\bclass\b\s*(\w+)', 1, STYLES['defclass']),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0,
             STYLES['numbers']),
            (r"\@(\w+)", 0, STYLES['at']),
        ]

        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #12
0
    def __init__(self, theDoc, theParent):
        QSyntaxHighlighter.__init__(self, theDoc)

        logger.debug("Initialising GuiDocHighlighter ...")
        self.mainConf = nw.CONFIG
        self.theDoc = theDoc
        self.theParent = theParent
        self.theTheme = theParent.theTheme
        self.theIndex = theParent.theIndex
        self.theDict = None
        self.theHandle = None
        self.spellCheck = False
        self.spellRx = None
        self.hRules = []
        self.hStyles = {}

        self.colHead = QColor(0, 0, 0)
        self.colHeadH = QColor(0, 0, 0)
        self.colEmph = QColor(0, 0, 0)
        self.colDialN = QColor(0, 0, 0)
        self.colDialD = QColor(0, 0, 0)
        self.colDialS = QColor(0, 0, 0)
        self.colHidden = QColor(0, 0, 0)
        self.colKey = QColor(0, 0, 0)
        self.colVal = QColor(0, 0, 0)
        self.colSpell = QColor(0, 0, 0)
        self.colTagErr = QColor(0, 0, 0)
        self.colRepTag = QColor(0, 0, 0)

        self.initHighlighter()

        logger.debug("GuiDocHighlighter initialisation complete")

        return
Пример #13
0
 def __init__(self, document):
     QSyntaxHighlighter.__init__(self, document)
     self.rules = []
     self.enums = []
     self.params = []
     self.paramgroups = []
     self._setupRules()
Пример #14
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        rules = []

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

        # All other rules
        rules += [
            # '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]
Пример #15
0
    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 CSharpHighlighter.keywords]
        
        rules += [(r'\b%s\b' % w, 0, STYLES['dataTypes'])
                  for w in CSharpHighlighter.dataTypes]
        
        rules += [(r'\b%s\b' % w, 0, STYLES['builtInFunctions'])
                  for w in CSharpHighlighter.builtInFunctions]
        
        rules += [(r'%s' % o, 0, STYLES['operator'])
                  for o in CSharpHighlighter.operators]

        rules += [(r'%s' % b, 0, STYLES['brace'])
                  for b in CSharpHighlighter.braces]
        
        rules += [(r'%s' % b, 0, STYLES['logicalOperators'])
                  for b in CSharpHighlighter.logicalOperators]


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

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

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

            # From '//' until a newline
            (r'//[^\n]*', 0, STYLES['comment']),
            
            # 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]
Пример #16
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        rules = []

        # Keyword, operator, and brace rules
        rules += [(r'\b%s\b' % w, 0, self.STYLES['dot_keywords'],
                   "dot_keywords", []) for w in PythonHighlighter.dot_keywords]

        patterns_cond_bool_operators = [
            (r'\b%s\b' % c, 0, self.STYLES['cond_bool_operators'],
             "cond_bool_operators", [])
            for c in PythonHighlighter.cond_bool_operators
        ]
        rules_cond_bool_operators = [
            (QRegularExpression(pat), index, fmt, ruleid, subrules)
            for (pat, index, fmt, ruleid,
                 subrules) in patterns_cond_bool_operators
        ]

        patterns_cond_operators = [
            (r'\b%s\b' % c, 0, self.STYLES['cond_operators'], "cond_operators",
             []) for c in PythonHighlighter.cond_operators
        ]
        rules_cond_operators = [
            (QRegularExpression(pat), index, fmt, ruleid, subrules)
            for (pat, index, fmt, ruleid, subrules) in patterns_cond_operators
        ]

        patterns_cond_keywords = [
            (r'\b%s\b' % c, 0, self.STYLES['cond_keywords'], "cond_keywords",
             []) for c in PythonHighlighter.cond_keywords
        ]
        rules_cond_keywords = [
            (QRegularExpression(pat), index, fmt, ruleid, subrules)
            for (pat, index, fmt, ruleid, subrules) in patterns_cond_keywords
        ]

        # All other rules
        rules += [
            # Conditions
            (r'cond(ition)? *= *"[^"]*(\\.[^"\\]*)*"', 0,
             self.STYLES['default'], "cond1", rules_cond_operators +
             rules_cond_keywords + rules_cond_bool_operators),
            (r'cond(ition)? *=[^,\]]*[,\]]', 0, self.STYLES['default'],
             "cond2", rules_cond_operators + rules_cond_keywords +
             rules_cond_bool_operators),

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

            # From '//' until a newline: comments
            (r'^//[^\n]*', 0, self.STYLES['comment'], "comment", []),
        ]

        # Build a QRegularExpression for each pattern
        self.rules = [(QRegularExpression(pat), index, fmt, ruleid, subrules)
                      for (pat, index, fmt, ruleid, subrules) in rules]
Пример #17
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)
        tri = (quote)
        trid = (dquote)
        # 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(tri), 1, STYLES['string2'])
        self.tri_double = (QRegExp(trid), 2, STYLES['string2'])

        rules = []

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

        # All other rules
        rules += [
            # 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']),

            # 'self'
            (r'\bself\b', 0, STYLES['self']),

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

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

            # 'self.' followed by an word
            (r'\bself\b)', 1, STYLES['selfnext']
             ),  ### (r'\bself.\b\s*(\w+)', 1, STYLES['selfnext']),

            # 'Q' followed by an word
            (r'\b[Q.]\b\s*(\w+)', 1, STYLES['Qnext']),

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

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

            # 'Q'  word
            #(r'\\bQ[A-Za-z]+\\b', 1, STYLES['Qtclass']), #(QRegExp("\\bQ[A-Za-z]+\\b")
        ]

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #18
0
 def __init__(self, document):
     QSyntaxHighlighter.__init__(self, document)
     self._fridge = ly.lex.Fridge()
     app.settingsChanged.connect(self.rehighlight)
     self._initialState = None
     self._highlighting = True
     self._mode = None
     self.initializeDocument()
Пример #19
0
 def __init__(self, parent):
     QSyntaxHighlighter.__init__(self, parent)
     self.parent = parent
     self.format = QTextCharFormat()
     self.format.setForeground(QBrush(styles.INVALID_DNA_COLOR))
     if styles.UNDERLINE_INVALID_DNA:
         self.format.setFontUnderline(True)
         self.format.setUnderlineColor(styles.INVALID_DNA_COLOR)
Пример #20
0
 def __init__(self, parent):
     QSyntaxHighlighter.__init__(self, parent)
     self.parent = parent
     self.format = QTextCharFormat()
     self.format.setForeground(QBrush(styles.INVALID_DNA_COLOR))
     if styles.UNDERLINE_INVALID_DNA:
         self.format.setFontUnderline(True)
         self.format.setUnderlineColor(styles.INVALID_DNA_COLOR)
Пример #21
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        raw_data = open('colors.txt', 'rb').read()
        highlight_data = eval(raw_data)
        rules = PgSQLHighlighter.create_highlight_rules(highlight_data)

        self.rules = [(QRegExp(pattern), color) for (pattern, color) in rules]
Пример #22
0
 def __init__(self, document):
     QSyntaxHighlighter.__init__(self, document)
     self._fridge = ly.lex.Fridge()
     app.settingsChanged.connect(self.rehighlight)
     self._initialState = None
     self._highlighting = True
     self._mode = None
     self.initializeDocument()
Пример #23
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        # Creating Regular expression for CSharp code
        rules = CSharpRegex.regexRules

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #24
0
    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]

        #测试
        self.parent = document
        self.highlight_data = []  # 存储匹配结果的列表

        self.matched_format = QTextCharFormat()  # 定义高亮格式
        brush = QBrush(Qt.blue, Qt.SolidPattern)
        self.matched_format.setBackground(brush)
Пример #25
0
    def __init__(self, document: QTextDocument):
        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 = [(r'.', 0, STYLES['basic'])]

        # Keyword, operator, brace, builtin and special words 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]
        rules += [(r'\b%s\b' % f, 0, STYLES['builtin'])  # FIXME: "exit" is highlighted in sys.exit()
                  for f in dir(builtins)]
        rules.append((r'__\w+__', 0, STYLES['special_function']))  # special functions like __init__
        rules += [(r'\b%s\b' % v, 0, STYLES['special_variables'])  # special variables like __name__
                  for v in PythonHighlighter.special_variables]

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

            # 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']),

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

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

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

        ]

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]

        self.disabled = False
        self.do_not_highlight = False
Пример #26
0
    def __init__(self, parent):
        QSyntaxHighlighter.__init__(self, parent)
        self.parent = parent

        symbol_format = QTextCharFormat()
        symbol_format.setForeground(QColor(19, 150, 250))
        symbol_pattern = QRegExp(r"\[[0-9]+\]")
        symbol_pattern.setMinimal(True)

        self.formats = [symbol_format]
        self.patterns = [symbol_pattern]
Пример #27
0
    def __init__(self, document):

        QSyntaxHighlighter.__init__(self, document)

        self.triple_single = (QRegExp("\'\'\'"), 1, STYLE['doc_string'])
        self.triple_double = (QRegExp('\"\"\"'), 2, STYLE['doc_string'])

        # RULES

        rules = []
        # r'' regular expression
        # [] used to indicate set of characters
        # \b matches the empty string, but only at the beginning or end of the word
        # \w matches any alphanumeric chars and the underscore
        # \s matches any whitespace char
        # * causes the resulting regexp to match 0 or more repetitions of the preceding regexp. ab* = a, ab, abb, abbb..
        # + causes the resulting regexp to match 1 or more repetitions of the preceding regexp. ab+ = ab, abb, abbbb..
        # ? causes the resulting regexp to match 0 or 1 repetitions of the preceding regexp. ab? = a, ab
        # ^ matches the start of the string, and in multi line mode also matches immediately after each new line
        # ?: A non-capturing version of regular parentheses
        # QRegExp, int, STYLE

        rules += [(r'\b%s\b' % keyword, 0, STYLE['keywords'])
                  for keyword in PythonHighlighter.keywords]
        rules += [(r'\b%s\b' % boolean, 0, STYLE['booleans'])
                  for boolean in PythonHighlighter.booleans]
        rules += [(r'%s' % operator, 0, STYLE['operators'])
                  for operator in PythonHighlighter.operators]
        rules += [(r'%s' % brace, 0, STYLE['braces'])
                  for brace in PythonHighlighter.braces]
        # Other rules:
        rules += [
            # self
            (r'\bself\b', 0, STYLE['self']),
            # string containing double-quote with escape sequence
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLE['string']),
            # string containing single-quote with escape sequence
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLE['string']),
            # def/class
            (r'\bdef\b\s*(\w+)', 1, STYLE['def_class']),
            (r'\bclass\b\s*(\w+)', 1, STYLE['def_class']),
            # from # until new-line
            (r'#[^\n]*', 0, STYLE['comments']),
            # numbers
            (r'\b[+-]?[0-9]+[lL]?\b', 0, STYLE['numbers']),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0,
             STYLE['numbers']),
            # decorator
            (r'@[^\n', 0, STYLE['def_class']),
        ]
        # Build QRegExp for each pattern
        self.rules = [(QRegExp(pattern), index, fmt)
                      for (pattern, index, fmt) in rules]
Пример #28
0
    def __init__(self, editor):
        QSyntaxHighlighter.__init__(self, editor.document())

        self.editor = editor
        self._misspelledColor = Qt.red
        self._defaultBlockFormat = QTextBlockFormat()
        self._defaultCharFormat = QTextCharFormat()
        self.defaultTextColor = QColor(S.text)
        self.backgroundColor = QColor(S.base)
        self.markupColor = QColor(S.textLight)
        self.linkColor = QColor(S.link)
        self.spellingErrorColor = QColor(Qt.red)
Пример #29
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        quote_color = QTextCharFormat()
        color_ = QColor()
        color_.setRgb(255, 127, 80)
        quote_color.setForeground(color_)

        keyword_color = QTextCharFormat()
        color_ = QColor()
        color_.setRgb(135, 206, 235)
        keyword_color.setForeground(color_)

        hex_color = QTextCharFormat()
        color_ = QColor()
        color_.setRgb(0, 153, 0)
        hex_color.setForeground(color_)

        comment_color = QTextCharFormat()
        color_ = QColor()
        color_.setRgb(187, 93, 0)
        comment_color.setForeground(color_)

        keywords = [
            "\\ball\\b", "\\band\\b", "\\bany\\b", "\\bascii\\b", "\\bat\\b",
            "\\bcondition\\b", "\\bcontains\\b", "\\bentrypoint\\b",
            "\\bfalse\\b", "\\bfilesize\\b", "\\bfullword\\b", "\\bfor\\b",
            "\\bglobal\\b", "\\bin\\b", "\\bimport\\b", "\\binclude\\b",
            "\\bint8\\b", "\\bint16\\b", "\\bint32\\b", "\\bint8be\\b",
            "\\bint16be\\b", "\\bint32be\\b", "\\bmatches\\b", "\\bmeta\\b",
            "\\bnocase\\b", "\\bnot\\b", "\\bor\\b", "\\bof\\b",
            "\\bprivate\\b", "\\brule\\b", "\\bstrings\\b", "\\bthem\\b",
            "\\btrue\\b", "\\buint8\\b", "\\buint16\\b", "\\buint32\\b",
            "\\buint8be\\b", "\\buint16be\\b", "\\buint32be\\b", "\\bwide\\b"
        ]

        self.highlightingRules = [
            (QRegExp(keyword), keyword_color)  # keyword
            for keyword in keywords
        ]

        self.highlightingRules.append(
            (QRegExp("\{[\S\s]*\}"), hex_color))  # hex string
        self.highlightingRules.append(
            (QRegExp("\/.*\/"), quote_color))  # regex
        self.highlightingRules.append(
            (QRegExp("\/\*[\S\s]*\*\/"), comment_color))  # comment
        self.highlightingRules.append(
            (QRegExp("\/\/.*"), comment_color))  # comment
        self.highlightingRules.append(
            (QRegExp("\".*\""), quote_color))  # double quote
        self.highlightingRules.append(
            (QRegExp("\'.*\'"), quote_color))  # single quote
Пример #30
0
    def __init__(self, document, styles='light'):
        QSyntaxHighlighter.__init__(self, document)

        self.styles = styles
        if self.styles == 'light':
            STYLES = STYLES_LIGHT
        elif self.styles == 'dark':
            STYLES = STYLES_DARK

        # Multi-line strings (expression, flag, style)
        # FIXME: The triple-quotes in these two lines will mess up the
        # syntax highlighting from this point onward (this is an issue if we were doing python syntax. Simply an
        # artifact that was left from the code that this was based off of)
        self.tri_single = (QRegExp("'''"), 1, STYLES['string2'])
        self.tri_double = (QRegExp('"""'), 2, STYLES['string2'])

        # NOTE: For multiline comments
        self.comments_start = (QRegExp("<!--"), 1, STYLES['comment'])
        self.comments_end = QRegExp("-->")

        rules = []

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

        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]

        # All other rules
        rules += [

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

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

            # 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]
Пример #31
0
 def __init__(self, document, line=None):
     QSyntaxHighlighter.__init__(self, document)
     self.line = line
     rules = []
     rules += [(r'%s' % c, 0, STYLES['comment'])
         for c in self.comment]
     rules += [(r'%s' % g, 0, STYLES['group'])
         for g in self.group]
     rules += [(r'%s' % o, 0, STYLES['operator'])
        for o in self.operators]
      # Build a QRegExp for each pattern
     self.rules = [(QRegExp(pat), index, fmt)
         for (pat, index, fmt) in rules]
Пример #32
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        rules = []
        rules += [(r'(?:^|\s+)(%s)(?:\s+|$)' % cw, self.control) for cw in self.control_words]

        # TODO: make the command regex work both inline and after line break
        rules += [
            (r'\s+(.*#.*)\s+do', self.trigger),
            # (r'(?:do^\s+|do\s+)(.*)(?:\s+endon|\nendon)', self.command),
            (r'do\r\n\s+(.*)', self.command),
        ]
        self.rules = [(re.compile(pat, re.IGNORECASE), fmt) for (pat, fmt) in rules]
Пример #33
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        rules = []

        # Keyword, operator, and brace rules
        rules += [(r"\b%s\b" % w, 0, STYLES["instr_general"])
                  for w in AsmHighlighter.instr_general]

        rules += [(r"\b%s\b" % w, 0, STYLES["instr_cmp"])
                  for w in AsmHighlighter.instr_cmp]

        rules += [(r"\b%s\b" % w, 0, STYLES["instr_branch"])
                  for w in AsmHighlighter.instr_branch]

        rules += [(r"\b%s\b" % w, 0, STYLES["instr_arith"])
                  for w in AsmHighlighter.instr_arith]

        rules += [(r"\b%s\b" % w, 0, STYLES["instr_vm"])
                  for w in AsmHighlighter.instr_vm]

        rules += [(r"\b%s\b" % w, 0, STYLES["instr_stack"])
                  for w in AsmHighlighter.instr_stack]

        rules += [(r"\b%s\b" % w, 0, STYLES["instr_bitwise"])
                  for w in AsmHighlighter.instr_bitwise]

        rules += [(r"%s" % o, 0, STYLES["operator"])
                  for o in AsmHighlighter.operators]

        rules += [(r"%s" % b, 0, STYLES["brace"])
                  for b in AsmHighlighter.braces]

        # All other rules
        rules += [
            # 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"]),
            # From 'vm_' until a space or a comma
            (r"vm_[^ ,]*", 0, STYLES["keywords_vm"]),
            # From '#' until a newline
            (r"#[^\n]*", 0, STYLES["comment"]),
            # From ';' until a newline
            (r";[^\n]*", 0, STYLES["comment"]),
        ]

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #34
0
    def __init__(self, parent):
        """Summary

        Args:
            parent (TYPE): Description
        """
        QSyntaxHighlighter.__init__(self, parent)
        self.parent = parent
        self.format = QTextCharFormat()
        self.format.setForeground(getBrushObj(Qt.white))
        self.format.setBackground(getBrushObj(styles.INVALID_DNA_COLOR))
        if styles.UNDERLINE_INVALID_DNA:
            self.format.setFontUnderline(True)
            self.format.setUnderlineColor(getColorObj(styles.INVALID_DNA_COLOR))
Пример #35
0
    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']),

            # From perso
            (r'\*\*\w+\*\*', 0, STYLES['replace']),

            # 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]
Пример #36
0
    def __init__(self, document):

        QSyntaxHighlighter.__init__(self, document)

        self.triple_single = (QRegExp("\'\'\'"), 1, STYLE['doc_string'])
        self.triple_double = (QRegExp('\"\"\"'), 2, STYLE['doc_string'])

        # RULES

        rules = []
        # r'' regular expression
        # [] used to indicate set of characters
        # \b matches the empty string, but only at the beginning or end of the word
        # \w matches any alphanumeric chars and the underscore
        # \s matches any whitespace char
        # * causes the resulting regexp to match 0 or more repetitions of the preceding regexp. ab* = a, ab, abb, abbb..
        # + causes the resulting regexp to match 1 or more repetitions of the preceding regexp. ab+ = ab, abb, abbbb..
        # ? causes the resulting regexp to match 0 or 1 repetitions of the preceding regexp. ab? = a, ab
        # ^ matches the start of the string, and in multi line mode also matches immediately after each new line
        # ?: A non-capturing version of regular parentheses
        # QRegExp, int, STYLE

        rules += [(r'\b%s\b' % keyword, 0, STYLE['keywords']) for keyword in PythonHighlighter.keywords]
        rules += [(r'\b%s\b' % boolean, 0, STYLE['booleans']) for boolean in PythonHighlighter.booleans]
        rules += [(r'%s' % operator, 0, STYLE['operators']) for operator in PythonHighlighter.operators]
        rules += [(r'%s' % brace, 0, STYLE['braces']) for brace in PythonHighlighter.braces]
        # Other rules:
        rules += [
            # self
            (r'\bself\b', 0, STYLE['self']),
            # string containing double-quote with escape sequence
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLE['string']),
            # string containing single-quote with escape sequence
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLE['string']),
            # def/class
            (r'\bdef\b\s*(\w+)', 1, STYLE['def_class']),
            (r'\bclass\b\s*(\w+)', 1, STYLE['def_class']),
            # from # until new-line
            (r'#[^\n]*', 0, STYLE['comments']),
            # numbers
            (r'\b[+-]?[0-9]+[lL]?\b', 0, STYLE['numbers']),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0, STYLE['numbers']),
            # decorator
            (r'@[^\n', 0, STYLE['def_class']),
        ]
        # Build QRegExp for each pattern
        self.rules = [(QRegExp(pattern), index, fmt) for (pattern, index, fmt) in rules]
Пример #37
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        self.start_of_chorus = (QRegExp("\{soc\}"), QRegExp("\{eoc\}"), 1, STYLES['chorus'])

        rules = []

        # Rules
        # TODO: make a nice rule for chord definition
        # TODO: make rules for keywords that take special arguments (like numbers)
        rules += [(r'\{%s\:(.)*\}' % w, 0, STYLES['argument']) for w in ChordProHighlighter.argumentKeywords]
        rules += [(r'\{%s\:?' % w, 0, STYLES['keyword']) for w in ChordProHighlighter.keywords]
        rules += [(r'%s' % b, 0, STYLES['curlyBrace']) for b in ChordProHighlighter.curlyBraces]
        rules += [(r'\[[^\]]*\]', 0, STYLES['chord'])]

        # Build a QRegExp for each pattern
        self.rules = [(QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Пример #38
0
    def __init__(self, document):
        QSyntaxHighlighter.__init__(self, document)

        self.tri_single = (QRegExp("'''"), 1, STYLES['string2'])
        self.tri_double = (QRegExp('"""'), 2, STYLES['string2'])

        rules = []


        # All other rules
        rules += [

            (r'<[.,\w,:]*>',0,STYLES["extension"]),
            (r'/[\w,/]*(.\w+)*', 0, STYLES['path']),
            (r'[\w]*://[\w,/]*.\w*', 0, STYLES["orkurl"]),
            (r'ERROR:[^\n]*',0,STYLES["error"]),
            (r'FileError\([^\n]*',0,STYLES["error"]),
            # Double-quoted string, possibly containing escape sequences
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),
            # Single-quoted string, possibly containing escape sequences
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']),

            # 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]
Пример #39
0
 def __init__(self, parent, mode):
     QSyntaxHighlighter.__init__(self, parent)
     self.tstamp=time.time()
     self.formatter=QFormatter()
     self.lexer=get_lexer_by_name(mode)
     return
Пример #40
0
 def __init__(self, document):
     QSyntaxHighlighter.__init__(self, document)
Пример #41
0
    def __init__(self, parent):
        QSyntaxHighlighter.__init__(self, parent)

        self.fPalette = parent.palette()
Пример #42
0
	def __init__(self, document):
		QSyntaxHighlighter.__init__(self, document)
		document.highlighter = self
		updateColorScheme()