2009-03-29 20:50:27 -04:00
|
|
|
from mode import Fundamental
|
2009-04-04 12:27:19 -04:00
|
|
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
2007-07-21 11:40:53 -04:00
|
|
|
|
|
|
|
class DiffGrammar(Grammar):
|
|
|
|
rules = [
|
2009-04-04 12:27:19 -04:00
|
|
|
PatternRule('diff.left', r"^\-.*\n$"),
|
|
|
|
PatternRule('diff.right', r"^\+.*\n$"),
|
|
|
|
PatternRule('diff.metadata', r'^[A-Za-z].*\n$'),
|
|
|
|
PatternRule('diff.seperator', r'^={67}\n$'),
|
|
|
|
PatternRule('diff.location', r"^@@ [-+0-9a-z, ]* @@\n$"),
|
|
|
|
PatternRule('diff.common', r"^.*\n$"),
|
2007-07-21 11:40:53 -04:00
|
|
|
]
|
|
|
|
|
2009-03-29 20:50:27 -04:00
|
|
|
class Diff(Fundamental):
|
2009-03-17 15:24:10 -04:00
|
|
|
name = 'diff'
|
|
|
|
extensions = ['.patch', '.diff']
|
|
|
|
grammar = DiffGrammar()
|
|
|
|
colors = {
|
2009-04-04 12:27:19 -04:00
|
|
|
'diff.left': ('red', 'default', 'bold'),
|
|
|
|
'diff.right': ('blue', 'default', 'bold'),
|
|
|
|
'diff.seperator': ('magenta', 'default', 'bold'),
|
|
|
|
'diff.metadata': ('magenta', 'default', 'bold'),
|
|
|
|
'diff.location': ('magenta', 'default', 'bold'),
|
2007-07-21 11:40:53 -04:00
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
2009-04-04 12:27:19 -04:00
|
|
|
class Diff3Line(Grammar):
|
|
|
|
rules = [PatternMatchRule('x', r'^( )(.*)\n$', 'pre', 'data')]
|
|
|
|
class Diff3Grammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule('diff.seperator', r'^====\n$'),
|
|
|
|
RegionRule('diff.part1', r"^1:\d+,\d+[a-z]\n$", Diff3Line, '^(?=[^ ])'),
|
|
|
|
RegionRule('diff.part2', r"^2:\d+,\d+[a-z]\n$", Diff3Line, '^(?=[^ ])'),
|
|
|
|
RegionRule('diff.part3', r"^3:\d+,\d+[a-z]\n$", Diff3Line, '^(?=[^ ])'),
|
|
|
|
PatternRule('diff.common', r"^.*\n$"),
|
|
|
|
]
|
|
|
|
|
|
|
|
class Diff3(Fundamental):
|
|
|
|
name = 'diff3'
|
|
|
|
extensions = ['.diff3']
|
|
|
|
grammar = Diff3Grammar()
|
|
|
|
colors = {
|
|
|
|
'diff.part1.start': ('yellow', 'default', 'bold'),
|
|
|
|
'diff.part1.pre': ('red', 'red', 'bold'),
|
|
|
|
'diff.part2.start': ('yellow', 'default', 'bold'),
|
|
|
|
'diff.part2.pre': ('green', 'green', 'bold'),
|
|
|
|
'diff.part3.start': ('yellow', 'default', 'bold'),
|
|
|
|
'diff.part3.pre': ('blue', 'blue', 'bold'),
|
|
|
|
}
|
|
|
|
|
|
|
|
def install(*args, **kwargs):
|
|
|
|
Diff.install(*args, **kwargs)
|
|
|
|
Diff3.install(*args, **kwargs)
|