termui/example/coloredList.go
Matteo Kloiber 3c08053c57 Bugfixes and refactoring
Bugfixes:

 - Fixes a bug which placed the tree dots (…) for overflown list on the wrong position.

Refactoring

 - Renamed `TextRender` to `TextRenderer`
 - Renamed `NoopRenderer` to `PlainRenderer`
 - Renamed `NoopRendererFactory` to `PlainRendererFactory`
2015-04-10 17:08:27 +02:00

60 lines
1.1 KiB
Go

// +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 = 15
list.Width = 26
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()
}