Fix region highlighting and skipping

Ref #8
This commit is contained in:
Zachary Yedidia
2017-03-30 10:33:52 -04:00
parent 98b6b4f75e
commit c6faee5e6c
52 changed files with 161 additions and 58 deletions
+24 -6
View File
@@ -57,12 +57,13 @@ type rules struct {
// region and also rules from the above region do not match inside this region
// Note that a region may contain more regions
type region struct {
group Group
parent *region
start *regexp.Regexp
end *regexp.Regexp
skip *regexp.Regexp
rules *rules
group Group
limitGroup Group
parent *region
start *regexp.Regexp
end *regexp.Regexp
skip *regexp.Regexp
rules *rules
}
func init() {
@@ -237,6 +238,23 @@ func parseRegion(group string, regionInfo map[interface{}]interface{}, prevRegio
}
}
// limit-color is optional
if _, ok := regionInfo["limit-group"]; ok {
groupStr := regionInfo["limit-group"].(string)
if _, ok := Groups[groupStr]; !ok {
numGroups++
Groups[groupStr] = numGroups
}
groupNum := Groups[groupStr]
region.limitGroup = groupNum
if err != nil {
return nil, err
}
} else {
region.limitGroup = region.group
}
region.rules, err = parseRules(regionInfo["rules"].([]interface{}), region)
if err != nil {