"erb",
"fish",
"fortran",
+ "gdscript",
"gentoo-ebuild",
"gentoo-etc-portage",
"git-commit",
"git-rebase-todo",
"glsl",
"go",
+ "golo",
"groff",
"haml",
"haskell",
"keymap",
"kickstart",
"ledger",
+ "lilypond",
"lisp",
"lua",
"makefile",
// This involves finding the regex for syntax and if it exists, the regex
// for the header. Then we must get the text for the file and the filetype.
func LoadSyntaxFilesFromDir(dir string) {
+ colorscheme = make(Colorscheme)
InitColorscheme()
+ // Default style
+ defStyle = tcell.StyleDefault.
+ Foreground(tcell.ColorDefault).
+ Background(tcell.ColorDefault)
+
+ // There may be another default style defined in the colorscheme
+ // In that case we should use that one
+ if style, ok := colorscheme["default"]; ok {
+ defStyle = style
+ }
+ if screen != nil {
+ screen.SetStyle(defStyle)
+ }
+
syntaxFiles = make(map[[2]*regexp.Regexp]FileTypeRules)
files, _ := ioutil.ReadDir(dir)
for _, f := range files {
// in which case we should look that up in the colorscheme
// They can also just give us a straight up color
st := defStyle
- if _, ok := colorscheme[color]; ok {
- st = colorscheme[color]
+ groups := strings.Split(color, ".")
+ if len(groups) > 1 {
+ curGroup := ""
+ for i, g := range groups {
+ if i != 0 {
+ curGroup += "."
+ }
+ curGroup += g
+ if style, ok := colorscheme[curGroup]; ok {
+ st = style
+ }
+ }
+ } else if style, ok := colorscheme[color]; ok {
+ st = style
} else {
st = StringToStyle(color)
}
for i, line := range lines {
matches[i] = make([]tcell.Style, len(line)+1)
+ for j, _ := range matches[i] {
+ matches[i][j] = defStyle
+ }
}
// We don't actually check the entire buffer, just from synLinesUp to synLinesDown
str := strings.Join(buf.Lines(totalStart, totalEnd), "\n")
startNum := ToCharPos(Loc{0, totalStart}, v.Buf)
- toplineNum := ToCharPos(Loc{0, v.Topline}, v.Buf)
-
for _, rule := range rules {
if rule.startend {
if indicies := rule.regex.FindAllStringIndex(str, -1); indicies != nil {
for _, value := range indicies {
value[0] = runePos(value[0], str) + startNum
value[1] = runePos(value[1], str) + startNum
- for i := value[0]; i < value[1]; i++ {
- if i < toplineNum {
+ startLoc := FromCharPos(value[0], buf)
+ endLoc := FromCharPos(value[1], buf)
+ for curLoc := startLoc; curLoc.LessThan(endLoc); curLoc = curLoc.Move(1, buf) {
+ if curLoc.Y < v.Topline {
continue
}
- loc := FromCharPos(i, buf)
- colNum, lineNum := loc.X, loc.Y
+ colNum, lineNum := curLoc.X, curLoc.Y
if lineNum == -1 || colNum == -1 {
continue
}
for _, value := range indicies {
start := runePos(value[0], line)
end := runePos(value[1], line)
+ // messenger.Message(start, " ", end)
for i := start; i < end; i++ {
matches[lineN][i] = rule.style
}