2021-04-07 12:32:22 -04:00
|
|
|
package highlight
|
|
|
|
|
2021-04-07 13:10:40 -04:00
|
|
|
import "timshome.page/gilo/terminal"
|
2021-04-07 12:32:22 -04:00
|
|
|
|
2021-04-07 16:26:05 -04:00
|
|
|
var syntaxColorMap = map[int]string{
|
|
|
|
Number: terminal.FGRed,
|
|
|
|
Match: terminal.FGBlue,
|
|
|
|
Normal: terminal.DefaultFGColor,
|
|
|
|
}
|
|
|
|
|
2021-04-13 14:54:44 -04:00
|
|
|
// SyntaxToColor Take a highlighting type and map it to
|
2021-04-07 16:26:05 -04:00
|
|
|
// an ANSI color escape code for display
|
2021-04-07 12:32:22 -04:00
|
|
|
func SyntaxToColor(hl int) string {
|
2021-04-07 16:26:05 -04:00
|
|
|
color := syntaxColorMap[hl]
|
|
|
|
if len(color) == 0 {
|
|
|
|
color = terminal.DefaultFGColor
|
2021-04-07 12:32:22 -04:00
|
|
|
}
|
2021-04-07 16:26:05 -04:00
|
|
|
|
|
|
|
return color
|
2021-04-07 12:32:22 -04:00
|
|
|
}
|