From 8a5b62c731eeda99e11ea9812ac2644cb53b291a Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Sat, 6 Mar 2021 02:26:42 -0500 Subject: [PATCH 1/2] Release v0.15.0. (#298) ### Changed - Bump github.com/gdamore/tcell/v2 from 2.0.0 to 2.2.0. - Bump github.com/mattn/go-runewidth from 0.0.9 to 0.0.10. - Allowing CI to modify go.mod and go.sum when necessary. - Executed `go mod tidy`. ### Added - TitleColor and TitleFocusedColor options for border title which enables the setting of separate colors for border and title on a container. --- .travis.yml | 7 +- CHANGELOG.md | 17 ++++- container/container_test.go | 148 ++++++++++++++++++++++++++++++++++++ container/draw.go | 14 +++- container/draw_test.go | 38 +++++++++ container/options.go | 23 ++++++ go.mod | 5 +- go.sum | 31 +++----- 8 files changed, 254 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2bb2e36..89839162 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,11 @@ before_install: script: - go get -t ./... - go get -u golang.org/x/lint/golint - - go test ./... - - CGO_ENABLED=1 go test -race ./... + # Temporarily set -mod=mod to allow modification of go.mod and go.sum. + # This seems to be caused by a sum missing in the tcell dependency and + # should be removed when no longer needed. + - go test -mod=mod ./... + - CGO_ENABLED=1 go test -mod=mod -race ./... - go vet ./... - diff -u <(echo -n) <(gofmt -d -s .) - diff -u <(echo -n) <(./internal/scripts/autogen_licences.sh .) diff --git a/CHANGELOG.md b/CHANGELOG.md index 790c1faa..ccafe990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.15.0] - 06-Mar-2021 + +### Changed + +- Bump github.com/gdamore/tcell/v2 from 2.0.0 to 2.2.0. +- Bump github.com/mattn/go-runewidth from 0.0.9 to 0.0.10. +- Allowing CI to modify go.mod and go.sum when necessary. +- Executed `go mod tidy`. + +### Added + +- TitleColor and TitleFocusedColor options for border title which enables the + setting of separate colors for border and title on a container. + ## [0.14.0] - 30-Dec-2020 ### Breaking API changes @@ -439,7 +453,8 @@ identifiers shouldn't be used externally. - The Gauge widget. - The Text widget. -[unreleased]: https://github.com/mum4k/termdash/compare/v0.14.0...devel +[unreleased]: https://github.com/mum4k/termdash/compare/v0.15.0...devel +[0.15.0]: https://github.com/mum4k/termdash/compare/v0.14.0...v0.15.0 [0.14.0]: https://github.com/mum4k/termdash/compare/v0.13.0...v0.14.0 [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 diff --git a/container/container_test.go b/container/container_test.go index d4d4704a..2d1d76e7 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -1003,6 +1003,154 @@ func TestNew(t *testing.T) { return ft }, }, + { + desc: "sets border title on root container of different color", + termSize: image.Point{10, 10}, + container: func(ft *faketerm.Terminal) (*Container, error) { + return New( + ft, + Border(linestyle.Light), + BorderTitle("Ab"), + BorderColor(cell.ColorRed), + FocusedColor(cell.ColorBlue), + TitleColor(cell.ColorMagenta), + TitleFocusedColor(cell.ColorCyan), + SplitVertical( + Left( + Border(linestyle.Light), + ), + Right( + Border(linestyle.Light), + ), + ), + ) + }, + want: func(size image.Point) *faketerm.Terminal { + ft := faketerm.MustNew(size) + cvs := testcanvas.MustNew(ft.Area()) + testdraw.MustBorder( + cvs, + image.Rect(0, 0, 10, 10), + draw.BorderCellOpts(cell.FgColor(cell.ColorBlue)), + ) + testdraw.MustBorder( + cvs, + image.Rect(1, 1, 5, 9), + draw.BorderCellOpts(cell.FgColor(cell.ColorRed)), + ) + testdraw.MustBorder( + cvs, + image.Rect(5, 1, 9, 9), + draw.BorderCellOpts(cell.FgColor(cell.ColorRed)), + ) + testdraw.MustText( + cvs, + "Ab", + image.Point{1, 0}, + draw.TextCellOpts(cell.FgColor(cell.ColorCyan)), + ) + testcanvas.MustApply(cvs, ft) + return ft + }, + }, + { + desc: "sets different color title on left child container", + termSize: image.Point{10, 10}, + container: func(ft *faketerm.Terminal) (*Container, error) { + return New( + ft, + Border(linestyle.Light), + BorderColor(cell.ColorRed), + FocusedColor(cell.ColorBlue), + SplitVertical( + Left( + Border(linestyle.Light), + BorderTitle("Ab"), + TitleColor(cell.ColorMagenta), + TitleFocusedColor(cell.ColorCyan), + ), + Right( + Border(linestyle.Light), + ), + ), + ) + }, + want: func(size image.Point) *faketerm.Terminal { + ft := faketerm.MustNew(size) + cvs := testcanvas.MustNew(ft.Area()) + testdraw.MustBorder( + cvs, + image.Rect(0, 0, 10, 10), + draw.BorderCellOpts(cell.FgColor(cell.ColorBlue)), + ) + testdraw.MustBorder( + cvs, + image.Rect(1, 1, 5, 9), + draw.BorderCellOpts(cell.FgColor(cell.ColorRed)), + ) + testdraw.MustBorder( + cvs, + image.Rect(5, 1, 9, 9), + draw.BorderCellOpts(cell.FgColor(cell.ColorRed)), + ) + testdraw.MustText( + cvs, + "Ab", + image.Point{2, 1}, + draw.TextCellOpts(cell.FgColor(cell.ColorMagenta)), + ) + testcanvas.MustApply(cvs, ft) + return ft + }, + }, + { + desc: "inherits the border color for the title on left child container when TitleColor is not set", + termSize: image.Point{10, 10}, + container: func(ft *faketerm.Terminal) (*Container, error) { + return New( + ft, + Border(linestyle.Light), + BorderColor(cell.ColorRed), + FocusedColor(cell.ColorBlue), + SplitVertical( + Left( + Border(linestyle.Light), + BorderTitle("Ab"), + ), + Right( + Border(linestyle.Light), + ), + ), + ) + }, + want: func(size image.Point) *faketerm.Terminal { + ft := faketerm.MustNew(size) + cvs := testcanvas.MustNew(ft.Area()) + testdraw.MustBorder( + cvs, + image.Rect(0, 0, 10, 10), + draw.BorderCellOpts(cell.FgColor(cell.ColorBlue)), + ) + testdraw.MustBorder( + cvs, + image.Rect(1, 1, 5, 9), + draw.BorderCellOpts(cell.FgColor(cell.ColorRed)), + ) + testdraw.MustBorder( + cvs, + image.Rect(5, 1, 9, 9), + draw.BorderCellOpts(cell.FgColor(cell.ColorRed)), + ) + testdraw.MustText( + cvs, + "Ab", + image.Point{2, 1}, + draw.TextCellOpts(cell.FgColor(cell.ColorRed)), + ) + testcanvas.MustApply(cvs, ft) + return ft + }, + }, { desc: "splitting a container removes the widget", termSize: image.Point{10, 10}, diff --git a/container/draw.go b/container/draw.go index d186b127..9368f2de 100644 --- a/container/draw.go +++ b/container/draw.go @@ -84,16 +84,26 @@ func drawBorder(c *Container) error { return err } - var cOpts []cell.Option + var cOpts, titleCOpts []cell.Option if c.focusTracker.isActive(c) { cOpts = append(cOpts, cell.FgColor(c.opts.inherited.focusedColor)) + if c.opts.inherited.titleFocusedColor != nil { + titleCOpts = append(titleCOpts, cell.FgColor(*c.opts.inherited.titleFocusedColor)) + } else { + titleCOpts = cOpts + } } else { cOpts = append(cOpts, cell.FgColor(c.opts.inherited.borderColor)) + if c.opts.inherited.titleColor != nil { + titleCOpts = append(titleCOpts, cell.FgColor(*c.opts.inherited.titleColor)) + } else { + titleCOpts = cOpts + } } if err := draw.Border(cvs, ar, draw.BorderLineStyle(c.opts.border), - draw.BorderTitle(c.opts.borderTitle, draw.OverrunModeThreeDot, cOpts...), + draw.BorderTitle(c.opts.borderTitle, draw.OverrunModeThreeDot, titleCOpts...), draw.BorderTitleAlign(c.opts.borderTitleHAlign), draw.BorderCellOpts(cOpts...), ); err != nil { diff --git a/container/draw_test.go b/container/draw_test.go index 9789772a..76c14d7b 100644 --- a/container/draw_test.go +++ b/container/draw_test.go @@ -502,6 +502,44 @@ func TestDrawWidget(t *testing.T) { return ft }, }, + { + desc: "draws widget with container border and title with different color and focus color", + termSize: image.Point{9, 5}, + container: func(ft *faketerm.Terminal) (*Container, error) { + return New( + ft, + Border(linestyle.Light), + BorderTitle("ab"), + TitleColor(cell.ColorBlue), + // The created container is in focus so we must set the focus color + // in order to see the difference. + TitleFocusedColor(cell.ColorBlue), + BorderTitleAlignLeft(), + PlaceWidget(fakewidget.New(widgetapi.Options{})), + ) + }, + want: func(size image.Point) *faketerm.Terminal { + ft := faketerm.MustNew(size) + cvs := testcanvas.MustNew(ft.Area()) + // Container border. + testdraw.MustBorder( + cvs, + cvs.Area(), + draw.BorderCellOpts(cell.FgColor(cell.ColorYellow)), + draw.BorderTitle( + "ab", + draw.OverrunModeThreeDot, + cell.FgColor(cell.ColorBlue), + ), + ) + + // Fake widget border. + testdraw.MustBorder(cvs, image.Rect(1, 1, 8, 4)) + testdraw.MustText(cvs, "(7,3)", image.Point{2, 2}) + testcanvas.MustApply(cvs, ft) + return ft + }, + }, { desc: "draws widget without container border", termSize: image.Point{9, 5}, diff --git a/container/options.go b/container/options.go index 795e61c5..1fa718a8 100644 --- a/container/options.go +++ b/container/options.go @@ -194,6 +194,10 @@ type inherited struct { borderColor cell.Color // focusedColor is the color used for the border when focused. focusedColor cell.Color + // titleColor is the color used for the title. + titleColor *cell.Color + // titleFocusedColor is the color used for the title when focused. + titleFocusedColor *cell.Color } // focusGroups maps focus group numbers that have the same key assigned. @@ -749,6 +753,25 @@ func FocusedColor(color cell.Color) Option { }) } +// TitleColor sets the color of the title around the container. +// This option is inherited to sub containers created by container splits. +func TitleColor(color cell.Color) Option { + return option(func(c *Container) error { + c.opts.inherited.titleColor = &color + return nil + }) +} + +// TitleFocusedColor sets the color of the container title when it has +// keyboard focus. +// This option is inherited to sub containers created by container splits. +func TitleFocusedColor(color cell.Color) Option { + return option(func(c *Container) error { + c.opts.inherited.titleFocusedColor = &color + return nil + }) +} + // splitType identifies how a container is split. type splitType int diff --git a/go.mod b/go.mod index 7d8ce5f0..1cd63357 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,9 @@ module github.com/mum4k/termdash go 1.14 require ( - github.com/gdamore/tcell/v2 v2.0.0 + github.com/gdamore/tcell/v2 v2.2.0 github.com/kylelemons/godebug v1.1.0 - github.com/mattn/go-runewidth v0.0.9 + github.com/mattn/go-runewidth v0.0.10 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 ) diff --git a/go.sum b/go.sum index b9b635e0..44032fc5 100644 --- a/go.sum +++ b/go.sum @@ -1,32 +1,21 @@ -github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08= -github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= 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/gdamore/tcell/v2 v2.2.0 h1:vSyEgKwraXPSOkvCk7IwOSyX+Pv3V2cV9CikJMXg4U4= +github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= 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/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= +github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= 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= +github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M= +golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 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= From fc131ea4369c0e2d0d5a0a29dcd5d286cee5311c Mon Sep 17 00:00:00 2001 From: Heiko Alexander Weber Date: Fri, 19 Mar 2021 00:41:29 +0100 Subject: [PATCH 2/2] Update README.md (#299) + added "ali" as reference in projects --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 93cee5cb..e38b3f64 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ Termdash uses [this branching model](https://nvie.com/posts/a-successful-git-bra - [grafterm](https://github.com/slok/grafterm): Metrics dashboards visualization on the terminal. - [perfstat](https://github.com/flaviostutz/perfstat): Analyze and show tips about possible bottlenecks in Linux systems. - [gex](https://github.com/Tosch110/gex): Cosmos SDK explorer in-terminal. +- [ali](https://github.com/nakabonne/ali): ALI HTTP load testing tool with realtime analysis. # Disclaimer