mirror of
https://github.com/mum4k/termdash.git
synced 2025-05-08 19:29:25 +08:00
Merge pull request #258 from mum4k/tcell-default
Making tcell the default in all demos and examples.
This commit is contained in:
commit
0f1d104694
@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Changed
|
||||
|
||||
- `tcell` dependency was upgraded 1.4.0.
|
||||
- made `tcell` terminal implementation the default in examples, demos and
|
||||
documentation.
|
||||
- upgrading versions on all dependencies.
|
||||
- terminal cells now support font modifier options (bold, italic,
|
||||
underline, strikethrough)
|
||||
@ -23,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- addressing some lint issues.
|
||||
- coveralls again triggers and reports on PRs.
|
||||
- improving test coverage in some modules.
|
||||
- changing the Blue color in demos to a more readable shade.
|
||||
|
||||
## [0.12.2] - 31-Aug-2020
|
||||
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
"github.com/mum4k/termdash/private/draw/testdraw"
|
||||
"github.com/mum4k/termdash/private/faketerm"
|
||||
"github.com/mum4k/termdash/private/fakewidget"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/widgetapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
)
|
||||
@ -38,11 +38,11 @@ import (
|
||||
// Shows how to create a simple 4x4 grid with four widgets.
|
||||
// All the cells in the grid contain the same widget in this example.
|
||||
func Example() {
|
||||
tbx, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer tbx.Close()
|
||||
defer t.Close()
|
||||
|
||||
bc, err := barchart.New()
|
||||
if err != nil {
|
||||
@ -67,14 +67,14 @@ func Example() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cont, err := container.New(tbx, gridOpts...)
|
||||
cont, err := container.New(t, gridOpts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if err := termdash.Run(ctx, tbx, cont); err != nil {
|
||||
if err := termdash.Run(ctx, t, cont); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@ -82,11 +82,11 @@ func Example() {
|
||||
// Shows how to create rows iteratively. Each row contains two columns and each
|
||||
// column contains the same widget.
|
||||
func Example_iterative() {
|
||||
tbx, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer tbx.Close()
|
||||
defer t.Close()
|
||||
|
||||
bc, err := barchart.New()
|
||||
if err != nil {
|
||||
@ -108,14 +108,14 @@ func Example_iterative() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cont, err := container.New(tbx, gridOpts...)
|
||||
cont, err := container.New(t, gridOpts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if err := termdash.Run(ctx, tbx, cont); err != nil {
|
||||
if err := termdash.Run(ctx, t, cont); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
"github.com/mum4k/termdash/private/event/testevent"
|
||||
"github.com/mum4k/termdash/private/faketerm"
|
||||
"github.com/mum4k/termdash/private/fakewidget"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgetapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
@ -42,7 +42,7 @@ import (
|
||||
// Example shows how to setup and run termdash with periodic redraw.
|
||||
func Example() {
|
||||
// Create the terminal.
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -86,7 +86,7 @@ func Example() {
|
||||
// Example shows how to setup and run termdash with manually triggered redraw.
|
||||
func Example_triggered() {
|
||||
// Create the terminal.
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -477,8 +477,8 @@ const (
|
||||
|
||||
func main() {
|
||||
terminalPtr := flag.String("terminal",
|
||||
"termbox",
|
||||
"The terminal implementation to use. Available implementations are 'termbox' and 'tcell' (default = termbox).")
|
||||
"tcell",
|
||||
"The terminal implementation to use. Available implementations are 'termbox' and 'tcell' (default = tcell).")
|
||||
flag.Parse()
|
||||
|
||||
var t terminalapi.Terminal
|
||||
@ -569,7 +569,7 @@ func textState(text string, capacity, step int) []rune {
|
||||
// SegmentDisplay.
|
||||
func newTextInput(updateText chan<- string) (*textinput.TextInput, error) {
|
||||
input, err := textinput.New(
|
||||
textinput.Label("Change text to: ", cell.FgColor(cell.ColorBlue)),
|
||||
textinput.Label("Change text to: ", cell.FgColor(cell.ColorNumber(33))),
|
||||
textinput.MaxWidthCells(20),
|
||||
textinput.PlaceHolder("enter any text"),
|
||||
textinput.OnSubmit(func(text string) error {
|
||||
@ -593,10 +593,10 @@ func newSegmentDisplay(ctx context.Context, updateText <-chan string) (*segmentd
|
||||
}
|
||||
|
||||
colors := []cell.Color{
|
||||
cell.ColorBlue,
|
||||
cell.ColorNumber(33),
|
||||
cell.ColorRed,
|
||||
cell.ColorYellow,
|
||||
cell.ColorBlue,
|
||||
cell.ColorNumber(33),
|
||||
cell.ColorGreen,
|
||||
cell.ColorRed,
|
||||
cell.ColorGreen,
|
||||
@ -854,7 +854,7 @@ func newSines(ctx context.Context) (left, right *button.Button, lc *linechart.Li
|
||||
go periodic(ctx, redrawInterval/3, func() error {
|
||||
step1 = (step1 + 1) % len(inputs)
|
||||
if err := lc.Series("first", rotateFloats(inputs, step1),
|
||||
linechart.SeriesCellOpts(cell.FgColor(cell.ColorBlue)),
|
||||
linechart.SeriesCellOpts(cell.FgColor(cell.ColorNumber(33))),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
// Package termbox implements terminal using the nsf/termbox-go library.
|
||||
// Prefer to use tcell instead, nsf/termbox-go is no longer maintained.
|
||||
package termbox
|
||||
|
||||
import (
|
||||
@ -52,6 +53,9 @@ func ColorMode(cm terminalapi.ColorMode) Option {
|
||||
|
||||
// Terminal provides input and output to a real terminal. Wraps the
|
||||
// nsf/termbox-go terminal implementation. This object is not thread-safe.
|
||||
//
|
||||
// Prefer to use tcell instead, nsf/termbox-go is no longer maintained.
|
||||
//
|
||||
// Implements terminalapi.Terminal.
|
||||
type Terminal struct {
|
||||
// events is a queue of input events.
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
)
|
||||
@ -56,7 +56,7 @@ func playBarChart(ctx context.Context, bc *barchart.BarChart, delay time.Duratio
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -75,10 +75,10 @@ func main() {
|
||||
barchart.ValueColors([]cell.Color{
|
||||
cell.ColorRed,
|
||||
cell.ColorYellow,
|
||||
cell.ColorBlue,
|
||||
cell.ColorNumber(33),
|
||||
cell.ColorGreen,
|
||||
cell.ColorRed,
|
||||
cell.ColorBlue,
|
||||
cell.ColorNumber(33),
|
||||
}),
|
||||
barchart.ShowValues(),
|
||||
barchart.BarWidth(8),
|
||||
|
@ -25,14 +25,14 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/button"
|
||||
"github.com/mum4k/termdash/widgets/segmentdisplay"
|
||||
)
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/donut"
|
||||
)
|
||||
@ -79,7 +79,7 @@ func playDonut(ctx context.Context, d *donut.Donut, start, step int, delay time.
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -95,7 +95,7 @@ func main() {
|
||||
}
|
||||
go playDonut(ctx, green, 0, 1, 250*time.Millisecond, playTypePercent)
|
||||
|
||||
blue, err := donut.New(donut.CellOpts(cell.FgColor(cell.ColorBlue)))
|
||||
blue, err := donut.New(donut.CellOpts(cell.FgColor(cell.ColorNumber(33))))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/gauge"
|
||||
)
|
||||
@ -79,7 +79,7 @@ func playGauge(ctx context.Context, g *gauge.Gauge, step int, delay time.Duratio
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -98,7 +98,7 @@ func main() {
|
||||
|
||||
absolute, err := gauge.New(
|
||||
gauge.Height(1),
|
||||
gauge.Color(cell.ColorBlue),
|
||||
gauge.Color(cell.ColorNumber(33)),
|
||||
gauge.Border(linestyle.Light),
|
||||
gauge.BorderTitle("Absolute progress"),
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/linechart"
|
||||
)
|
||||
@ -53,7 +53,7 @@ func playLineChart(ctx context.Context, lc *linechart.LineChart, delay time.Dura
|
||||
i = (i + 1) % len(inputs)
|
||||
rotated := append(inputs[i:], inputs[:i]...)
|
||||
if err := lc.Series("first", rotated,
|
||||
linechart.SeriesCellOpts(cell.FgColor(cell.ColorBlue)),
|
||||
linechart.SeriesCellOpts(cell.FgColor(cell.ColorNumber(33))),
|
||||
linechart.SeriesXLabels(map[int]string{
|
||||
0: "zero",
|
||||
}),
|
||||
@ -74,7 +74,7 @@ func playLineChart(ctx context.Context, lc *linechart.LineChart, delay time.Dura
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/segmentdisplay"
|
||||
)
|
||||
@ -46,7 +46,7 @@ func clock(ctx context.Context, sd *segmentdisplay.SegmentDisplay) {
|
||||
spacer = ":"
|
||||
}
|
||||
chunks := []*segmentdisplay.TextChunk{
|
||||
segmentdisplay.NewChunk(parts[0], segmentdisplay.WriteCellOpts(cell.FgColor(cell.ColorBlue))),
|
||||
segmentdisplay.NewChunk(parts[0], segmentdisplay.WriteCellOpts(cell.FgColor(cell.ColorNumber(33)))),
|
||||
segmentdisplay.NewChunk(spacer),
|
||||
segmentdisplay.NewChunk(parts[1], segmentdisplay.WriteCellOpts(cell.FgColor(cell.ColorRed))),
|
||||
}
|
||||
@ -74,10 +74,10 @@ func rotate(inputs []rune, step int) []rune {
|
||||
func rollText(ctx context.Context, sd *segmentdisplay.SegmentDisplay) {
|
||||
const text = "Termdash"
|
||||
colors := map[rune]cell.Color{
|
||||
'T': cell.ColorBlue,
|
||||
'T': cell.ColorNumber(33),
|
||||
'e': cell.ColorRed,
|
||||
'r': cell.ColorYellow,
|
||||
'm': cell.ColorBlue,
|
||||
'm': cell.ColorNumber(33),
|
||||
'd': cell.ColorGreen,
|
||||
'a': cell.ColorRed,
|
||||
's': cell.ColorGreen,
|
||||
@ -113,7 +113,7 @@ func rollText(ctx context.Context, sd *segmentdisplay.SegmentDisplay) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/sparkline"
|
||||
)
|
||||
@ -76,7 +76,7 @@ func fillSparkLine(ctx context.Context, sl *sparkline.SparkLine, delay time.Dura
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -84,7 +84,7 @@ func main() {
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
green, err := sparkline.New(
|
||||
sparkline.Label("Green SparkLine", cell.FgColor(cell.ColorBlue)),
|
||||
sparkline.Label("Green SparkLine", cell.FgColor(cell.ColorNumber(33))),
|
||||
sparkline.Color(cell.ColorGreen),
|
||||
)
|
||||
if err != nil {
|
||||
@ -92,7 +92,7 @@ func main() {
|
||||
}
|
||||
go playSparkLine(ctx, green, 250*time.Millisecond)
|
||||
red, err := sparkline.New(
|
||||
sparkline.Label("Red SparkLine", cell.FgColor(cell.ColorBlue)),
|
||||
sparkline.Label("Red SparkLine", cell.FgColor(cell.ColorNumber(33))),
|
||||
sparkline.Color(cell.ColorRed),
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -106,7 +106,7 @@ func main() {
|
||||
if err := wrapped.Write("Supports", text.WriteCellOpts(cell.FgColor(cell.ColorRed))); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := wrapped.Write(" colors", text.WriteCellOpts(cell.FgColor(cell.ColorBlue))); err != nil {
|
||||
if err := wrapped.Write(" colors", text.WriteCellOpts(cell.FgColor(cell.ColorNumber(33)))); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := wrapped.Write(" and"); err != nil {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"github.com/mum4k/termdash/container/grid"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/tcell"
|
||||
"github.com/mum4k/termdash/widgets/button"
|
||||
"github.com/mum4k/termdash/widgets/segmentdisplay"
|
||||
"github.com/mum4k/termdash/widgets/textinput"
|
||||
@ -60,10 +60,10 @@ func textState(text string, capacity, step int) []rune {
|
||||
// Exists when the context expires.
|
||||
func rollText(ctx context.Context, sd *segmentdisplay.SegmentDisplay, updateText <-chan string) {
|
||||
colors := []cell.Color{
|
||||
cell.ColorBlue,
|
||||
cell.ColorNumber(33),
|
||||
cell.ColorRed,
|
||||
cell.ColorYellow,
|
||||
cell.ColorBlue,
|
||||
cell.ColorNumber(33),
|
||||
cell.ColorGreen,
|
||||
cell.ColorRed,
|
||||
cell.ColorGreen,
|
||||
@ -110,7 +110,7 @@ func rollText(ctx context.Context, sd *segmentdisplay.SegmentDisplay, updateText
|
||||
}
|
||||
|
||||
func main() {
|
||||
t, err := termbox.New()
|
||||
t, err := tcell.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -127,7 +127,7 @@ func main() {
|
||||
go rollText(ctx, rollingSD, updateText)
|
||||
|
||||
input, err := textinput.New(
|
||||
textinput.Label("New text:", cell.FgColor(cell.ColorBlue)),
|
||||
textinput.Label("New text:", cell.FgColor(cell.ColorNumber(33))),
|
||||
textinput.MaxWidthCells(20),
|
||||
textinput.Border(linestyle.Light),
|
||||
textinput.PlaceHolder("Enter any text"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user