Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mum4k/termdash
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.14.0
Choose a base ref
...
head repository: mum4k/termdash
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.15.0
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Dec 30, 2020

  1. Create dependabot.yml

    mum4k authored Dec 30, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    74d9de2 View commit details

Commits on Mar 6, 2021

  1. 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.
    mum4k authored Mar 6, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8a5b62c View commit details
Showing with 264 additions and 29 deletions.
  1. +10 −0 .github/dependabot.yml
  2. +5 −2 .travis.yml
  3. +16 −1 CHANGELOG.md
  4. +148 −0 container/container_test.go
  5. +12 −2 container/draw.go
  6. +38 −0 container/draw_test.go
  7. +23 −0 container/options.go
  8. +2 −3 go.mod
  9. +10 −21 go.sum
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
target-branch: "devel"
schedule:
interval: "daily"
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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 .)
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
148 changes: 148 additions & 0 deletions container/container_test.go
Original file line number Diff line number Diff line change
@@ -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},
14 changes: 12 additions & 2 deletions container/draw.go
Original file line number Diff line number Diff line change
@@ -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 {
38 changes: 38 additions & 0 deletions container/draw_test.go
Original file line number Diff line number Diff line change
@@ -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},
23 changes: 23 additions & 0 deletions container/options.go
Original file line number Diff line number Diff line change
@@ -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

5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
31 changes: 10 additions & 21 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=