eric6/Plugins/VcsPlugins/vcsPySvn/SvnDiffHighlighter.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8218
7c09585bd960
permissions
-rw-r--r--

Updated copyright for 2021.

# -*- coding: utf-8 -*-

# Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a syntax highlighter for unified and context diff outputs.
"""

from E5Gui.E5GenericDiffHighlighter import TERMINAL, E5GenericDiffHighlighter


class SvnDiffHighlighter(E5GenericDiffHighlighter):
    """
    Class implementing a diff highlighter for Git.
    """
    def __init__(self, doc):
        """
        Constructor
        
        @param doc reference to the text document (QTextDocument)
        """
        super(SvnDiffHighlighter, self).__init__(doc)

    def generateRules(self):
        """
        Public method to generate the rule set.
        """
        diffHeader = self.makeFormat(fg=self.textColor,
                                     bg=self.headerColor)
        diffHeaderBold = self.makeFormat(fg=self.textColor,
                                         bg=self.headerColor,
                                         bold=True)
        diffContext = self.makeFormat(fg=self.textColor,
                                      bg=self.contextColor)

        diffAdded = self.makeFormat(fg=self.textColor,
                                    bg=self.addedColor)
        diffRemoved = self.makeFormat(fg=self.textColor,
                                      bg=self.removedColor)
        
        diffBarRegex = TERMINAL(r'^=+$')

        diffHeaderRegex = TERMINAL(r'^[iI]ndex: \S+')
        
        diffOldRegex = TERMINAL(r'^--- ')
        diffNewRegex = TERMINAL(r'^\+\+\+')
        diffContextRegex = TERMINAL(r'^@@ ')
        
        diffAddedRegex = TERMINAL(r'^[+>]|^A ')
        diffRemovedRegex = TERMINAL(r'^[-<]|^D ')
        
        self.createRules((diffOldRegex, diffRemoved),
                         (diffNewRegex, diffAdded),
                         (diffContextRegex, diffContext),
                         (diffHeaderRegex, diffHeader),
                         (diffBarRegex, diffHeaderBold),
                         (diffAddedRegex, diffAdded),
                         (diffRemovedRegex, diffRemoved),
                         )

eric ide

mercurial