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.

4110
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4110
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a syntax highlighter for unified and context diff outputs.
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from E5Gui.E5GenericDiffHighlighter import TERMINAL, E5GenericDiffHighlighter
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 class SvnDiffHighlighter(E5GenericDiffHighlighter):
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 Class implementing a diff highlighter for Git.
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 def __init__(self, doc):
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Constructor
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 @param doc reference to the text document (QTextDocument)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 super(SvnDiffHighlighter, self).__init__(doc)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 def generateRules(self):
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Public method to generate the rule set.
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 diffHeader = self.makeFormat(fg=self.textColor,
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 bg=self.headerColor)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 diffHeaderBold = self.makeFormat(fg=self.textColor,
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 bg=self.headerColor,
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 bold=True)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 diffContext = self.makeFormat(fg=self.textColor,
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 bg=self.contextColor)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 diffAdded = self.makeFormat(fg=self.textColor,
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 bg=self.addedColor)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 diffRemoved = self.makeFormat(fg=self.textColor,
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 bg=self.removedColor)
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 diffBarRegex = TERMINAL(r'^=+$')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 diffHeaderRegex = TERMINAL(r'^[iI]ndex: \S+')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 diffOldRegex = TERMINAL(r'^--- ')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 diffNewRegex = TERMINAL(r'^\+\+\+')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 diffContextRegex = TERMINAL(r'^@@ ')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 diffAddedRegex = TERMINAL(r'^[+>]|^A ')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 diffRemovedRegex = TERMINAL(r'^[-<]|^D ')
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.createRules((diffOldRegex, diffRemoved),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 (diffNewRegex, diffAdded),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 (diffContextRegex, diffContext),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 (diffHeaderRegex, diffHeader),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 (diffBarRegex, diffHeaderBold),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 (diffAddedRegex, diffAdded),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 (diffRemovedRegex, diffRemoved),
5a106c734527 Added diff syntax highlighters to the various VCS interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 )

eric ide

mercurial