mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-10 06:40:24 +09:00
20 lines
374 B
Go
20 lines
374 B
Go
package highlight
|
|
|
|
func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
|
|
for _, d := range defs {
|
|
if d.ftdetect[0].Match([]byte(filename)) {
|
|
return d
|
|
}
|
|
if len(d.ftdetect) > 1 {
|
|
if d.ftdetect[1].Match(firstLine) {
|
|
return d
|
|
}
|
|
}
|
|
}
|
|
|
|
emptyDef := new(Def)
|
|
emptyDef.FileType = "Unknown"
|
|
emptyDef.rules = new(Rules)
|
|
return emptyDef
|
|
}
|