Add more tests to _examples/colors256.go

This commit is contained in:
Roi Martin 2016-11-13 20:46:02 +01:00
parent 56a1633c76
commit adef0057a9
1 changed files with 22 additions and 9 deletions

View File

@ -37,20 +37,33 @@ func layout(g *gocui.Gui) error {
return err return err
} }
var count int // 256-colors escape codes
for i := 1; i <= 255; i++ { for i := 0; i < 256; i++ {
count++ str := fmt.Sprintf("\x1b[48;5;%dm\x1b[30m%3d\x1b[0m ", i, i)
str += fmt.Sprintf("\x1b[38;5;%dm%3d\x1b[0m ", i, i)
block := fmt.Sprintf("\x1b[48;5;%dm%3s\x1b[0m", i, " ") if (i+1)%10 == 0 {
str := fmt.Sprintf("\x1b[38;5;%dm%3d %s\x1b[0m\t", i, i, block) str += "\n"
if count == 10 {
str += "\n\n"
count = 0
} }
fmt.Fprint(v, str) fmt.Fprint(v, str)
}
fmt.Fprint(v, "\n\n")
// 8-colors escape codes
ctr := 0
for i := 0; i <= 7; i++ {
for _, j := range []int{1, 4, 7} {
str := fmt.Sprintf("\x1b[3%d;%dm%d:%d\x1b[0m ", i, j, i, j)
if (ctr+1)%20 == 0 {
str += "\n"
}
fmt.Fprint(v, str)
ctr++
}
} }
} }
return nil return nil