mirror of
https://github.com/zyedidia/micro
synced 2024-11-05 17:41:24 +00:00
Merge
This commit is contained in:
commit
2b1ebd5fb7
3 changed files with 15 additions and 6 deletions
|
@ -117,16 +117,12 @@ func ParseColorscheme(text string) (map[string]tcell.Style, error) {
|
|||
|
||||
// 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
|
||||
// The 'extra' can be bold, reverse, italic or underline
|
||||
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, ",")
|
||||
}
|
||||
split = strings.Split(spaceSplit[len(spaceSplit)-1], ",")
|
||||
if len(split) > 1 {
|
||||
fg, bg = split[0], split[1]
|
||||
} else {
|
||||
|
|
|
@ -26,6 +26,18 @@ func TestAttributeStringToStyle(t *testing.T) {
|
|||
assert.NotEqual(t, 0, attr&tcell.AttrBold)
|
||||
}
|
||||
|
||||
func TestMultiAttributesStringToStyle(t *testing.T) {
|
||||
s := StringToStyle("bold italic underline cyan,brightcyan")
|
||||
|
||||
fg, bg, attr := s.Decompose()
|
||||
|
||||
assert.Equal(t, tcell.ColorTeal, fg)
|
||||
assert.Equal(t, tcell.ColorAqua, bg)
|
||||
assert.NotEqual(t, 0, attr&tcell.AttrBold)
|
||||
assert.NotEqual(t, 0, attr&tcell.AttrItalic)
|
||||
assert.NotEqual(t, 0, attr&tcell.AttrUnderline)
|
||||
}
|
||||
|
||||
func TestColor256StringToStyle(t *testing.T) {
|
||||
s := StringToStyle("128,60")
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ ft["markdown"] = "<!-- %s -->"
|
|||
ft["nginx"] = "# %s"
|
||||
ft["nim"] = "# %s"
|
||||
ft["objc"] = "// %s"
|
||||
ft["ocaml"] = "(* %s *)"
|
||||
ft["pascal"] = "{ %s }"
|
||||
ft["perl"] = "# %s"
|
||||
ft["php"] = "// %s"
|
||||
|
|
Loading…
Reference in a new issue