]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/colorscheme.go
Code optimisation (#1117)
[micro.git] / cmd / micro / colorscheme.go
index 8cb4d916afc18c05e980f8beef803e96718d6104..8a649b1785d606d4149acfae214b86d5bbb0b63c 100644 (file)
@@ -15,7 +15,7 @@ type Colorscheme map[string]tcell.Style
 // The current colorscheme
 var colorscheme Colorscheme
 
-// This takes in a syntax group and returns the colorscheme's style for that group
+// GetColor takes in a syntax group and returns the colorscheme's style for that group
 func GetColor(color string) tcell.Style {
        st := defStyle
        if color == "" {
@@ -54,7 +54,7 @@ func InitColorscheme() {
                Foreground(tcell.ColorDefault).
                Background(tcell.ColorDefault)
        if screen != nil {
-               screen.SetStyle(defStyle)
+               // screen.SetStyle(defStyle)
        }
 
        LoadDefaultColorscheme()
@@ -109,7 +109,7 @@ func ParseColorscheme(text string) Colorscheme {
                                defStyle = style
                        }
                        if screen != nil {
-                               screen.SetStyle(defStyle)
+                               // screen.SetStyle(defStyle)
                        }
                } else {
                        fmt.Println("Color-link statement is not valid:", line)
@@ -252,5 +252,9 @@ func GetColor256(color int) tcell.Color {
                tcell.Color253, tcell.Color254, tcell.Color255,
        }
 
-       return colors[color]
+       if color >= 0 && color < len(colors) {
+               return colors[color]
+       }
+
+       return tcell.ColorDefault
 }