mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-23 17:27:14 +09:00
Add colorschemes to runtime
This commit is contained in:
11
runtime/colorschemes/default.micro
Normal file
11
runtime/colorschemes/default.micro
Normal file
@@ -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"
|
||||
12
runtime/colorschemes/solarized.micro
Normal file
12
runtime/colorschemes/solarized.micro
Normal file
@@ -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"
|
||||
@@ -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+"(.*)"`)
|
||||
|
||||
Reference in New Issue
Block a user