diff --git a/_examples/barchart.go b/_examples/barchart.go index aa20274..9e48f5e 100644 --- a/_examples/barchart.go +++ b/_examples/barchart.go @@ -6,31 +6,27 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - if err := termui.Init(); err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() - bc := termui.NewBarChart() - data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6} - bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"} + bc := ui.NewBarChart() + bc.Data = []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6} + bc.DataLabels = []string{"S0", "S1", "S2", "S3", "S4", "S5"} bc.BorderLabel = "Bar Chart" - bc.Data = data bc.Width = 26 bc.Height = 10 - bc.DataLabels = bclabels - bc.TextColor = termui.ColorGreen - bc.BarColor = termui.ColorRed - bc.NumColor = termui.ColorYellow + bc.TextColor = ui.ColorGreen + bc.BarColor = ui.ColorRed + bc.NumColor = ui.ColorYellow - termui.Render(bc) + ui.Render(bc) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + ui.Loop() } diff --git a/_examples/dashboard.go b/_examples/dashboard.go index 50dc94e..1a14b23 100644 --- a/_examples/dashboard.go +++ b/_examples/dashboard.go @@ -13,9 +13,7 @@ import ( ) func main() { - if err := ui.Init(); err != nil { - panic(err) - } + ui.Init() defer ui.Close() p := ui.NewPar(":PRESS q TO QUIT DEMO") @@ -33,14 +31,15 @@ func main() { } }) - strs := []string{"[0] gizak/termui", "[1] editbox.go", "[2] interrupt.go", "[3] keyboard.go", "[4] output.go", "[5] random_out.go", "[6] dashboard.go", "[7] nsf/termbox-go"} - list := ui.NewList() - list.Items = strs - list.ItemFgColor = ui.ColorYellow - list.BorderLabel = "List" - list.Height = 7 - list.Width = 25 - list.Y = 4 + listData := []string{"[0] gizak/termui", "[1] editbox.go", "[2] interrupt.go", "[3] keyboard.go", "[4] output.go", "[5] random_out.go", "[6] dashboard.go", "[7] nsf/termbox-go"} + + l := ui.NewList() + l.Items = listData + l.ItemFgColor = ui.ColorYellow + l.BorderLabel = "List" + l.Height = 7 + l.Width = 25 + l.Y = 4 g := ui.NewGauge() g.Percent = 50 @@ -52,29 +51,30 @@ func main() { g.BorderFg = ui.ColorWhite g.BorderLabelFg = ui.ColorCyan - spark := ui.Sparkline{} - spark.Height = 1 - spark.Title = "srv 0:" - spdata := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6} - spark.Data = spdata - spark.LineColor = ui.ColorCyan - spark.TitleColor = ui.ColorWhite + sparklineData := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6, 4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6} - spark1 := ui.Sparkline{} - spark1.Height = 1 - spark1.Title = "srv 1:" - spark1.Data = spdata - spark1.TitleColor = ui.ColorWhite - spark1.LineColor = ui.ColorRed + sl := ui.Sparkline{} + sl.Height = 1 + sl.Title = "srv 0:" + sl.Data = sparklineData + sl.LineColor = ui.ColorCyan + sl.TitleColor = ui.ColorWhite - sp := ui.NewSparklines(spark, spark1) - sp.Width = 25 - sp.Height = 7 - sp.BorderLabel = "Sparkline" - sp.Y = 4 - sp.X = 25 + sl2 := ui.Sparkline{} + sl2.Height = 1 + sl2.Title = "srv 1:" + sl2.Data = sparklineData + sl2.TitleColor = ui.ColorWhite + sl2.LineColor = ui.ColorRed - sinps := (func() []float64 { + sls := ui.NewSparklines(sl, sl2) + sls.Width = 25 + sls.Height = 7 + sls.BorderLabel = "Sparkline" + sls.Y = 4 + sls.X = 25 + + sinData := (func() []float64 { n := 220 ps := make([]float64, n) for i := range ps { @@ -85,7 +85,7 @@ func main() { lc := ui.NewLineChart() lc.BorderLabel = "dot-mode Line Chart" - lc.Data["default"] = sinps + lc.Data["default"] = sinData lc.Width = 50 lc.Height = 11 lc.X = 0 @@ -94,52 +94,56 @@ func main() { lc.LineColor["default"] = ui.ColorRed | ui.AttrBold lc.Mode = "dot" + barchartData := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6} + bc := ui.NewBarChart() - bcdata := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6} - bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"} bc.BorderLabel = "Bar Chart" bc.Width = 26 bc.Height = 10 bc.X = 51 bc.Y = 0 - bc.DataLabels = bclabels + bc.DataLabels = []string{"S0", "S1", "S2", "S3", "S4", "S5"} bc.BarColor = ui.ColorGreen bc.NumColor = ui.ColorBlack - lc1 := ui.NewLineChart() - lc1.BorderLabel = "braille-mode Line Chart" - lc1.Data["default"] = sinps - lc1.Width = 26 - lc1.Height = 11 - lc1.X = 51 - lc1.Y = 14 - lc1.AxesColor = ui.ColorWhite - lc1.LineColor["default"] = ui.ColorYellow | ui.AttrBold + lc2 := ui.NewLineChart() + lc2.BorderLabel = "braille-mode Line Chart" + lc2.Data["default"] = sinData + lc2.Width = 26 + lc2.Height = 11 + lc2.X = 51 + lc2.Y = 14 + lc2.AxesColor = ui.ColorWhite + lc2.LineColor["default"] = ui.ColorYellow | ui.AttrBold - p1 := ui.NewPar("Hey!\nI am a borderless block!") - p1.Border = false - p1.Width = 26 - p1.Height = 2 - p1.TextFgColor = ui.ColorMagenta - p1.X = 52 - p1.Y = 11 + p2 := ui.NewPar("Hey!\nI am a borderless block!") + p2.Border = false + p2.Width = 26 + p2.Height = 2 + p2.TextFgColor = ui.ColorMagenta + p2.X = 52 + p2.Y = 11 - draw := func(t int) { - g.Percent = t % 101 - list.Items = strs[t%9:] - sp.Lines[0].Data = spdata[:30+t%50] - sp.Lines[1].Data = spdata[:35+t%50] - lc.Data["default"] = sinps[t/2%220:] - lc1.Data["default"] = sinps[2*t%220:] - bc.Data = bcdata[t/2%10:] - ui.Render(p, list, g, sp, lc, bc, lc1, p1) + draw := func(count int) { + g.Percent = count % 101 + l.Items = listData[count%9:] + sls.Lines[0].Data = sparklineData[:30+count%50] + sls.Lines[1].Data = sparklineData[:35+count%50] + lc.Data["default"] = sinData[count/2%220:] + lc2.Data["default"] = sinData[2*count%220:] + bc.Data = barchartData[count/2%10:] + + ui.Render(p, l, g, sls, lc, bc, lc2, p2) } + ui.Handle("/sys/kbd/q", func(ui.Event) { ui.StopLoop() }) + ui.Handle("/timer/1s", func(e ui.Event) { t := e.Data.(ui.EvtTimer) draw(int(t.Count)) }) + ui.Loop() } diff --git a/_examples/gauge.go b/_examples/gauge.go index d05b77e..0485241 100644 --- a/_examples/gauge.go +++ b/_examples/gauge.go @@ -6,79 +6,74 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() - //termui.UseTheme("helloworld") - - g0 := termui.NewGauge() + g0 := ui.NewGauge() g0.Percent = 40 g0.Width = 50 g0.Height = 3 g0.BorderLabel = "Slim Gauge" - g0.BarColor = termui.ColorRed - g0.BorderFg = termui.ColorWhite - g0.BorderLabelFg = termui.ColorCyan + g0.BarColor = ui.ColorRed + g0.BorderFg = ui.ColorWhite + g0.BorderLabelFg = ui.ColorCyan - gg := termui.NewBlock() + gg := ui.NewBlock() gg.Width = 50 gg.Height = 5 gg.Y = 12 gg.BorderLabel = "TEST" gg.Align() - g2 := termui.NewGauge() + g2 := ui.NewGauge() g2.Percent = 60 g2.Width = 50 g2.Height = 3 - g2.PercentColor = termui.ColorBlue + g2.PercentColor = ui.ColorBlue g2.Y = 3 g2.BorderLabel = "Slim Gauge" - g2.BarColor = termui.ColorYellow - g2.BorderFg = termui.ColorWhite + g2.BarColor = ui.ColorYellow + g2.BorderFg = ui.ColorWhite - g1 := termui.NewGauge() + g1 := ui.NewGauge() g1.Percent = 30 g1.Width = 50 g1.Height = 5 g1.Y = 6 g1.BorderLabel = "Big Gauge" - g1.PercentColor = termui.ColorYellow - g1.BarColor = termui.ColorGreen - g1.BorderFg = termui.ColorWhite - g1.BorderLabelFg = termui.ColorMagenta + g1.PercentColor = ui.ColorYellow + g1.BarColor = ui.ColorGreen + g1.BorderFg = ui.ColorWhite + g1.BorderLabelFg = ui.ColorMagenta - g3 := termui.NewGauge() + g3 := ui.NewGauge() g3.Percent = 50 g3.Width = 50 g3.Height = 3 g3.Y = 11 g3.BorderLabel = "Gauge with custom label" g3.Label = "{{percent}}% (100MBs free)" - g3.LabelAlign = termui.AlignRight + g3.LabelAlign = ui.AlignRight - g4 := termui.NewGauge() + g4 := ui.NewGauge() g4.Percent = 50 g4.Width = 50 g4.Height = 3 g4.Y = 14 g4.BorderLabel = "Gauge" g4.Label = "Gauge with custom highlighted label" - g4.PercentColor = termui.ColorYellow - g4.BarColor = termui.ColorGreen - g4.PercentColorHighlighted = termui.ColorBlack + g4.PercentColor = ui.ColorYellow + g4.BarColor = ui.ColorGreen + g4.PercentColorHighlighted = ui.ColorBlack - termui.Render(g0, g1, g2, g3, g4) + ui.Render(g0, g1, g2, g3, g4) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + ui.Loop() } diff --git a/_examples/grid.go b/_examples/grid.go index 5387f13..cf1f030 100644 --- a/_examples/grid.go +++ b/_examples/grid.go @@ -13,9 +13,7 @@ import ( ) func main() { - if err := ui.Init(); err != nil { - panic(err) - } + ui.Init() defer ui.Close() sinps := (func() []float64 { @@ -96,6 +94,7 @@ func main() { ui.Handle("/sys/kbd/q", func(ui.Event) { ui.StopLoop() }) + ui.Handle("/timer/1s", func(e ui.Event) { t := e.Data.(ui.EvtTimer) i := t.Count diff --git a/_examples/linechart.go b/_examples/linechart.go index 383e057..6697f51 100644 --- a/_examples/linechart.go +++ b/_examples/linechart.go @@ -9,17 +9,12 @@ package main import ( "math" - "github.com/gizak/termui" + ui "github.com/gizak/termui" ) func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() - - //termui.UseTheme("helloworld") + err := ui.Init() + defer ui.Close() sinps := (func() map[string][]float64 { n := 220 @@ -33,17 +28,17 @@ func main() { return ps })() - lc0 := termui.NewLineChart() + lc0 := ui.NewLineChart() lc0.BorderLabel = "braille-mode Line Chart" lc0.Data = sinps lc0.Width = 50 lc0.Height = 12 lc0.X = 0 lc0.Y = 0 - lc0.AxesColor = termui.ColorWhite - lc0.LineColor["first"] = termui.ColorGreen | termui.AttrBold + lc0.AxesColor = ui.ColorWhite + lc0.LineColor["first"] = ui.ColorGreen | ui.AttrBold - lc1 := termui.NewLineChart() + lc1 := ui.NewLineChart() lc1.BorderLabel = "dot-mode Line Chart" lc1.Mode = "dot" lc1.Data = sinps @@ -51,10 +46,10 @@ func main() { lc1.Height = 12 lc1.X = 51 lc1.DotStyle = '+' - lc1.AxesColor = termui.ColorWhite - lc1.LineColor["first"] = termui.ColorYellow | termui.AttrBold + lc1.AxesColor = ui.ColorWhite + lc1.LineColor["first"] = ui.ColorYellow | ui.AttrBold - lc2 := termui.NewLineChart() + lc2 := ui.NewLineChart() lc2.BorderLabel = "dot-mode Line Chart" lc2.Mode = "dot" lc2.Data["first"] = sinps["first"][4:] @@ -63,13 +58,14 @@ func main() { lc2.Height = 16 lc2.X = 0 lc2.Y = 12 - lc2.AxesColor = termui.ColorWhite - lc2.LineColor["first"] = termui.ColorCyan | termui.AttrBold + lc2.AxesColor = ui.ColorWhite + lc2.LineColor["first"] = ui.ColorCyan | ui.AttrBold - termui.Render(lc0, lc1, lc2) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Render(lc0, lc1, lc2) + + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + ui.Loop() } diff --git a/_examples/list.go b/_examples/list.go index 375029d..339aa75 100644 --- a/_examples/list.go +++ b/_examples/list.go @@ -6,16 +6,11 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() - - //termui.UseTheme("helloworld") + ui.Init() + defer ui.Close() strs := []string{ "[0] github.com/gizak/termui", @@ -27,18 +22,19 @@ func main() { "[6] dashboard.go", "[7] nsf/termbox-go"} - ls := termui.NewList() + ls := ui.NewList() ls.Items = strs - ls.ItemFgColor = termui.ColorYellow + ls.ItemFgColor = ui.ColorYellow ls.BorderLabel = "List" ls.Height = 7 ls.Width = 25 ls.Y = 0 - termui.Render(ls) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() - }) - termui.Loop() + ui.Render(ls) + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() + }) + + ui.Loop() } diff --git a/_examples/mbarchart.go b/_examples/mbarchart.go index 074cccf..70b7d0f 100644 --- a/_examples/mbarchart.go +++ b/_examples/mbarchart.go @@ -6,18 +6,13 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() - //termui.UseTheme("helloworld") - - bc := termui.NewMBarChart() + bc := ui.NewMBarChart() math := []int{90, 85, 90, 80} english := []int{70, 85, 75, 60} science := []int{75, 60, 80, 85} @@ -36,19 +31,20 @@ func main() { bc.ShowScale = true //Show y_axis scale value (min and max) bc.SetMax(400) - bc.TextColor = termui.ColorGreen //this is color for label (x-axis) - bc.BarColor[3] = termui.ColorGreen //BarColor for computerscience - bc.BarColor[1] = termui.ColorYellow //Bar Color for english - bc.NumColor[3] = termui.ColorRed // Num color for computerscience - bc.NumColor[1] = termui.ColorRed // num color for english + bc.TextColor = ui.ColorGreen //this is color for label (x-axis) + bc.BarColor[3] = ui.ColorGreen //BarColor for computerscience + bc.BarColor[1] = ui.ColorYellow //Bar Color for english + bc.NumColor[3] = ui.ColorRed // Num color for computerscience + bc.NumColor[1] = ui.ColorRed // num color for english //Other colors are automatically populated, btw All the students seems do well in computerscience. :p - termui.Render(bc) + ui.Render(bc) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + + ui.Loop() } diff --git a/_examples/par.go b/_examples/par.go index d340fe4..da98c8a 100644 --- a/_examples/par.go +++ b/_examples/par.go @@ -6,47 +6,43 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() - //termui.UseTheme("helloworld") - - par0 := termui.NewPar("Borderless Text") + par0 := ui.NewPar("Borderless Text") par0.Height = 1 par0.Width = 20 par0.Y = 1 par0.Border = false - par1 := termui.NewPar("你好,世界。") + par1 := ui.NewPar("你好,世界。") par1.Height = 3 par1.Width = 17 par1.X = 20 par1.BorderLabel = "标签" - par2 := termui.NewPar("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)") + par2 := ui.NewPar("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)") par2.Height = 5 par2.Width = 37 par2.Y = 4 par2.BorderLabel = "Multiline" - par2.BorderFg = termui.ColorYellow + par2.BorderFg = ui.ColorYellow - par3 := termui.NewPar("Long text with label and it is auto trimmed.") + par3 := ui.NewPar("Long text with label and it is auto trimmed.") par3.Height = 3 par3.Width = 37 par3.Y = 9 par3.BorderLabel = "Auto Trim" - termui.Render(par0, par1, par2, par3) + ui.Render(par0, par1, par2, par3) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + + ui.Loop() } diff --git a/_examples/piechart.go b/_examples/piechart.go index c3af3a8..1504625 100644 --- a/_examples/piechart.go +++ b/_examples/piechart.go @@ -8,14 +8,13 @@ import ( "math/rand" "time" - "github.com/gizak/termui" + ui "github.com/gizak/termui" ) func main() { - if err := termui.Init(); err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() + rand.Seed(time.Now().UTC().UnixNano()) randomDataAndOffset := func() (data []float64, offset float64) { noSlices := 1 + rand.Intn(5) @@ -28,7 +27,7 @@ func main() { } run := true - pc := termui.NewPieChart() + pc := ui.NewPieChart() pc.BorderLabel = "Pie Chart" pc.Width = 70 pc.Height = 36 @@ -38,26 +37,28 @@ func main() { return fmt.Sprintf("%.02f", v) } - termui.Handle("/timer/1s", func(e termui.Event) { + ui.Handle("/timer/1s", func(e ui.Event) { if run { pc.Data, pc.Offset = randomDataAndOffset() - termui.Render(pc) + ui.Render(pc) } }) - termui.Handle("/sys/kbd/s", func(termui.Event) { + ui.Handle("/sys/kbd/s", func(ui.Event) { run = !run if run { pc.BorderLabel = "Pie Chart" } else { pc.BorderLabel = "Pie Chart (Stopped)" } - termui.Render(pc) + ui.Render(pc) }) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Render(pc) - termui.Loop() + + ui.Render(pc) + + ui.Loop() } diff --git a/_examples/sparklines.go b/_examples/sparklines.go index ba4ef71..77baad7 100644 --- a/_examples/sparklines.go +++ b/_examples/sparklines.go @@ -6,64 +6,59 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() - - //termui.UseTheme("helloworld") + ui.Init() + defer ui.Close() data := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6} - spl0 := termui.NewSparkline() + spl0 := ui.NewSparkline() spl0.Data = data[3:] spl0.Title = "Sparkline 0" - spl0.LineColor = termui.ColorGreen + spl0.LineColor = ui.ColorGreen // single - spls0 := termui.NewSparklines(spl0) + spls0 := ui.NewSparklines(spl0) spls0.Height = 2 spls0.Width = 20 spls0.Border = false - spl1 := termui.NewSparkline() + spl1 := ui.NewSparkline() spl1.Data = data spl1.Title = "Sparkline 1" - spl1.LineColor = termui.ColorRed + spl1.LineColor = ui.ColorRed - spl2 := termui.NewSparkline() + spl2 := ui.NewSparkline() spl2.Data = data[5:] spl2.Title = "Sparkline 2" - spl2.LineColor = termui.ColorMagenta + spl2.LineColor = ui.ColorMagenta // group - spls1 := termui.NewSparklines(spl0, spl1, spl2) + spls1 := ui.NewSparklines(spl0, spl1, spl2) spls1.Height = 8 spls1.Width = 20 spls1.Y = 3 spls1.BorderLabel = "Group Sparklines" - spl3 := termui.NewSparkline() + spl3 := ui.NewSparkline() spl3.Data = data spl3.Title = "Enlarged Sparkline" spl3.Height = 8 - spl3.LineColor = termui.ColorYellow + spl3.LineColor = ui.ColorYellow - spls2 := termui.NewSparklines(spl3) + spls2 := ui.NewSparklines(spl3) spls2.Height = 11 spls2.Width = 30 - spls2.BorderFg = termui.ColorCyan + spls2.BorderFg = ui.ColorCyan spls2.X = 21 spls2.BorderLabel = "Tweeked Sparkline" - termui.Render(spls0, spls1, spls2) + ui.Render(spls0, spls1, spls2) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + ui.Loop() } diff --git a/_examples/table.go b/_examples/table.go index 3bd352b..b746ad7 100644 --- a/_examples/table.go +++ b/_examples/table.go @@ -6,30 +6,28 @@ package main -import "github.com/gizak/termui" +import ui "github.com/gizak/termui" func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() + rows1 := [][]string{ []string{"header1", "header2", "header3"}, []string{"你好吗", "Go-lang is so cool", "Im working on Ruby"}, []string{"2016", "10", "11"}, } - table1 := termui.NewTable() + table1 := ui.NewTable() table1.Rows = rows1 - table1.FgColor = termui.ColorWhite - table1.BgColor = termui.ColorDefault + table1.FgColor = ui.ColorWhite + table1.BgColor = ui.ColorDefault table1.Y = 0 table1.X = 0 table1.Width = 62 table1.Height = 7 - termui.Render(table1) + ui.Render(table1) rows2 := [][]string{ []string{"header1", "header2", "header3"}, @@ -37,22 +35,24 @@ func main() { []string{"2016", "11", "11"}, } - table2 := termui.NewTable() + table2 := ui.NewTable() table2.Rows = rows2 - table2.FgColor = termui.ColorWhite - table2.BgColor = termui.ColorDefault - table2.TextAlign = termui.AlignCenter + table2.FgColor = ui.ColorWhite + table2.BgColor = ui.ColorDefault + table2.TextAlign = ui.AlignCenter table2.Separator = false table2.Analysis() table2.SetSize() - table2.BgColors[2] = termui.ColorRed + table2.BgColors[2] = ui.ColorRed table2.Y = 10 table2.X = 0 table2.Border = true - termui.Render(table2) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Render(table2) + + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Loop() + + ui.Loop() } diff --git a/_examples/tabs.go b/_examples/tabs.go index 25be239..c25cf6b 100644 --- a/_examples/tabs.go +++ b/_examples/tabs.go @@ -7,36 +7,31 @@ package main import ( - "github.com/gizak/termui" + ui "github.com/gizak/termui" "github.com/gizak/termui/extra" ) func main() { - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() - //termui.UseTheme("helloworld") - - header := termui.NewPar("Press q to quit, Press j or k to switch tabs") + header := ui.NewPar("Press q to quit, Press j or k to switch tabs") header.Height = 1 header.Width = 50 header.Border = false - header.TextBgColor = termui.ColorBlue + header.TextBgColor = ui.ColorBlue tab1 := extra.NewTab("pierwszy") - par2 := termui.NewPar("Press q to quit\nPress j or k to switch tabs\n") + par2 := ui.NewPar("Press q to quit\nPress j or k to switch tabs\n") par2.Height = 5 par2.Width = 37 par2.Y = 0 par2.BorderLabel = "Keys" - par2.BorderFg = termui.ColorYellow + par2.BorderFg = ui.ColorYellow tab1.AddBlocks(par2) tab2 := extra.NewTab("drugi") - bc := termui.NewBarChart() + bc := ui.NewBarChart() data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6} bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"} bc.BorderLabel = "Bar Chart" @@ -44,9 +39,9 @@ func main() { bc.Width = 26 bc.Height = 10 bc.DataLabels = bclabels - bc.TextColor = termui.ColorGreen - bc.BarColor = termui.ColorRed - bc.NumColor = termui.ColorYellow + bc.TextColor = ui.ColorGreen + bc.BarColor = ui.ColorRed + bc.NumColor = ui.ColorYellow tab2.AddBlocks(bc) tab3 := extra.NewTab("trzeci") @@ -61,23 +56,23 @@ func main() { tabpane.SetTabs(*tab1, *tab2, *tab3, *tab4, *tab5, *tab6) - termui.Render(header, tabpane) + ui.Render(header, tabpane) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Handle("/sys/kbd/j", func(termui.Event) { + ui.Handle("/sys/kbd/j", func(ui.Event) { tabpane.SetActiveLeft() - termui.Clear() - termui.Render(header, tabpane) + ui.Clear() + ui.Render(header, tabpane) }) - termui.Handle("/sys/kbd/k", func(termui.Event) { + ui.Handle("/sys/kbd/k", func(ui.Event) { tabpane.SetActiveRight() - termui.Clear() - termui.Render(header, tabpane) + ui.Clear() + ui.Render(header, tabpane) }) - termui.Loop() + ui.Loop() } diff --git a/_examples/theme.go b/_examples/theme.go index ae0ba48..70cb8b5 100644 --- a/_examples/theme.go +++ b/_examples/theme.go @@ -13,10 +13,7 @@ import ( ) func main() { - err := ui.Init() - if err != nil { - panic(err) - } + ui.Init() defer ui.Close() // Deprecated @@ -136,12 +133,15 @@ func main() { } ui.Render(p, list, g, sp, lc, bc, lc1, p1) + ui.Handle("/sys/kbd/q", func(ui.Event) { ui.StopLoop() }) + ui.Handle("/timer/1s", func(e ui.Event) { t := e.Data.(ui.EvtTimer) draw(int(t.Count)) }) + ui.Loop() } diff --git a/_examples/ttop.go b/_examples/ttop.go index c858b35..c049e25 100644 --- a/_examples/ttop.go +++ b/_examples/ttop.go @@ -18,7 +18,7 @@ import ( "strconv" "strings" - "github.com/gizak/termui" + ui "github.com/gizak/termui" "github.com/gizak/termui/extra" ) @@ -201,23 +201,23 @@ func getMemStats() (ms MemStat, err error) { } type CpuTabElems struct { - GMap map[string]*termui.Gauge - LChart *termui.LineChart + GMap map[string]*ui.Gauge + LChart *ui.LineChart } func NewCpuTabElems(width int) *CpuTabElems { - lc := termui.NewLineChart() + lc := ui.NewLineChart() lc.Width = width lc.Height = 12 lc.X = 0 lc.Mode = "dot" lc.BorderLabel = "CPU" - return &CpuTabElems{GMap: make(map[string]*termui.Gauge), + return &CpuTabElems{GMap: make(map[string]*ui.Gauge), LChart: lc} } -func (cte *CpuTabElems) AddGauge(key string, Y int, width int) *termui.Gauge { - cte.GMap[key] = termui.NewGauge() +func (cte *CpuTabElems) AddGauge(key string, Y int, width int) *ui.Gauge { + cte.GMap[key] = ui.NewGauge() cte.GMap[key].Width = width cte.GMap[key].Height = 3 cte.GMap[key].Y = Y @@ -239,21 +239,21 @@ func (cte *CpuTabElems) Update(cs CpusStats) { } type MemTabElems struct { - Gauge *termui.Gauge - SLines *termui.Sparklines + Gauge *ui.Gauge + SLines *ui.Sparklines } func NewMemTabElems(width int) *MemTabElems { - g := termui.NewGauge() + g := ui.NewGauge() g.Width = width g.Height = 3 g.Y = 0 - sline := termui.NewSparkline() + sline := ui.NewSparkline() sline.Title = "MEM" sline.Height = 8 - sls := termui.NewSparklines(sline) + sls := ui.NewSparklines(sline) sls.Width = width sls.Height = 12 sls.Y = 3 @@ -275,21 +275,16 @@ func main() { if runtime.GOOS != "linux" { panic("Currently works only on Linux") } - err := termui.Init() - if err != nil { - panic(err) - } - defer termui.Close() + ui.Init() + defer ui.Close() termWidth := 70 - //termui.UseTheme("helloworld") - - header := termui.NewPar("Press q to quit, Press j or k to switch tabs") + header := ui.NewPar("Press q to quit, Press j or k to switch tabs") header.Height = 1 header.Width = 50 header.Border = false - header.TextBgColor = termui.ColorBlue + header.TextBgColor = ui.ColorBlue tabCpu := extra.NewTab("CPU") tabMem := extra.NewTab("MEM") @@ -333,23 +328,23 @@ func main() { tabpane.SetTabs(*tabCpu, *tabMem) - termui.Render(header, tabpane) + ui.Render(header, tabpane) - termui.Handle("/sys/kbd/q", func(termui.Event) { - termui.StopLoop() + ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.StopLoop() }) - termui.Handle("/sys/kbd/j", func(termui.Event) { + ui.Handle("/sys/kbd/j", func(ui.Event) { tabpane.SetActiveLeft() - termui.Render(header, tabpane) + ui.Render(header, tabpane) }) - termui.Handle("/sys/kbd/k", func(termui.Event) { + ui.Handle("/sys/kbd/k", func(ui.Event) { tabpane.SetActiveRight() - termui.Render(header, tabpane) + ui.Render(header, tabpane) }) - termui.Handle("/timer/1s", func(e termui.Event) { + ui.Handle("/timer/1s", func(e ui.Event) { cs, errcs := getCpusStatsMap() if errcs != nil { panic(errcs) @@ -362,8 +357,8 @@ func main() { panic(errm) } memTabElems.Update(ms) - termui.Render(header, tabpane) + ui.Render(header, tabpane) }) - termui.Loop() + ui.Loop() } diff --git a/_examples/wrapper.go b/_examples/wrapper.go index 4f6d18e..c63469b 100644 --- a/_examples/wrapper.go +++ b/_examples/wrapper.go @@ -9,11 +9,7 @@ package main import ui "github.com/gizak/termui" func main() { - - err := ui.Init() - if err != nil { - panic(err) - } + ui.Init() defer ui.Close() p := ui.NewPar("Press q to QUIT THE DEMO. [There](fg-blue) are other things [that](fg-red) are going to fit in here I think. What do you think? Now is the time for all good [men to](bg-blue) come to the aid of their country. [This is going to be one really really really long line](fg-green) that is going to go together and stuffs and things. Let's see how this thing renders out.\n Here is a new paragraph and stuffs and things. There should be a tab indent at the beginning of the paragraph. Let's see if that worked as well.") diff --git a/barchart.go b/barchart.go index 84c347a..a6e2c10 100644 --- a/barchart.go +++ b/barchart.go @@ -40,15 +40,16 @@ type BarChart struct { // NewBarChart returns a new *BarChart with current theme. func NewBarChart() *BarChart { - bc := &BarChart{Block: *NewBlock()} - bc.BarColor = ThemeAttr("barchart.bar.bg") - bc.NumColor = ThemeAttr("barchart.num.fg") - bc.TextColor = ThemeAttr("barchart.text.fg") - bc.NumFmt = func(n int) string { return fmt.Sprint(n) } - bc.BarGap = 1 - bc.BarWidth = 3 - bc.CellChar = ' ' - return bc + return &BarChart{ + Block: *NewBlock(), + BarColor: ThemeAttr("barchart.bar.bg"), + NumColor: ThemeAttr("barchart.num.fg"), + TextColor: ThemeAttr("barchart.text.fg"), + NumFmt: func(n int) string { return fmt.Sprint(n) }, + BarGap: 1, + BarWidth: 3, + CellChar: ' ', + } } func (bc *BarChart) layout() { @@ -77,7 +78,6 @@ func (bc *BarChart) layout() { } func (bc *BarChart) SetMax(max int) { - if max > 0 { bc.max = max } diff --git a/block.go b/block.go index 3e8571b..a402f9c 100644 --- a/block.go +++ b/block.go @@ -125,23 +125,23 @@ type Block struct { // NewBlock returns a *Block which inherits styles from current theme. func NewBlock() *Block { - b := Block{} - b.Display = true - b.Border = true - b.BorderLeft = true - b.BorderRight = true - b.BorderTop = true - b.BorderBottom = true - b.BorderBg = ThemeAttr("border.bg") - b.BorderFg = ThemeAttr("border.fg") - b.BorderLabelBg = ThemeAttr("label.bg") - b.BorderLabelFg = ThemeAttr("label.fg") - b.Bg = ThemeAttr("block.bg") - b.Width = 2 - b.Height = 2 - b.id = GenId() - b.Float = AlignNone - return &b + return &Block{ + Display: true, + Border: true, + BorderLeft: true, + BorderRight: true, + BorderTop: true, + BorderBottom: true, + BorderBg: ThemeAttr("border.bg"), + BorderFg: ThemeAttr("border.fg"), + BorderLabelBg: ThemeAttr("label.bg"), + BorderLabelFg: ThemeAttr("label.fg"), + Bg: ThemeAttr("block.bg"), + Width: 2, + Height: 2, + id: GenId(), + Float: AlignNone, + } } func (b Block) Id() string { diff --git a/block_test.go b/block_test.go index 8194179..9c65650 100644 --- a/block_test.go +++ b/block_test.go @@ -4,9 +4,7 @@ package termui -import ( - "testing" -) +import "testing" func TestBlockFloat(t *testing.T) { Init() diff --git a/gauge.go b/gauge.go index 9f6ce3a..7a6d748 100644 --- a/gauge.go +++ b/gauge.go @@ -43,7 +43,6 @@ func NewGauge() *Gauge { LabelAlign: AlignCenter, PercentColorHighlighted: ColorUndef, } - g.Width = 12 g.Height = 5 return g diff --git a/helper.go b/helper.go index b15496e..cf6bb64 100644 --- a/helper.go +++ b/helper.go @@ -8,9 +8,9 @@ import ( "regexp" "strings" - tm "github.com/nsf/termbox-go" + rw "github.com/mattn/go-runewidth" + tb "github.com/nsf/termbox-go" ) -import rw "github.com/mattn/go-runewidth" /* ---------------Port from termbox-go --------------------- */ @@ -59,8 +59,8 @@ const ( /* ----------------------- End ----------------------------- */ -func toTmAttr(x Attribute) tm.Attribute { - return tm.Attribute(x) +func toTmAttr(x Attribute) tb.Attribute { + return tb.Attribute(x) } func str2runes(s string) []rune { @@ -237,14 +237,14 @@ func CellsToStr(cs []Cell) string { func SetOutputMode(mode OutputMode) { switch mode { case OutputCurrent: - tm.SetOutputMode(tm.OutputCurrent) + tb.SetOutputMode(tb.OutputCurrent) case OutputNormal: - tm.SetOutputMode(tm.OutputNormal) + tb.SetOutputMode(tb.OutputNormal) case Output256: - tm.SetOutputMode(tm.Output256) + tb.SetOutputMode(tb.Output256) case Output216: - tm.SetOutputMode(tm.Output216) + tb.SetOutputMode(tb.Output216) case OutputGrayscale: - tm.SetOutputMode(tm.OutputGrayscale) + tb.SetOutputMode(tb.OutputGrayscale) } } diff --git a/linechart.go b/linechart.go index e55b6c1..0ceae45 100644 --- a/linechart.go +++ b/linechart.go @@ -79,21 +79,22 @@ type LineChart struct { // NewLineChart returns a new LineChart with current theme. func NewLineChart() *LineChart { - lc := &LineChart{Block: *NewBlock()} - lc.AxesColor = ThemeAttr("linechart.axes.fg") - lc.defaultLineColor = ThemeAttr("linechart.line.fg") - lc.Mode = "braille" - lc.DotStyle = '•' - lc.Data = make(map[string][]float64) - lc.LineColor = make(map[string]Attribute) - lc.axisXLabelGap = 2 - lc.axisYLabelGap = 1 - lc.bottomValue = math.Inf(1) - lc.topValue = math.Inf(-1) - lc.YPadding = 0.2 - lc.YFloor = math.Inf(-1) - lc.YCeil = math.Inf(1) - return lc + return &LineChart{ + Block: *NewBlock(), + AxesColor: ThemeAttr("linechart.axes.fg"), + defaultLineColor: ThemeAttr("linechart.line.fg"), + Mode: "braille", + DotStyle: '•', + Data: make(map[string][]float64), + LineColor: make(map[string]Attribute), + axisXLabelGap: 2, + axisYLabelGap: 1, + bottomValue: math.Inf(1), + topValue: math.Inf(-1), + YPadding: 0.2, + YFloor: math.Inf(-1), + YCeil: math.Inf(1), + } } // one cell contains two data points, so capicity is 2x dot mode diff --git a/list.go b/list.go index 5a59215..441d48b 100644 --- a/list.go +++ b/list.go @@ -39,11 +39,12 @@ type List struct { // NewList returns a new *List with current theme. func NewList() *List { - l := &List{Block: *NewBlock()} - l.Overflow = "hidden" - l.ItemFgColor = ThemeAttr("list.item.fg") - l.ItemBgColor = ThemeAttr("list.item.bg") - return l + return &List{ + Block: *NewBlock(), + Overflow: "hidden", + ItemFgColor: ThemeAttr("list.item.fg"), + ItemBgColor: ThemeAttr("list.item.bg"), + } } // Buffer implements Bufferer interface. @@ -85,5 +86,6 @@ func (l *List) Buffer() Buffer { } } } + return buf } diff --git a/mbarchart.go b/mbarchart.go index b3f774b..a9df9cf 100644 --- a/mbarchart.go +++ b/mbarchart.go @@ -46,16 +46,18 @@ type MBarChart struct { maxScale []rune } -// NewBarChart returns a new *BarChart with current theme. +// NewMBarChart returns a new *MBarChart with current theme. func NewMBarChart() *MBarChart { - bc := &MBarChart{Block: *NewBlock()} - bc.BarColor[0] = ThemeAttr("mbarchart.bar.bg") - bc.NumColor[0] = ThemeAttr("mbarchart.num.fg") - bc.TextColor = ThemeAttr("mbarchart.text.fg") - bc.NumFmt = func(n int) string { return fmt.Sprint(n) } - bc.BarGap = 1 - bc.BarWidth = 3 - return bc + mbc := &MBarChart{ + Block: *NewBlock(), + TextColor: ThemeAttr("mbarchart.text.fg"), + NumFmt: func(n int) string { return fmt.Sprint(n) }, + BarGap: 1, + BarWidth: 3, + } + mbc.BarColor[0] = ThemeAttr("mbarchart.bar.bg") + mbc.NumColor[0] = ThemeAttr("mbarchart.num.fg") + return mbc } func (bc *MBarChart) layout() { @@ -139,7 +141,6 @@ func (bc *MBarChart) layout() { } func (bc *MBarChart) SetMax(max int) { - if max > 0 { bc.max = max } @@ -148,7 +149,9 @@ func (bc *MBarChart) SetMax(max int) { // Buffer implements Bufferer interface. func (bc *MBarChart) Buffer() Buffer { buf := bc.Block.Buffer() + bc.layout() + var oftX int for i := 0; i < bc.numBar && i < bc.minDataLen && i < len(bc.DataLabels); i++ { diff --git a/render.go b/render.go index 999e632..efea961 100644 --- a/render.go +++ b/render.go @@ -10,7 +10,7 @@ import ( "sync" "time" - tm "github.com/nsf/termbox-go" + tb "github.com/nsf/termbox-go" ) // Bufferer should be implemented by all renderable components. @@ -21,10 +21,10 @@ type Bufferer interface { // Init initializes termui library. This function should be called before any others. // After initialization, the library must be finalized by 'Close' function. func Init() error { - if err := tm.Init(); err != nil { + if err := tb.Init(); err != nil { return err } - tm.SetInputMode(tm.InputEsc | tm.InputMouse) + tb.SetInputMode(tb.InputEsc | tb.InputMouse) DefaultEvtStream = NewEvtStream() sysEvtChs = make([]chan Event, 0) @@ -65,15 +65,15 @@ func Init() error { // Close finalizes termui library, // should be called after successful initialization when termui's functionality isn't required anymore. func Close() { - tm.Close() + tb.Close() } var renderLock sync.Mutex func termSync() { renderLock.Lock() - tm.Sync() - termWidth, termHeight = tm.Size() + tb.Sync() + termWidth, termHeight = tb.Size() renderLock.Unlock() } @@ -105,7 +105,7 @@ func render(bs ...Bufferer) { for p, c := range buf.CellMap { if p.In(buf.Area) { - tm.SetCell(p.X, p.Y, c.Ch, toTmAttr(c.Fg), toTmAttr(c.Bg)) + tb.SetCell(p.X, p.Y, c.Ch, toTmAttr(c.Fg), toTmAttr(c.Bg)) } } @@ -114,25 +114,25 @@ func render(bs ...Bufferer) { renderLock.Lock() // render - tm.Flush() + tb.Flush() renderLock.Unlock() } func Clear() { - tm.Clear(tm.ColorDefault, toTmAttr(ThemeAttr("bg"))) + tb.Clear(tb.ColorDefault, toTmAttr(ThemeAttr("bg"))) } func clearArea(r image.Rectangle, bg Attribute) { for i := r.Min.X; i < r.Max.X; i++ { for j := r.Min.Y; j < r.Max.Y; j++ { - tm.SetCell(i, j, ' ', tm.ColorDefault, toTmAttr(bg)) + tb.SetCell(i, j, ' ', tb.ColorDefault, toTmAttr(bg)) } } } func ClearArea(r image.Rectangle, bg Attribute) { clearArea(r, bg) - tm.Flush() + tb.Flush() } var renderJobs chan []Bufferer diff --git a/sparkline.go b/sparkline.go index 75e7c52..6fb5393 100644 --- a/sparkline.go +++ b/sparkline.go @@ -53,8 +53,7 @@ func NewSparkline() Sparkline { // NewSparklines return a new *Sparklines with given Sparkline(s), you can always add a new Sparkline later. func NewSparklines(ss ...Sparkline) *Sparklines { - s := &Sparklines{Block: *NewBlock(), Lines: ss} - return s + return &Sparklines{Block: *NewBlock(), Lines: ss} } func (sl *Sparklines) update() { diff --git a/table.go b/table.go index 40351a5..5f212e3 100644 --- a/table.go +++ b/table.go @@ -51,11 +51,12 @@ type Table struct { // NewTable returns a new Table instance func NewTable() *Table { - table := &Table{Block: *NewBlock()} - table.FgColor = ColorWhite - table.BgColor = ColorDefault - table.Separator = true - return table + return &Table{ + Block: *NewBlock(), + FgColor: ColorWhite, + BgColor: ColorDefault, + Separator: true, + } } // CellsWidth calculates the width of a cell array and returns an int diff --git a/theme.go b/theme.go index 70f5024..c5c719d 100644 --- a/theme.go +++ b/theme.go @@ -103,7 +103,6 @@ func ThemeAttr(name string) Attribute { } func lookUpAttr(clrmap map[string]Attribute, name string) Attribute { - a, ok := clrmap[name] if ok { return a diff --git a/widget.go b/widget.go index 80276bf..5a0d606 100644 --- a/widget.go +++ b/widget.go @@ -33,7 +33,6 @@ func NewWgtInfo(wgt Widget) WgtInfo { func NewWgtMgr() WgtMgr { wm := WgtMgr(make(map[string]WgtInfo)) return wm - } func (wm WgtMgr) AddWgt(wgt Widget) {