From f4dc75130fd6469e08213dcbd5ff0d7ebe32bf98 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 6 Sep 2018 16:55:27 -0700 Subject: [PATCH] Update README and fix _examples links --- README.md | 37 +++++++++++++++++++++---------------- _examples/theme.go | 16 ++++++++-------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0422341..0aaa55b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # termui [![Build Status](https://travis-ci.org/gizak/termui.svg?branch=master)](https://travis-ci.org/gizak/termui) [![Doc Status](https://godoc.org/github.com/gizak/termui?status.png)](https://godoc.org/github.com/gizak/termui) -demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.) +demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.) `termui` is a cross-platform, easy-to-compile, and fully-customizable terminal dashboard. It is inspired by [blessed-contrib](https://github.com/yaronn/blessed-contrib), but purely in Go. @@ -10,13 +10,17 @@ Now version v2 has arrived! It brings new event system, new theme system, new `B `master` mirrors v2 branch, to install: - go get -u github.com/gizak/termui +```bash +go get -u github.com/gizak/termui +``` It is recommanded to use locked deps by using [dep](https://golang.github.io/dep/): move to `termui` src directory then run `dep ensure`. For the compatible reason, you can choose to install the legacy version of `termui`: - go get gopkg.in/gizak/termui.v1 +```bash +go get gopkg.in/gizak/termui.v1 +``` ## Usage @@ -24,11 +28,11 @@ For the compatible reason, you can choose to install the legacy version of `term To use `termui`, the very first thing you may want to know is how to manage layout. `termui` offers two ways of doing this, known as absolute layout and grid layout. -__Absolute layout__ +**Absolute layout** Each widget has an underlying block structure which basically is a box model. It has border, label and padding properties. A border of a widget can be chosen to hide or display (with its border label), you can pick a different front/back colour for the border as well. To display such a widget at a specific location in terminal window, you need to assign `.X`, `.Y`, `.Height`, `.Width` values for each widget before sending it to `.Render`. Let's demonstrate these by a code snippet: -`````go +```go import ui "github.com/gizak/termui" // <- ui shortcut, optional func main() { @@ -59,13 +63,13 @@ Each widget has an underlying block structure which basically is a box model. It // event handler... } -````` +``` Note that components can be overlapped (I'd rather call this a feature...), `Render(rs ...Renderer)` renders its args from left to right (i.e. each component's weight is arising from left to right). -__Grid layout:__ +**Grid layout:** -grid +grid Grid layout uses [12 columns grid system](http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp) with expressive syntax. To use `Grid`, all we need to do is build a widget tree consisting of `Row`s and `Col`s (Actually a `Col` is also a `Row` but with a widget endpoint attached). @@ -124,14 +128,14 @@ Grid layout uses [12 columns grid system](http://www.w3schools.com/bootstrap/boo Click image to see the corresponding demo codes. -[par](https://github.com/gizak/termui/blob/master/_example/par.go) -[list](https://github.com/gizak/termui/blob/master/_example/list.go) -[gauge](https://github.com/gizak/termui/blob/master/_example/gauge.go) -[linechart](https://github.com/gizak/termui/blob/master/_example/linechart.go) -[barchart](https://github.com/gizak/termui/blob/master/_example/barchart.go) -[barchart](https://github.com/gizak/termui/blob/master/_example/mbarchart.go) -[sparklines](https://github.com/gizak/termui/blob/master/_example/sparklines.go) -[table](https://github.com/gizak/termui/blob/master/_example/table.go) +[par](https://github.com/gizak/termui/blob/master/_examples/par.go) +[list](https://github.com/gizak/termui/blob/master/_examples/list.go) +[gauge](https://github.com/gizak/termui/blob/master/_examples/gauge.go) +[linechart](https://github.com/gizak/termui/blob/master/_examples/linechart.go) +[barchart](https://github.com/gizak/termui/blob/master/_examples/barchart.go) +[barchart](https://github.com/gizak/termui/blob/master/_examples/mbarchart.go) +[sparklines](https://github.com/gizak/termui/blob/master/_examples/sparklines.go) +[table](https://github.com/gizak/termui/blob/master/_examples/table.go) ## GoDoc @@ -148,4 +152,5 @@ Click image to see the corresponding demo codes. ## Changelog ## License + This library is under the [MIT License](http://opensource.org/licenses/MIT) diff --git a/_examples/theme.go b/_examples/theme.go index 1cc1659..0f45947 100644 --- a/_examples/theme.go +++ b/_examples/theme.go @@ -122,14 +122,14 @@ func main() { p1.X = 52 p1.Y = 11 - draw := func(t int) { - g.Percent = t % 101 - list.Items = strs[t%9:] - sp.Lines[0].Data = spdata[t%10:] - sp.Lines[1].Data = spdata[t/2%10:] - lc.Data["default"] = sinps[t/2:] - lc1.Data["default"] = rndwalk[t:] - bc.Data = bcdata[t/2%10:] + draw := func(count int) { + g.Percent = count % 101 + list.Items = strs[count%9:] + sp.Lines[0].Data = spdata[count%10:] + sp.Lines[1].Data = spdata[count/2%10:] + lc.Data["default"] = sinps[count/2:] + lc1.Data["default"] = rndwalk[count:] + bc.Data = bcdata[count/2%10:] ui.Render(p, list, g, sp, lc, bc, lc1, p1) }