2007-06-23 21:41:18 -04:00
|
|
|
import color, mode2
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2007-06-23 21:41:18 -04:00
|
|
|
from point2 import Point
|
|
|
|
from lex2 import Grammar, ConstantRule, PatternRule, RegionRule, DualRegionRule
|
|
|
|
|
|
|
|
class MetadataGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(
|
|
|
|
name=r'username',
|
|
|
|
pattern='[a-zA-Z0-9_]+',
|
|
|
|
),
|
|
|
|
]
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2007-06-23 21:41:18 -04:00
|
|
|
class BlameGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
RegionRule(
|
|
|
|
name=r'metadata',
|
|
|
|
start=r'^[0-9\.]+',
|
|
|
|
grammar=MetadataGrammar(),
|
|
|
|
end=r'[0-9]{4}-[0-9]{2}-[0-9]{2}',
|
|
|
|
),
|
|
|
|
PatternRule(
|
|
|
|
name=r'data',
|
|
|
|
pattern=r'.+$',
|
|
|
|
),
|
|
|
|
]
|
2007-03-06 10:05:38 -05:00
|
|
|
|
2007-06-23 21:41:18 -04:00
|
|
|
class Blame(mode2.Fundamental):
|
|
|
|
grammar = BlameGrammar()
|
|
|
|
def __init__(self, w):
|
|
|
|
mode2.Fundamental.__init__(self, w)
|
2007-03-06 10:05:38 -05:00
|
|
|
self.colors = {
|
2007-06-23 21:41:18 -04:00
|
|
|
'metadata.start': color.build('blue', 'default', 'bold'),
|
|
|
|
'metadata.username': color.build('cyan', 'default', 'bold'),
|
|
|
|
'metadata.end': color.build('green', 'default', 'bold'),
|
2007-03-06 10:05:38 -05:00
|
|
|
}
|
|
|
|
def name(self):
|
|
|
|
return "Blame"
|