mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
Add support for limit-group to highlights region limits
This commit is contained in:
@@ -116,14 +116,16 @@ func (h *Highlighter) highlightRegion(highlights LineMatch, start int, canMatchE
|
|||||||
|
|
||||||
if start == 0 {
|
if start == 0 {
|
||||||
if !statesOnly {
|
if !statesOnly {
|
||||||
|
if _, ok := highlights[0]; !ok {
|
||||||
highlights[0] = curRegion.group
|
highlights[0] = curRegion.group
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loc := findIndex(curRegion.end, curRegion.skip, line, start == 0, canMatchEnd)
|
loc := findIndex(curRegion.end, curRegion.skip, line, start == 0, canMatchEnd)
|
||||||
if loc != nil {
|
if loc != nil {
|
||||||
if !statesOnly {
|
if !statesOnly {
|
||||||
highlights[start+loc[1]-1] = curRegion.group
|
highlights[start+loc[0]] = curRegion.limitGroup
|
||||||
}
|
}
|
||||||
if curRegion.parent == nil {
|
if curRegion.parent == nil {
|
||||||
if !statesOnly {
|
if !statesOnly {
|
||||||
@@ -162,7 +164,7 @@ func (h *Highlighter) highlightRegion(highlights LineMatch, start int, canMatchE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if firstLoc[0] != len(line) {
|
if firstLoc[0] != len(line) {
|
||||||
highlights[start+firstLoc[0]] = firstRegion.group
|
highlights[start+firstLoc[0]] = firstRegion.limitGroup
|
||||||
h.highlightRegion(highlights, start, false, lineNum, line[:firstLoc[0]], curRegion, statesOnly)
|
h.highlightRegion(highlights, start, false, lineNum, line[:firstLoc[0]], curRegion, statesOnly)
|
||||||
h.highlightRegion(highlights, start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion, statesOnly)
|
h.highlightRegion(highlights, start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion, statesOnly)
|
||||||
return highlights
|
return highlights
|
||||||
@@ -217,7 +219,7 @@ func (h *Highlighter) highlightEmptyRegion(highlights LineMatch, start int, canM
|
|||||||
}
|
}
|
||||||
if firstLoc[0] != len(line) {
|
if firstLoc[0] != len(line) {
|
||||||
if !statesOnly {
|
if !statesOnly {
|
||||||
highlights[start+firstLoc[0]] = firstRegion.group
|
highlights[start+firstLoc[0]] = firstRegion.limitGroup
|
||||||
}
|
}
|
||||||
h.highlightEmptyRegion(highlights, start, false, lineNum, line[:firstLoc[0]], statesOnly)
|
h.highlightEmptyRegion(highlights, start, false, lineNum, line[:firstLoc[0]], statesOnly)
|
||||||
h.highlightRegion(highlights, start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion, statesOnly)
|
h.highlightRegion(highlights, start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion, statesOnly)
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ type rules struct {
|
|||||||
// Note that a region may contain more regions
|
// Note that a region may contain more regions
|
||||||
type region struct {
|
type region struct {
|
||||||
group Group
|
group Group
|
||||||
|
limitGroup Group
|
||||||
parent *region
|
parent *region
|
||||||
start *regexp.Regexp
|
start *regexp.Regexp
|
||||||
end *regexp.Regexp
|
end *regexp.Regexp
|
||||||
@@ -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)
|
region.rules, err = parseRules(regionInfo["rules"].([]interface{}), region)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1900,7 +1900,7 @@ func runtimeSyntaxHaskellYaml() (*asset, error) {
|
|||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _runtimeSyntaxHtmlYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x91\x41\x8f\xd4\x30\x0c\x85\xef\xf9\x15\x51\x84\x10\xac\x44\xb9\x67\x07\xf6\xc0\xcf\x68\x8b\xe4\x4d\xdc\x36\xac\x9b\x54\xb1\x3b\x68\x91\x7f\x3c\x2a\x1d\xb6\x2b\x66\x10\xe4\xf8\x9e\xad\xf7\xf9\x65\x48\x84\xf2\xbc\xa0\xb7\x93\xcc\x64\x4c\x44\xc1\x20\xde\x58\x6b\xed\xe6\x65\x98\xd1\x5b\xd7\x75\xcd\x24\x73\x4b\xfd\xc3\x1b\x67\x4c\x5d\x09\x79\x9f\xf9\x60\x53\xc4\x2c\x69\x48\x58\xbd\x75\xa7\xe6\xee\xe1\xb3\xbb\x38\xbc\x60\x48\x40\xde\xba\xb7\xed\xd7\xfb\xb6\xf5\xbc\x40\x40\xdf\xf7\xfd\xdd\xfd\xcb\x8c\x80\xe0\x8c\x59\xbc\x75\xef\x80\x44\x1f\xc7\x50\xa8\x54\x9d\x30\x8d\x93\xe8\x54\x71\x50\x82\x47\x24\xa5\x92\xc7\x88\x1c\x74\x63\xd2\x92\x03\xa5\xf0\xa4\x25\x0f\x25\xac\xac\x25\x53\x81\xa8\x25\xcf\x65\x65\x2c\x67\xac\xca\xe9\x07\x2a\x2f\x90\x95\x6b\x50\x96\x67\x42\x15\xa8\x23\x8a\x6e\x27\xeb\x19\x68\x45\xfd\x9e\xa2\x4c\xef\x3f\x39\x73\x21\x0a\x25\xb3\x40\x96\x86\xa5\xa6\x3c\xee\x67\x6e\x8f\x05\xea\x86\xd9\x39\xf7\xa2\x61\x8e\x7f\x28\xfc\x94\x96\x5f\x85\x75\x5d\x73\xa8\xaf\x1a\xfb\xfd\x5e\x27\xed\x45\x7d\x99\xa0\x1e\xab\x17\x9c\x88\x03\xac\x24\xd7\x18\x27\x0e\x35\x2d\x72\x14\x7e\xf0\x9c\x3e\xde\xf2\x6e\x32\xa4\x1c\x68\x8d\xdb\x17\x7f\x83\x33\xec\x6b\xff\x93\xbd\x95\xf9\x97\xe8\x6b\xeb\x1f\xc9\x81\xd9\x19\xf3\x33\x00\x00\xff\xff\xbc\x3c\xd7\x4c\x8a\x02\x00\x00")
|
var _runtimeSyntaxHtmlYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x92\xdf\x6e\xd5\x30\x0c\xc6\xef\xf3\x14\x51\x84\x10\x4c\x5a\xb9\xcf\x0e\xec\x82\xc7\x68\x8b\xe4\x25\x6e\x1b\xe6\x26\x55\xec\x1e\x34\xe4\x87\x47\xa5\x87\xf5\x88\xf1\x67\xbe\xfc\x3e\x27\xfe\xf9\x4b\x86\x44\x28\x4f\x0b\x7a\x3b\xc9\x4c\xc6\x44\x14\x0c\xe2\x8d\xb5\xd6\x6e\x5e\x86\x19\xbd\x75\x5d\xd7\x4c\x32\xb7\xd4\xdf\xbf\x71\xc6\xd4\x95\x90\xf7\x9e\x5b\x9b\x22\x66\x49\x43\xc2\xea\xad\x3b\x35\x37\xf7\x9f\xdc\xc5\xe1\x05\x43\x02\xf2\xd6\xbd\x6d\xbf\xdc\xb5\xad\xe7\x05\x02\xfa\xbe\xef\x6f\xee\x9e\x7b\x04\x04\x67\xcc\xe2\xad\x7b\x07\x24\xfa\x30\x86\x42\xa5\xea\x84\x69\x9c\x44\xa7\x8a\x83\x12\x3c\x20\x29\x95\x3c\x46\xe4\xa0\x1b\x93\x96\x1c\x28\x85\x47\x2d\x79\x28\x61\x65\x2d\x99\x0a\x44\x2d\x79\x2e\x2b\x63\x39\x63\x55\x4e\xdf\x51\x79\x81\xac\x5c\x83\xb2\x3c\x11\xaa\x40\x1d\x51\x74\x5b\x59\xcf\x40\x2b\xea\xb7\x14\x65\x7a\xff\xd1\x99\x0b\x51\x28\x99\x05\xb2\x34\x2c\x35\xe5\x71\x5f\x73\x2b\x16\xa8\x1b\x66\xe7\xdc\xb3\x86\x39\xfe\xa6\xf0\x63\x5a\x7e\x06\xd6\x75\xcd\xa1\x5e\x25\xf6\xab\xae\x27\xed\x41\x7d\x9e\xa0\x1e\x47\x2f\x38\x11\x07\x58\x49\x5e\x62\x9c\x38\xd4\xb4\xc8\x11\xf8\xc1\x73\xfa\xf0\x27\x8f\xd2\x9c\xe4\x76\xac\x65\x5d\xfc\xd5\xab\xfd\x9b\x31\xe5\x40\x6b\xdc\xbe\xc0\x57\x38\xc3\x7e\xed\x6b\xd8\xb6\xb0\xff\x82\xf6\xd2\xfa\xcf\xe4\xc0\xec\x8c\xf9\x11\x00\x00\xff\xff\x2e\xf2\xcb\xf0\xaa\x02\x00\x00")
|
||||||
|
|
||||||
func runtimeSyntaxHtmlYamlBytes() ([]byte, error) {
|
func runtimeSyntaxHtmlYamlBytes() ([]byte, error) {
|
||||||
return bindataRead(
|
return bindataRead(
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ rules:
|
|||||||
- default:
|
- default:
|
||||||
start: "<script.*?>"
|
start: "<script.*?>"
|
||||||
end: "</script.*?>"
|
end: "</script.*?>"
|
||||||
|
limit-group: identifier
|
||||||
rules:
|
rules:
|
||||||
- include: "javascript"
|
- include: "javascript"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user