diff --git a/README.md b/README.md index 87e7a90..55c12f1 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,11 @@ The `helloworld` color scheme drops in some colors! list +#### 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 [demo code](https://github.com/gizak/termui/blob/master/example/gauge.go) diff --git a/example/coloredList.go b/example/coloredList.go new file mode 100644 index 0000000..284d488 --- /dev/null +++ b/example/coloredList.go @@ -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() +}