diff --git a/runtime/colorschemes/default.micro b/runtime/colorschemes/default.micro new file mode 100644 index 00000000..04178599 --- /dev/null +++ b/runtime/colorschemes/default.micro @@ -0,0 +1,11 @@ +color-link comment "blue" +color-link constant "red" +color-link identifier "cyan" +color-link statement "yellow" +color-link preproc "magenta" +color-link type "green" +color-link special "magenta" +color-link ignore "default" +color-link error ",brightred" +color-link todo ",brightyellow" +color-link line-number "yellow" \ No newline at end of file diff --git a/runtime/colorschemes/solarized.micro b/runtime/colorschemes/solarized.micro new file mode 100644 index 00000000..2c702f54 --- /dev/null +++ b/runtime/colorschemes/solarized.micro @@ -0,0 +1,12 @@ +color-link comment "brightgreen" +color-link constant "cyan" +color-link identifier "blue" +color-link statement "green" +color-link preproc "brightred" +color-link type "yellow" +color-link special "red" +color-link underlined "magenta" +color-link error "bold brightred" +color-link todo "bold magenta" +color-link statusline "black,brightblue" +color-link line-number "brightgreen,black" diff --git a/src/colorscheme.go b/src/colorscheme.go index 1c32cd97..674c44d9 100644 --- a/src/colorscheme.go +++ b/src/colorscheme.go @@ -9,7 +9,7 @@ import ( "strings" ) -const colorschemeName = "default" +const defaultColorscheme = "default" // Colorscheme is a map from string to style -- it represents a colorscheme type Colorscheme map[string]tcell.Style @@ -19,22 +19,18 @@ var colorscheme Colorscheme // InitColorscheme picks and initializes the colorscheme when micro starts func InitColorscheme() { - LoadColorscheme() - // LoadColorscheme may not have found any colorschemes - if colorscheme == nil { - colorscheme = DefaultColorscheme() - } + LoadDefaultColorscheme() } -// LoadColorscheme loads the colorscheme from ~/.micro/colorschemes -func LoadColorscheme() { +// LoadDefaultColorscheme loads the default colorscheme from ~/.micro/colorschemes +func LoadDefaultColorscheme() { usr, _ := user.Current() dir := usr.HomeDir - LoadColorschemeFromDir(dir + "/.micro/colorschemes") + LoadColorscheme(defaultColorscheme, dir+"/.micro/colorschemes") } -// LoadColorschemeFromDir loads the colorscheme from a directory -func LoadColorschemeFromDir(dir string) { +// LoadColorscheme loads the given colorscheme from a directory +func LoadColorscheme(colorschemeName, dir string) { files, _ := ioutil.ReadDir(dir) for _, f := range files { if f.Name() == colorschemeName+".micro" { @@ -48,23 +44,6 @@ func LoadColorschemeFromDir(dir string) { } } -// DefaultColorscheme returns the default colorscheme -func DefaultColorscheme() Colorscheme { - c := make(Colorscheme) - c["comment"] = StringToStyle("brightgreen") - c["constant"] = StringToStyle("cyan") - c["identifier"] = StringToStyle("blue") - c["statement"] = StringToStyle("green") - c["preproc"] = StringToStyle("brightred") - c["type"] = StringToStyle("yellow") - c["special"] = StringToStyle("red") - c["underlined"] = StringToStyle("brightmagenta") - c["ignore"] = StringToStyle("default") - c["error"] = StringToStyle("bold brightred") - c["todo"] = StringToStyle("bold brightmagenta") - return c -} - // ParseColorscheme parses the text definition for a colorscheme and returns the corresponding object func ParseColorscheme(text string) Colorscheme { parser := regexp.MustCompile(`color-link\s+(\S*)\s+"(.*)"`)