func StringToStyle(str string) tcell.Style {
	var fg, bg string
	spaceSplit := strings.Split(str, " ")
	var split []string
	if len(spaceSplit) > 1 {
		split = strings.Split(spaceSplit[1], ",")
	} else {
		split = strings.Split(str, ",")
	}
	if len(split) > 1 {
		fg, bg = split[0], split[1]
	} else {
		fg = split[0]
	}
	fg = strings.TrimSpace(fg)
	bg = strings.TrimSpace(bg)
	var fgColor, bgColor tcell.Color
	if fg == "" {
		fgColor, _, _ = defStyle.Decompose()
	} else {
		fgColor = StringToColor(fg)
	}
	if bg == "" {
		_, bgColor, _ = defStyle.Decompose()
	} else {
		bgColor = StringToColor(bg)
	}
	style := defStyle.Foreground(fgColor).Background(bgColor)
	if strings.Contains(str, "bold") {
		style = style.Bold(true)
	}
	if strings.Contains(str, "reverse") {
		style = style.Reverse(true)
	}
	if strings.Contains(str, "underline") {
		style = style.Underline(true)
	}
	return style
}
StringToStyle returns a style from a string
The strings must be in the format "extra foregroundcolor,backgroundcolor"
The 'extra' can be bold, reverse, or underline
package editor
import (
	"log"
	"regexp"
	"strconv"
	"strings"
	"github.com/gdamore/tcell/v2"
)
type Colorscheme map[string]tcell.Style
var colorscheme Colorscheme
var defStyle tcell.Style
func GetColor(color string) tcell.Style {
	return colorscheme.GetColor(color)
}
func (colorscheme Colorscheme) GetColor(color string) tcell.Style {
	st := defStyle
	if color == "" {
		return st
	}
	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)
	}
	return st
}
func init() {
	colorscheme = make(Colorscheme)
	defStyle = tcell.StyleDefault.
		Foreground(tcell.ColorDefault).
		Background(tcell.ColorDefault)
}
func SetDefaultColorscheme(scheme Colorscheme) {
	colorscheme = scheme
}
func ParseColorscheme(text string) Colorscheme {
	parser := regexp.MustCompile(`color-link\s+(\S*)\s+"(.*)"`)
	lines := strings.Split(text, "\n")
	c := make(Colorscheme)
	for _, line := range lines {
		if strings.TrimSpace(line) == "" ||
			strings.TrimSpace(line)[0] == '#' {
			continue
		}
		matches := parser.FindSubmatch([]byte(line))
		if len(matches) == 3 {
			link := string(matches[1])
			colors := string(matches[2])
			style := StringToStyle(colors)
			c[link] = style
			if link == "default" {
				defStyle = style
			}
		} else {
			log.Println("Color-link statement is not valid:", line)
		}
	}
	return c
}