Skip to content

Commit fbd21e7

Browse files
authored
Merge pull request #266 from mum4k/release-0-13
Releasing Termdash v0.13.
2 parents 2a7dafa + 2fc684f commit fbd21e7

File tree

34 files changed

+783
-211
lines changed

34 files changed

+783
-211
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ go:
33
- 1.14.x
44
- 1.15.x
55
- stable
6+
before_install:
7+
- go get github.com/mattn/goveralls
68
script:
79
- go get -t ./...
810
- go get -u golang.org/x/lint/golint
@@ -12,6 +14,8 @@ script:
1214
- diff -u <(echo -n) <(gofmt -d -s .)
1315
- diff -u <(echo -n) <(./internal/scripts/autogen_licences.sh .)
1416
- diff -u <(echo -n) <(golint ./...)
17+
- $GOPATH/bin/goveralls -service=travis-pro
1518
env:
1619
global:
1720
- CGO_ENABLED=0
21+
- secure: VOOh/w2YNAn+psiWYjIOQ5ZhhMb6Wz7zzmhIlj0dc5mGQztFAX5TuNWOU5JokvOigFy18JhPeDJRmp661xqM4gy1Znx1odSXES3YdCwt42pmpjYIkI9lI09xTRH6WYIRmYfCHe4J3A9/CWLeDRaAU1e+YqmNyraaGzE82ouUPH/I4A9gur4j4j6t1X/t0iovyd/4qNDsetUPevQsJS224Pv6Xhg3LGnSAXMPM+tu0t3UeEfRu/l9OgP6/bnet9BUx0BryFCVJp6fAtq7x61+WRIJesugrhHVgl/dz8CgFsVjRkqWQSNnZvt07dHNOX0mZj2U22OAkH+9ZN93wScs3bDZFXozrta7eOWhrJLcJTMrAxdHYMNKmoXqQQ0TGFV/L9blOtT8uj9US3wxeD11s4TyZePWIC5hnpUsNFoGPsBB45uwW2TSwvTTEL9bxWWzjYzSkLG5P6Kk4/JkeMh3OMFCM/LutX8QDch1n/s0CfXdy7qgh5G4I9ZhGTU+huJlumeuM4U+my0EPnA3uclJ97cw0n6K7MKwKCTTA8La2ifATunKC/U4Hjo1rf9DxofIrRIvwV5zEUIn1r6ut5fO+o+MWDupkvsMqIA7QJyCLhRp+pAlPWGDZLdrFEicN/kpULH4IGUIPn532gXzEOAG+Aq0WYDVPXGLSifSyxafiDk=

CHANGELOG.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.13.0] - 17-Nov-2020
11+
12+
### Added
13+
14+
- the `Text` widget now allows user to specify custom scroll marker runes.
15+
16+
### Changed
17+
18+
- terminal cells now support font modifier options (bold, italic,
19+
underline, strike through).
20+
- `tcell` dependency was upgraded to v2.0.0.
21+
- upgraded versions of all other dependencies.
22+
- aligned the definition of the first 16 colors with the definition used by
23+
Xterm and `tcell`. Defined two non-standard colors `ColorMagenta` and
24+
`ColorCyan` to make this change backward compatible for users that use
25+
`termbox-go`.
26+
- made `tcell` terminal implementation the default in examples, demos and
27+
documentation.
28+
29+
### Fixed
30+
31+
- coveralls again triggers and reports on PRs.
32+
- addressed some lint issues.
33+
- improved test coverage in some modules.
34+
- changed the Blue color in demos to a more visible shade.
35+
- fixed a bug where segment display text in `termdashdemo` appeared to be
36+
jumping.
37+
1038
## [0.12.2] - 31-Aug-2020
1139

1240
### Fixed
@@ -69,7 +97,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6997
- The `SegmentDisplay` can now display dots and colons ('.' and ':').
7098
- The `Donut` widget now guarantees spacing between the donut and its label.
7199
- The continuous build on Travis CI now builds with cgo explicitly disabled to
72-
ensure both Termdash and its dependencies use pure Go.
100+
ensure both Termdash and its dependencies use pure Go.
73101

74102
### Fixed
75103

@@ -341,7 +369,8 @@ identifiers shouldn't be used externally.
341369
- The Gauge widget.
342370
- The Text widget.
343371

344-
[unreleased]: https://github.com/mum4k/termdash/compare/v0.12.2...devel
372+
[unreleased]: https://github.com/mum4k/termdash/compare/v0.13.0...devel
373+
[0.13.0]: https://github.com/mum4k/termdash/compare/v0.12.2...v0.13.0
345374
[0.12.2]: https://github.com/mum4k/termdash/compare/v0.12.1...v0.12.2
346375
[0.12.1]: https://github.com/mum4k/termdash/compare/v0.12.0...v0.12.1
347376
[0.12.0]: https://github.com/mum4k/termdash/compare/v0.11.0...v0.12.0

cell/cell.go

+50-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ type Option interface {
2323

2424
// Options stores the provided options.
2525
type Options struct {
26-
FgColor Color
27-
BgColor Color
26+
FgColor Color
27+
BgColor Color
28+
Bold bool
29+
Italic bool
30+
Underline bool
31+
Strikethrough bool
32+
Inverse bool
33+
Blink bool
2834
}
2935

3036
// Set allows existing options to be passed as an option.
@@ -62,3 +68,45 @@ func BgColor(color Color) Option {
6268
co.BgColor = color
6369
})
6470
}
71+
72+
// Bold makes cell's text bold.
73+
func Bold() Option {
74+
return option(func(co *Options) {
75+
co.Bold = true
76+
})
77+
}
78+
79+
// Italic makes cell's text italic. Only works when using the tcell backend.
80+
func Italic() Option {
81+
return option(func(co *Options) {
82+
co.Italic = true
83+
})
84+
}
85+
86+
// Underline makes cell's text underlined.
87+
func Underline() Option {
88+
return option(func(co *Options) {
89+
co.Underline = true
90+
})
91+
}
92+
93+
// Strikethrough strikes through the cell's text. Only works when using the tcell backend.
94+
func Strikethrough() Option {
95+
return option(func(co *Options) {
96+
co.Strikethrough = true
97+
})
98+
}
99+
100+
// Inverse inverts the colors of the cell's text.
101+
func Inverse() Option {
102+
return option(func(co *Options) {
103+
co.Inverse = true
104+
})
105+
}
106+
107+
// Blink makes the cell's text blink. Only works when using the tcell backend.
108+
func Blink() Option {
109+
return option(func(co *Options) {
110+
co.Blink = true
111+
})
112+
}

cell/cell_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestNewOptions(t *testing.T) {
2727
want *Options
2828
}{
2929
{
30+
3031
desc: "no provided options",
3132
want: &Options{},
3233
},
@@ -72,6 +73,25 @@ func TestNewOptions(t *testing.T) {
7273
BgColor: ColorMagenta,
7374
},
7475
},
76+
{
77+
desc: "setting font attributes",
78+
opts: []Option{
79+
Bold(),
80+
Italic(),
81+
Underline(),
82+
Strikethrough(),
83+
Inverse(),
84+
Blink(),
85+
},
86+
want: &Options{
87+
Bold: true,
88+
Italic: true,
89+
Underline: true,
90+
Strikethrough: true,
91+
Inverse: true,
92+
Blink: true,
93+
},
94+
},
7595
}
7696

7797
for _, tc := range tests {

cell/color.go

+21-4
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,32 @@ var colorNames = map[Color]string{
4848
const (
4949
ColorDefault Color = iota
5050

51-
// 8 "system" colors.
51+
// The 16 Xterm colors.
52+
// See https://jonasjacek.github.io/colors/
5253
ColorBlack
53-
ColorRed
54+
ColorMaroon
5455
ColorGreen
56+
ColorOlive
57+
ColorNavy
58+
ColorPurple
59+
ColorTeal
60+
ColorSilver
61+
ColorGray
62+
ColorRed
63+
ColorLime
5564
ColorYellow
5665
ColorBlue
57-
ColorMagenta
58-
ColorCyan
66+
ColorFuchsia
67+
ColorAqua
5968
ColorWhite
6069
)
6170

71+
// Colors defined for backward compatibility with termbox-go.
72+
const (
73+
ColorMagenta Color = ColorPurple
74+
ColorCyan Color = ColorTeal
75+
)
76+
6277
// ColorNumber sets a color using its number.
6378
// Make sure your terminal is set to a terminalapi.ColorMode that supports the
6479
// target color. The provided value must be in the range 0-255.
@@ -86,6 +101,8 @@ func ColorRGB6(r, g, b int) Color {
86101
return ColorDefault
87102
}
88103
}
104+
// Explanation:
105+
// https://stackoverflow.com/questions/27159322/rgb-values-of-the-colors-in-the-ansi-extended-colors-index-17-255
89106
return Color(0x10 + 36*r + 6*g + b + 1) // Colors are off-by-one due to ColorDefault being zero.
90107
}
91108

container/grid/grid_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ import (
3030
"github.com/mum4k/termdash/private/draw/testdraw"
3131
"github.com/mum4k/termdash/private/faketerm"
3232
"github.com/mum4k/termdash/private/fakewidget"
33-
"github.com/mum4k/termdash/terminal/termbox"
33+
"github.com/mum4k/termdash/terminal/tcell"
3434
"github.com/mum4k/termdash/widgetapi"
3535
"github.com/mum4k/termdash/widgets/barchart"
3636
)
3737

3838
// Shows how to create a simple 4x4 grid with four widgets.
3939
// All the cells in the grid contain the same widget in this example.
4040
func Example() {
41-
tbx, err := termbox.New()
41+
t, err := tcell.New()
4242
if err != nil {
4343
panic(err)
4444
}
45-
defer tbx.Close()
45+
defer t.Close()
4646

4747
bc, err := barchart.New()
4848
if err != nil {
@@ -67,26 +67,26 @@ func Example() {
6767
panic(err)
6868
}
6969

70-
cont, err := container.New(tbx, gridOpts...)
70+
cont, err := container.New(t, gridOpts...)
7171
if err != nil {
7272
panic(err)
7373
}
7474

7575
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
7676
defer cancel()
77-
if err := termdash.Run(ctx, tbx, cont); err != nil {
77+
if err := termdash.Run(ctx, t, cont); err != nil {
7878
panic(err)
7979
}
8080
}
8181

8282
// Shows how to create rows iteratively. Each row contains two columns and each
8383
// column contains the same widget.
8484
func Example_iterative() {
85-
tbx, err := termbox.New()
85+
t, err := tcell.New()
8686
if err != nil {
8787
panic(err)
8888
}
89-
defer tbx.Close()
89+
defer t.Close()
9090

9191
bc, err := barchart.New()
9292
if err != nil {
@@ -108,14 +108,14 @@ func Example_iterative() {
108108
panic(err)
109109
}
110110

111-
cont, err := container.New(tbx, gridOpts...)
111+
cont, err := container.New(t, gridOpts...)
112112
if err != nil {
113113
panic(err)
114114
}
115115

116116
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
117117
defer cancel()
118-
if err := termdash.Run(ctx, tbx, cont); err != nil {
118+
if err := termdash.Run(ctx, t, cont); err != nil {
119119
panic(err)
120120
}
121121
}

go.mod

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ module github.com/mum4k/termdash
33
go 1.14
44

55
require (
6-
github.com/gdamore/tcell v1.3.0
6+
github.com/gdamore/tcell/v2 v2.0.0
77
github.com/kylelemons/godebug v1.1.0
88
github.com/mattn/go-runewidth v0.0.9
9-
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be
9+
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e
10+
golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba // indirect
11+
golang.org/x/text v0.3.4 // indirect
1012
)

go.sum

+14
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,30 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
44
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
55
github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM=
66
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
7+
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
8+
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
9+
github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs=
10+
github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
711
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
812
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
913
github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=
1014
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
15+
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
16+
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
1117
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
18+
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
1219
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
1320
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
1421
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be h1:yzmWtPyxEUIKdZg4RcPq64MfS8NA6A5fNOJgYhpR9EQ=
1522
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
23+
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e h1:T8/SzSWIDoWV9trslLNfUdJ5yHrIXXuODEy5M0vou4U=
24+
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
1625
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
1726
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
27+
golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba h1:xmhUJGQGbxlod18iJGqVEp9cHIPLl7QiX2aA3to708s=
28+
golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1829
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
1930
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
31+
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
32+
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
33+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

private/faketerm/diff_test.go

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package faketerm
2+
3+
import (
4+
"image"
5+
"testing"
6+
7+
"github.com/mum4k/termdash/cell"
8+
)
9+
10+
func TestDiff(t *testing.T) {
11+
tests := []struct {
12+
desc string
13+
term1 *Terminal
14+
term2 *Terminal
15+
wantDiff bool
16+
}{
17+
{
18+
desc: "no diff on equal terminals",
19+
term1: func() *Terminal {
20+
t := MustNew(image.Point{2, 2})
21+
t.SetCell(image.Point{0, 0}, 'a')
22+
return t
23+
}(),
24+
term2: func() *Terminal {
25+
t := MustNew(image.Point{2, 2})
26+
t.SetCell(image.Point{0, 0}, 'a')
27+
return t
28+
}(),
29+
wantDiff: false,
30+
},
31+
{
32+
desc: "reports diff on when cell runes differ",
33+
term1: func() *Terminal {
34+
t := MustNew(image.Point{2, 2})
35+
t.SetCell(image.Point{0, 0}, 'a')
36+
return t
37+
}(),
38+
term2: func() *Terminal {
39+
t := MustNew(image.Point{2, 2})
40+
t.SetCell(image.Point{1, 1}, 'a')
41+
return t
42+
}(),
43+
wantDiff: true,
44+
},
45+
{
46+
desc: "reports diff on when cell options differ",
47+
term1: func() *Terminal {
48+
t := MustNew(image.Point{2, 2})
49+
t.SetCell(image.Point{0, 0}, 'a', cell.Bold())
50+
return t
51+
}(),
52+
term2: func() *Terminal {
53+
t := MustNew(image.Point{2, 2})
54+
t.SetCell(image.Point{0, 0}, 'a')
55+
return t
56+
}(),
57+
wantDiff: true,
58+
},
59+
}
60+
61+
for _, tc := range tests {
62+
t.Run(tc.desc, func(t *testing.T) {
63+
gotDiff := Diff(tc.term1, tc.term2)
64+
if (gotDiff != "") != tc.wantDiff {
65+
t.Errorf("Diff -> unexpected diff while wantDiff:%v, the diff:\n%s", tc.wantDiff, gotDiff)
66+
}
67+
})
68+
}
69+
}

0 commit comments

Comments
 (0)