src/eric7/Plugins/VcsPlugins/vcsPySvn/SvnDiffHighlighter.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
5 5
6 """ 6 """
7 Module implementing a syntax highlighter for unified and context diff outputs. 7 Module implementing a syntax highlighter for unified and context diff outputs.
8 """ 8 """
9 9
10 from EricGui.EricGenericDiffHighlighter import ( 10 from EricGui.EricGenericDiffHighlighter import TERMINAL, EricGenericDiffHighlighter
11 TERMINAL, EricGenericDiffHighlighter
12 )
13 11
14 12
15 class SvnDiffHighlighter(EricGenericDiffHighlighter): 13 class SvnDiffHighlighter(EricGenericDiffHighlighter):
16 """ 14 """
17 Class implementing a diff highlighter for Git. 15 Class implementing a diff highlighter for Git.
18 """ 16 """
17
19 def __init__(self, doc): 18 def __init__(self, doc):
20 """ 19 """
21 Constructor 20 Constructor
22 21
23 @param doc reference to the text document (QTextDocument) 22 @param doc reference to the text document (QTextDocument)
24 """ 23 """
25 super().__init__(doc) 24 super().__init__(doc)
26 25
27 def generateRules(self): 26 def generateRules(self):
28 """ 27 """
29 Public method to generate the rule set. 28 Public method to generate the rule set.
30 """ 29 """
31 diffHeader = self.makeFormat(fg=self.textColor, 30 diffHeader = self.makeFormat(fg=self.textColor, bg=self.headerColor)
32 bg=self.headerColor) 31 diffHeaderBold = self.makeFormat(
33 diffHeaderBold = self.makeFormat(fg=self.textColor, 32 fg=self.textColor, bg=self.headerColor, bold=True
34 bg=self.headerColor, 33 )
35 bold=True) 34 diffContext = self.makeFormat(fg=self.textColor, bg=self.contextColor)
36 diffContext = self.makeFormat(fg=self.textColor,
37 bg=self.contextColor)
38 35
39 diffAdded = self.makeFormat(fg=self.textColor, 36 diffAdded = self.makeFormat(fg=self.textColor, bg=self.addedColor)
40 bg=self.addedColor) 37 diffRemoved = self.makeFormat(fg=self.textColor, bg=self.removedColor)
41 diffRemoved = self.makeFormat(fg=self.textColor,
42 bg=self.removedColor)
43
44 diffBarRegex = TERMINAL(r'^=+$')
45 38
46 diffHeaderRegex = TERMINAL(r'^[iI]ndex: \S+') 39 diffBarRegex = TERMINAL(r"^=+$")
47 40
48 diffOldRegex = TERMINAL(r'^--- ') 41 diffHeaderRegex = TERMINAL(r"^[iI]ndex: \S+")
49 diffNewRegex = TERMINAL(r'^\+\+\+') 42
50 diffContextRegex = TERMINAL(r'^@@ ') 43 diffOldRegex = TERMINAL(r"^--- ")
51 44 diffNewRegex = TERMINAL(r"^\+\+\+")
52 diffAddedRegex = TERMINAL(r'^[+>]|^A ') 45 diffContextRegex = TERMINAL(r"^@@ ")
53 diffRemovedRegex = TERMINAL(r'^[-<]|^D ') 46
54 47 diffAddedRegex = TERMINAL(r"^[+>]|^A ")
55 self.createRules((diffOldRegex, diffRemoved), 48 diffRemovedRegex = TERMINAL(r"^[-<]|^D ")
56 (diffNewRegex, diffAdded), 49
57 (diffContextRegex, diffContext), 50 self.createRules(
58 (diffHeaderRegex, diffHeader), 51 (diffOldRegex, diffRemoved),
59 (diffBarRegex, diffHeaderBold), 52 (diffNewRegex, diffAdded),
60 (diffAddedRegex, diffAdded), 53 (diffContextRegex, diffContext),
61 (diffRemovedRegex, diffRemoved), 54 (diffHeaderRegex, diffHeader),
62 ) 55 (diffBarRegex, diffHeaderBold),
56 (diffAddedRegex, diffAdded),
57 (diffRemovedRegex, diffRemoved),
58 )

eric ide

mercurial