Added an example for the colored list.

This commit is contained in:
Matteo Kloiber 2015-04-05 21:57:35 +02:00
parent 6c168b2d04
commit 769ce01ae8
2 changed files with 64 additions and 0 deletions

View File

@ -112,6 +112,11 @@ The `helloworld` color scheme drops in some colors!
<img src="./example/list.png" alt="list" type="image/png" width="200"> <img src="./example/list.png" alt="list" type="image/png" width="200">
#### Colored List
[demo code](https://github.com/gizak/termui/blob/master/example/coloredList.go)
TODO: Image (let's wait until the implementation is finished).
#### Gauge #### Gauge
[demo code](https://github.com/gizak/termui/blob/master/example/gauge.go) [demo code](https://github.com/gizak/termui/blob/master/example/gauge.go)

59
example/coloredList.go Normal file
View File

@ -0,0 +1,59 @@
// +build ignore
package main
import "github.com/gizak/termui"
import "github.com/nsf/termbox-go"
func commonList() *termui.List {
strs := []string{
"[0] github.com/gizak/termui",
"[1] 笀耔 [澉 灊灅甗](RED) 郔镺 笀耔 澉 [灊灅甗](yellow) 郔镺",
"[2] こんにちは世界",
"[3] keyboard.go",
"[4] [output](RED).go",
"[5] random_out.go",
"[6] [dashboard](BOLD).go",
"[7] nsf/termbox-go",
"[8] OVERFLOW!!!!!!![!!!!!!!!!!!!](red,bold)!!!"}
list := termui.NewList()
list.Items = strs
list.Height = 20
list.Width = 25
list.RendererFactory = termui.MarkdownTextRendererFactory{}
return list
}
func listHidden() *termui.List {
list := commonList()
list.Border.Label = "List - Hidden"
list.Overflow = "hidden"
return list
}
func listWrap() *termui.List {
list := commonList()
list.Border.Label = "List - Wrapped"
list.Overflow = "wrap"
return list
}
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
hiddenList := listHidden()
wrappedList := listWrap()
wrappedList.X = 30
termui.UseTheme("helloworld")
termui.Render(hiddenList, wrappedList)
termbox.PollEvent()
}