mirror of https://github.com/jroimartin/gocui.git
Add more tests to _examples/colors256.go
This commit is contained in:
parent
56a1633c76
commit
adef0057a9
|
@ -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 {
|
fmt.Fprint(v, str)
|
||||||
str += "\n\n"
|
}
|
||||||
count = 0
|
|
||||||
|
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)
|
fmt.Fprint(v, str)
|
||||||
|
|
||||||
|
ctr++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue