Skip to content

Commit

Permalink
Merge pull request #266 from mum4k/release-0-13
Browse files Browse the repository at this point in the history
Releasing Termdash v0.13.
  • Loading branch information
mum4k committed Nov 18, 2020
2 parents 2a7dafa + 2fc684f commit fbd21e7
Show file tree
Hide file tree
Showing 34 changed files with 783 additions and 211 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,8 @@ go:
- 1.14.x
- 1.15.x
- stable
before_install:
- go get github.com/mattn/goveralls
script:
- go get -t ./...
- go get -u golang.org/x/lint/golint
Expand All @@ -12,6 +14,8 @@ script:
- diff -u <(echo -n) <(gofmt -d -s .)
- diff -u <(echo -n) <(./internal/scripts/autogen_licences.sh .)
- diff -u <(echo -n) <(golint ./...)
- $GOPATH/bin/goveralls -service=travis-pro
env:
global:
- CGO_ENABLED=0
- 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=
33 changes: 31 additions & 2 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.13.0] - 17-Nov-2020

### Added

- the `Text` widget now allows user to specify custom scroll marker runes.

### Changed

- terminal cells now support font modifier options (bold, italic,
underline, strike through).
- `tcell` dependency was upgraded to v2.0.0.
- upgraded versions of all other dependencies.
- aligned the definition of the first 16 colors with the definition used by
Xterm and `tcell`. Defined two non-standard colors `ColorMagenta` and
`ColorCyan` to make this change backward compatible for users that use
`termbox-go`.
- made `tcell` terminal implementation the default in examples, demos and
documentation.

### Fixed

- coveralls again triggers and reports on PRs.
- addressed some lint issues.
- improved test coverage in some modules.
- changed the Blue color in demos to a more visible shade.
- fixed a bug where segment display text in `termdashdemo` appeared to be
jumping.

## [0.12.2] - 31-Aug-2020

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

### Fixed

Expand Down Expand Up @@ -341,7 +369,8 @@ identifiers shouldn't be used externally.
- The Gauge widget.
- The Text widget.

[unreleased]: https://github.com/mum4k/termdash/compare/v0.12.2...devel
[unreleased]: https://github.com/mum4k/termdash/compare/v0.13.0...devel
[0.13.0]: https://github.com/mum4k/termdash/compare/v0.12.2...v0.13.0
[0.12.2]: https://github.com/mum4k/termdash/compare/v0.12.1...v0.12.2
[0.12.1]: https://github.com/mum4k/termdash/compare/v0.12.0...v0.12.1
[0.12.0]: https://github.com/mum4k/termdash/compare/v0.11.0...v0.12.0
Expand Down
52 changes: 50 additions & 2 deletions cell/cell.go
Expand Up @@ -23,8 +23,14 @@ type Option interface {

// Options stores the provided options.
type Options struct {
FgColor Color
BgColor Color
FgColor Color
BgColor Color
Bold bool
Italic bool
Underline bool
Strikethrough bool
Inverse bool
Blink bool
}

// Set allows existing options to be passed as an option.
Expand Down Expand Up @@ -62,3 +68,45 @@ func BgColor(color Color) Option {
co.BgColor = color
})
}

// Bold makes cell's text bold.
func Bold() Option {
return option(func(co *Options) {
co.Bold = true
})
}

// Italic makes cell's text italic. Only works when using the tcell backend.
func Italic() Option {
return option(func(co *Options) {
co.Italic = true
})
}

// Underline makes cell's text underlined.
func Underline() Option {
return option(func(co *Options) {
co.Underline = true
})
}

// Strikethrough strikes through the cell's text. Only works when using the tcell backend.
func Strikethrough() Option {
return option(func(co *Options) {
co.Strikethrough = true
})
}

// Inverse inverts the colors of the cell's text.
func Inverse() Option {
return option(func(co *Options) {
co.Inverse = true
})
}

// Blink makes the cell's text blink. Only works when using the tcell backend.
func Blink() Option {
return option(func(co *Options) {
co.Blink = true
})
}
20 changes: 20 additions & 0 deletions cell/cell_test.go
Expand Up @@ -27,6 +27,7 @@ func TestNewOptions(t *testing.T) {
want *Options
}{
{

desc: "no provided options",
want: &Options{},
},
Expand Down Expand Up @@ -72,6 +73,25 @@ func TestNewOptions(t *testing.T) {
BgColor: ColorMagenta,
},
},
{
desc: "setting font attributes",
opts: []Option{
Bold(),
Italic(),
Underline(),
Strikethrough(),
Inverse(),
Blink(),
},
want: &Options{
Bold: true,
Italic: true,
Underline: true,
Strikethrough: true,
Inverse: true,
Blink: true,
},
},
}

for _, tc := range tests {
Expand Down
25 changes: 21 additions & 4 deletions cell/color.go
Expand Up @@ -48,17 +48,32 @@ var colorNames = map[Color]string{
const (
ColorDefault Color = iota

// 8 "system" colors.
// The 16 Xterm colors.
// See https://jonasjacek.github.io/colors/
ColorBlack
ColorRed
ColorMaroon
ColorGreen
ColorOlive
ColorNavy
ColorPurple
ColorTeal
ColorSilver
ColorGray
ColorRed
ColorLime
ColorYellow
ColorBlue
ColorMagenta
ColorCyan
ColorFuchsia
ColorAqua
ColorWhite
)

// Colors defined for backward compatibility with termbox-go.
const (
ColorMagenta Color = ColorPurple
ColorCyan Color = ColorTeal
)

// ColorNumber sets a color using its number.
// Make sure your terminal is set to a terminalapi.ColorMode that supports the
// target color. The provided value must be in the range 0-255.
Expand Down Expand Up @@ -86,6 +101,8 @@ func ColorRGB6(r, g, b int) Color {
return ColorDefault
}
}
// Explanation:
// https://stackoverflow.com/questions/27159322/rgb-values-of-the-colors-in-the-ansi-extended-colors-index-17-255
return Color(0x10 + 36*r + 6*g + b + 1) // Colors are off-by-one due to ColorDefault being zero.
}

Expand Down
18 changes: 9 additions & 9 deletions container/grid/grid_test.go
Expand Up @@ -30,19 +30,19 @@ 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"
)

// 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 {
Expand All @@ -67,26 +67,26 @@ 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)
}
}

// 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 {
Expand All @@ -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)
}
}
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Expand Up @@ -3,8 +3,10 @@ module github.com/mum4k/termdash
go 1.14

require (
github.com/gdamore/tcell v1.3.0
github.com/gdamore/tcell/v2 v2.0.0
github.com/kylelemons/godebug v1.1.0
github.com/mattn/go-runewidth v0.0.9
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e
golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba // indirect
golang.org/x/text v0.3.4 // indirect
)
14 changes: 14 additions & 0 deletions go.sum
Expand Up @@ -4,16 +4,30 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM=
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs=
github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be h1:yzmWtPyxEUIKdZg4RcPq64MfS8NA6A5fNOJgYhpR9EQ=
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e h1:T8/SzSWIDoWV9trslLNfUdJ5yHrIXXuODEy5M0vou4U=
github.com/nsf/termbox-go v0.0.0-20201107200903-9b52a5faed9e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba h1:xmhUJGQGbxlod18iJGqVEp9cHIPLl7QiX2aA3to708s=
golang.org/x/sys v0.0.0-20201113233024-12cec1faf1ba/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
69 changes: 69 additions & 0 deletions private/faketerm/diff_test.go
@@ -0,0 +1,69 @@
package faketerm

import (
"image"
"testing"

"github.com/mum4k/termdash/cell"
)

func TestDiff(t *testing.T) {
tests := []struct {
desc string
term1 *Terminal
term2 *Terminal
wantDiff bool
}{
{
desc: "no diff on equal terminals",
term1: func() *Terminal {
t := MustNew(image.Point{2, 2})
t.SetCell(image.Point{0, 0}, 'a')
return t
}(),
term2: func() *Terminal {
t := MustNew(image.Point{2, 2})
t.SetCell(image.Point{0, 0}, 'a')
return t
}(),
wantDiff: false,
},
{
desc: "reports diff on when cell runes differ",
term1: func() *Terminal {
t := MustNew(image.Point{2, 2})
t.SetCell(image.Point{0, 0}, 'a')
return t
}(),
term2: func() *Terminal {
t := MustNew(image.Point{2, 2})
t.SetCell(image.Point{1, 1}, 'a')
return t
}(),
wantDiff: true,
},
{
desc: "reports diff on when cell options differ",
term1: func() *Terminal {
t := MustNew(image.Point{2, 2})
t.SetCell(image.Point{0, 0}, 'a', cell.Bold())
return t
}(),
term2: func() *Terminal {
t := MustNew(image.Point{2, 2})
t.SetCell(image.Point{0, 0}, 'a')
return t
}(),
wantDiff: true,
},
}

for _, tc := range tests {
t.Run(tc.desc, func(t *testing.T) {
gotDiff := Diff(tc.term1, tc.term2)
if (gotDiff != "") != tc.wantDiff {
t.Errorf("Diff -> unexpected diff while wantDiff:%v, the diff:\n%s", tc.wantDiff, gotDiff)
}
})
}
}

0 comments on commit fbd21e7

Please sign in to comment.