mirror of
https://github.com/mum4k/termdash.git
synced 2025-05-01 22:17:51 +08:00
commit
614d6ed820
20
CHANGELOG.md
20
CHANGELOG.md
@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.7.1] - 24-Feb-2019
|
||||
|
||||
### Fixed
|
||||
|
||||
- Some of the packages that were moved into internal are required externally.
|
||||
This release makes them available again.
|
||||
|
||||
#### Breaking API changes
|
||||
|
||||
- The draw.LineStyle enum was refactored into its own package
|
||||
linestyle.LineStyle. Users will have to replace:
|
||||
|
||||
- draw.LineStyleNone -> linestyle.None
|
||||
- draw.LineStyleLight -> linestyle.Light
|
||||
- draw.LineStyleDouble -> linestyle.Double
|
||||
- draw.LineStyleRound -> linestyle.Round
|
||||
|
||||
## [0.7.0] - 24-Feb-2019
|
||||
|
||||
### Added
|
||||
@ -168,7 +185,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- The Gauge widget.
|
||||
- The Text widget.
|
||||
|
||||
[Unreleased]: https://github.com/mum4k/termdash/compare/v0.7.0...devel
|
||||
[Unreleased]: https://github.com/mum4k/termdash/compare/v0.7.1...devel
|
||||
[0.7.1]: https://github.com/mum4k/termdash/compare/v0.7.0...v0.7.1
|
||||
[0.7.0]: https://github.com/mum4k/termdash/compare/v0.6.1...v0.7.0
|
||||
[0.6.1]: https://github.com/mum4k/termdash/compare/v0.6.0...v0.6.1
|
||||
[0.6.0]: https://github.com/mum4k/termdash/compare/v0.5.0...v0.6.0
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"image"
|
||||
"strings"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
)
|
||||
|
||||
// Horizontal indicates the type of horizontal alignment.
|
@ -24,7 +24,7 @@ import (
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
)
|
||||
|
||||
// Option is used to provide options for cells on a 2-D terminal.
|
@ -26,12 +26,12 @@ import (
|
||||
"image"
|
||||
"sync"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/event"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// Container wraps either sub containers or widgets and positions them on the
|
||||
@ -103,7 +103,7 @@ func newChild(parent *Container, area image.Rectangle) *Container {
|
||||
|
||||
// hasBorder determines if this container has a border.
|
||||
func (c *Container) hasBorder() bool {
|
||||
return c.opts.border != draw.LineStyleNone
|
||||
return c.opts.border != linestyle.None
|
||||
}
|
||||
|
||||
// hasWidget determines if this container has a widget.
|
||||
|
@ -21,38 +21,44 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/event"
|
||||
"github.com/mum4k/termdash/internal/event/testevent"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
"github.com/mum4k/termdash/widgets/fakewidget"
|
||||
)
|
||||
|
||||
// Example demonstrates how to use the Container API.
|
||||
func Example() {
|
||||
bc, err := barchart.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, err := New(
|
||||
/* terminal = */ nil,
|
||||
SplitVertical(
|
||||
Left(
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -60,8 +66,8 @@ func Example() {
|
||||
),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(bc),
|
||||
),
|
||||
),
|
||||
); err != nil {
|
||||
@ -93,7 +99,7 @@ func TestNew(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
)
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
@ -116,10 +122,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -141,10 +147,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
SplitPercent(0),
|
||||
),
|
||||
@ -163,10 +169,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
SplitPercent(100),
|
||||
),
|
||||
@ -185,10 +191,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
SplitPercent(20),
|
||||
),
|
||||
@ -209,13 +215,13 @@ func TestNew(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -242,10 +248,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -267,10 +273,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
SplitPercent(0),
|
||||
),
|
||||
@ -289,10 +295,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
SplitPercent(100),
|
||||
),
|
||||
@ -311,10 +317,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
SplitPercent(20),
|
||||
),
|
||||
@ -335,13 +341,13 @@ func TestNew(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -370,22 +376,22 @@ func TestNew(t *testing.T) {
|
||||
Left(
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
SplitHorizontal(
|
||||
Top(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Bottom(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -407,15 +413,15 @@ func TestNew(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderColor(cell.ColorRed),
|
||||
FocusedColor(cell.ColorBlue),
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -448,14 +454,14 @@ func TestNew(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -482,10 +488,10 @@ func TestNew(t *testing.T) {
|
||||
ft,
|
||||
SplitVertical(
|
||||
Left(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
Right(
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
),
|
||||
),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
@ -959,7 +965,7 @@ func TestMouse(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(
|
||||
fakewidget.New(widgetapi.Options{WantMouse: widgetapi.MouseScopeWidget}),
|
||||
),
|
||||
@ -994,7 +1000,7 @@ func TestMouse(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(
|
||||
fakewidget.New(widgetapi.Options{WantMouse: widgetapi.MouseScopeContainer}),
|
||||
),
|
||||
@ -1030,7 +1036,7 @@ func TestMouse(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(
|
||||
fakewidget.New(widgetapi.Options{WantMouse: widgetapi.MouseScopeGlobal}),
|
||||
),
|
||||
|
@ -21,9 +21,9 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
)
|
||||
|
||||
|
@ -18,13 +18,14 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/widgets/fakewidget"
|
||||
)
|
||||
|
||||
@ -42,7 +43,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
)
|
||||
},
|
||||
@ -69,7 +70,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderTitle("ab"),
|
||||
BorderTitleAlignLeft(),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
@ -103,7 +104,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderTitle("ab"),
|
||||
BorderTitleAlignCenter(),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
@ -138,7 +139,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderTitle("ab"),
|
||||
BorderTitleAlignRight(),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
@ -173,7 +174,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderTitle("abcdefgh"),
|
||||
BorderTitleAlignRight(),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
@ -228,7 +229,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{})),
|
||||
)
|
||||
},
|
||||
@ -243,7 +244,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
)
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
@ -279,7 +280,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
MaximumSize: image.Point{10, 10},
|
||||
})),
|
||||
@ -311,7 +312,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
MaximumSize: image.Point{10, 0},
|
||||
})),
|
||||
@ -343,7 +344,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
MaximumSize: image.Point{0, 10},
|
||||
})),
|
||||
@ -375,7 +376,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{1, 2}},
|
||||
)),
|
||||
@ -407,7 +408,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
MaximumSize: image.Point{20, 19},
|
||||
Ratio: image.Point{1, 1},
|
||||
@ -439,7 +440,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
AlignHorizontal(align.HorizontalLeft),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{1, 2}},
|
||||
@ -470,7 +471,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
AlignHorizontal(align.HorizontalCenter),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{1, 2}},
|
||||
@ -501,7 +502,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
AlignHorizontal(align.HorizontalRight),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{1, 2}},
|
||||
@ -532,7 +533,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
AlignVertical(align.VerticalTop),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{2, 1}},
|
||||
@ -563,7 +564,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
AlignVertical(align.VerticalMiddle),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{2, 1}},
|
||||
@ -594,7 +595,7 @@ func TestDrawWidget(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
AlignVertical(align.VerticalBottom),
|
||||
PlaceWidget(fakewidget.New(widgetapi.Options{
|
||||
Ratio: image.Point{2, 1}},
|
||||
|
@ -19,9 +19,9 @@ package container
|
||||
import (
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/mouse/button"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/button"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// pointCont finds the top-most (on the screen) container whose area contains
|
||||
|
@ -20,13 +20,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/event"
|
||||
"github.com/mum4k/termdash/internal/event/testevent"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// pointCase is a test case for the pointCont function.
|
||||
@ -97,7 +97,7 @@ func TestPointCont(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderColor(cell.ColorBlue),
|
||||
)
|
||||
},
|
||||
@ -167,7 +167,7 @@ func TestPointCont(t *testing.T) {
|
||||
container: func(ft *faketerm.Terminal) (*Container, error) {
|
||||
return New(
|
||||
ft,
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderColor(cell.ColorBlack),
|
||||
SplitVertical(
|
||||
Left(
|
||||
|
@ -19,10 +19,10 @@ package container
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// applyOptions applies the options to the container.
|
||||
@ -60,7 +60,7 @@ type options struct {
|
||||
vAlign align.Vertical
|
||||
|
||||
// border is the border around the container.
|
||||
border draw.LineStyle
|
||||
border linestyle.LineStyle
|
||||
borderTitle string
|
||||
borderTitleHAlign align.Horizontal
|
||||
}
|
||||
@ -224,7 +224,7 @@ func AlignVertical(v align.Vertical) Option {
|
||||
}
|
||||
|
||||
// Border configures the container to have a border of the specified style.
|
||||
func Border(ls draw.LineStyle) Option {
|
||||
func Border(ls linestyle.LineStyle) Option {
|
||||
return option(func(c *Container) error {
|
||||
c.opts.border = ls
|
||||
return nil
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestRoot(t *testing.T) {
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
)
|
||||
|
||||
func Example() {
|
||||
|
@ -18,8 +18,8 @@ package button
|
||||
import (
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// State represents the state of the mouse button.
|
@ -19,8 +19,8 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// eventTestCase is one mouse event and the output expectation.
|
@ -45,9 +45,9 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -19,11 +19,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func Example_copiedToCanvas() {
|
||||
|
@ -19,10 +19,10 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
// MustNew returns a new canvas or panics.
|
||||
|
@ -19,10 +19,10 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// Canvas is where a widget draws its output for display on the terminal.
|
||||
|
@ -19,9 +19,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
|
@ -19,9 +19,9 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
// MustNew returns a new canvas or panics.
|
||||
|
@ -20,9 +20,10 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// BorderOption is used to provide options to Border().
|
||||
@ -34,7 +35,7 @@ type BorderOption interface {
|
||||
// borderOptions stores the provided options.
|
||||
type borderOptions struct {
|
||||
cellOpts []cell.Option
|
||||
lineStyle LineStyle
|
||||
lineStyle linestyle.LineStyle
|
||||
title string
|
||||
titleOM OverrunMode
|
||||
titleCellOpts []cell.Option
|
||||
@ -50,10 +51,10 @@ func (bo borderOption) set(bOpts *borderOptions) {
|
||||
}
|
||||
|
||||
// DefaultBorderLineStyle is the default value for the BorderLineStyle option.
|
||||
const DefaultBorderLineStyle = LineStyleLight
|
||||
const DefaultBorderLineStyle = linestyle.Light
|
||||
|
||||
// BorderLineStyle sets the style of the line used to draw the border.
|
||||
func BorderLineStyle(ls LineStyle) BorderOption {
|
||||
func BorderLineStyle(ls linestyle.LineStyle) BorderOption {
|
||||
return borderOption(func(bOpts *borderOptions) {
|
||||
bOpts.lineStyle = ls
|
||||
})
|
||||
|
@ -18,11 +18,12 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
func TestBorder(t *testing.T) {
|
||||
@ -57,7 +58,7 @@ func TestBorder(t *testing.T) {
|
||||
canvas: image.Rect(0, 0, 4, 4),
|
||||
border: image.Rect(0, 0, 2, 2),
|
||||
opts: []BorderOption{
|
||||
BorderLineStyle(LineStyle(-1)),
|
||||
BorderLineStyle(linestyle.LineStyle(-1)),
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
return faketerm.MustNew(size)
|
||||
@ -72,21 +73,21 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -97,27 +98,27 @@ func TestBorder(t *testing.T) {
|
||||
canvas: image.Rect(0, 0, 4, 4),
|
||||
border: image.Rect(0, 0, 4, 4),
|
||||
opts: []BorderOption{
|
||||
BorderLineStyle(LineStyleDouble),
|
||||
BorderLineStyle(linestyle.Double),
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleDouble][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleDouble][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Double][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Double][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Double][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Double][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[LineStyleDouble][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleDouble][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[linestyle.Double][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Double][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[LineStyleDouble][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleDouble][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[linestyle.Double][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Double][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleDouble][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleDouble][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Double][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Double][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Double][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Double][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -128,27 +129,27 @@ func TestBorder(t *testing.T) {
|
||||
canvas: image.Rect(0, 0, 4, 4),
|
||||
border: image.Rect(0, 0, 4, 4),
|
||||
opts: []BorderOption{
|
||||
BorderLineStyle(LineStyleRound),
|
||||
BorderLineStyle(linestyle.Round),
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleRound][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleRound][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleRound][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleRound][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Round][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Round][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Round][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Round][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[LineStyleRound][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleRound][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[linestyle.Round][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Round][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[LineStyleRound][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleRound][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[linestyle.Round][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Round][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleRound][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleRound][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleRound][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleRound][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Round][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Round][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Round][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Round][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -162,11 +163,11 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -184,14 +185,14 @@ func TestBorder(t *testing.T) {
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1},
|
||||
lineStyleChars[LineStyleLight][topLeftCorner], cell.FgColor(cell.ColorRed))
|
||||
lineStyleChars[linestyle.Light][topLeftCorner], cell.FgColor(cell.ColorRed))
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2},
|
||||
lineStyleChars[LineStyleLight][bottomLeftCorner], cell.FgColor(cell.ColorRed))
|
||||
lineStyleChars[linestyle.Light][bottomLeftCorner], cell.FgColor(cell.ColorRed))
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1},
|
||||
lineStyleChars[LineStyleLight][topRightCorner], cell.FgColor(cell.ColorRed))
|
||||
lineStyleChars[linestyle.Light][topRightCorner], cell.FgColor(cell.ColorRed))
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2},
|
||||
lineStyleChars[LineStyleLight][bottomRightCorner], cell.FgColor(cell.ColorRed))
|
||||
lineStyleChars[linestyle.Light][bottomRightCorner], cell.FgColor(cell.ColorRed))
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -208,21 +209,21 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, 'a')
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, 'b')
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -239,21 +240,21 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, 'a', cell.FgColor(cell.ColorRed))
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, 'b', cell.FgColor(cell.ColorRed))
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -282,11 +283,11 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -303,21 +304,21 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, 'a')
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, 'b')
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -334,21 +335,21 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, 'a')
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, '…')
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -366,27 +367,27 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, 'a')
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, 'b')
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{4, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{5, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -404,27 +405,27 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, 'a')
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, 'b')
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{4, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{5, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
@ -442,27 +443,27 @@ func TestBorder(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleLight][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleLight][bottomLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[linestyle.Light][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[linestyle.Light][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[linestyle.Light][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, 'a')
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{4, 0}, 'b')
|
||||
testcanvas.MustSetCell(c, image.Point{4, 3}, lineStyleChars[LineStyleLight][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{4, 3}, lineStyleChars[linestyle.Light][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{5, 0}, lineStyleChars[LineStyleLight][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 1}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 2}, lineStyleChars[LineStyleLight][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 3}, lineStyleChars[LineStyleLight][bottomRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 0}, lineStyleChars[linestyle.Light][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 1}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 2}, lineStyleChars[linestyle.Light][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{5, 3}, lineStyleChars[linestyle.Light][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/numbers/trig"
|
||||
)
|
||||
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille/testbraille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
// mustBrailleLine draws the braille line or panics.
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
)
|
||||
|
||||
// BrailleFillOption is used to provide options to BrailleFill.
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille/testbraille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestBrailleFill(t *testing.T) {
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/numbers"
|
||||
)
|
||||
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille/testbraille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestBrailleLine(t *testing.T) {
|
||||
|
@ -20,8 +20,9 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// HVLineOption is used to provide options to HVLine().
|
||||
@ -33,13 +34,13 @@ type HVLineOption interface {
|
||||
// hVLineOptions stores the provided options.
|
||||
type hVLineOptions struct {
|
||||
cellOpts []cell.Option
|
||||
lineStyle LineStyle
|
||||
lineStyle linestyle.LineStyle
|
||||
}
|
||||
|
||||
// newHVLineOptions returns a new hVLineOptions instance.
|
||||
func newHVLineOptions() *hVLineOptions {
|
||||
return &hVLineOptions{
|
||||
lineStyle: DefaultHVLineStyle,
|
||||
lineStyle: DefaultLineStyle,
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,12 +52,12 @@ func (o hVLineOption) set(opts *hVLineOptions) {
|
||||
o(opts)
|
||||
}
|
||||
|
||||
// DefaultHVLineStyle is the default value for the HVLineStyle option.
|
||||
const DefaultHVLineStyle = LineStyleLight
|
||||
// DefaultLineStyle is the default value for the HVLineStyle option.
|
||||
const DefaultLineStyle = linestyle.Light
|
||||
|
||||
// HVLineStyle sets the style of the line.
|
||||
// Defaults to DefaultHVLineStyle.
|
||||
func HVLineStyle(ls LineStyle) HVLineOption {
|
||||
// Defaults to DefaultLineStyle.
|
||||
func HVLineStyle(ls linestyle.LineStyle) HVLineOption {
|
||||
return hVLineOption(func(opts *hVLineOptions) {
|
||||
opts.lineStyle = ls
|
||||
})
|
||||
|
@ -19,6 +19,8 @@ package draw
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// hVLineEdge is an edge between two points on the graph.
|
||||
@ -90,7 +92,7 @@ func (n *hVLineNode) hasRight() bool {
|
||||
// rune, given the selected line style returns the correct line character to
|
||||
// represent this node.
|
||||
// Only handles nodes with two or more edges, as returned by multiEdgeNodes().
|
||||
func (n *hVLineNode) rune(ls LineStyle) (rune, error) {
|
||||
func (n *hVLineNode) rune(ls linestyle.LineStyle) (rune, error) {
|
||||
parts, err := lineParts(ls)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
func TestMultiEdgeNodes(t *testing.T) {
|
||||
@ -180,7 +181,7 @@ func TestNodeRune(t *testing.T) {
|
||||
tests := []struct {
|
||||
desc string
|
||||
node *hVLineNode
|
||||
ls LineStyle
|
||||
ls linestyle.LineStyle
|
||||
want rune
|
||||
wantErr bool
|
||||
}{
|
||||
@ -197,7 +198,7 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 1}, image.Point{2, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
ls: linestyle.Light,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@ -209,13 +210,13 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 1}, image.Point{2, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
ls: linestyle.Light,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
desc: "fails on unsupported line style",
|
||||
node: &hVLineNode{},
|
||||
ls: LineStyle(-1),
|
||||
ls: linestyle.LineStyle(-1),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@ -227,8 +228,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 1}, image.Point{2, 1}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][hLine],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][hLine],
|
||||
},
|
||||
{
|
||||
desc: "vertical line",
|
||||
@ -239,8 +240,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 1}, image.Point{1, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][vLine],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][vLine],
|
||||
},
|
||||
{
|
||||
desc: "top left corner",
|
||||
@ -251,8 +252,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{0, 0}, image.Point{0, 1}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][topLeftCorner],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][topLeftCorner],
|
||||
},
|
||||
{
|
||||
desc: "top right corner",
|
||||
@ -263,8 +264,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{2, 0}, image.Point{2, 1}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][topRightCorner],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][topRightCorner],
|
||||
},
|
||||
{
|
||||
desc: "bottom left corner",
|
||||
@ -275,8 +276,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{0, 2}, image.Point{1, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][bottomLeftCorner],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][bottomLeftCorner],
|
||||
},
|
||||
{
|
||||
desc: "bottom right corner",
|
||||
@ -287,8 +288,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{2, 1}, image.Point{2, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][bottomRightCorner],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][bottomRightCorner],
|
||||
},
|
||||
{
|
||||
desc: "T horizontal and up",
|
||||
@ -300,8 +301,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 2}, image.Point{2, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][hAndUp],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][hAndUp],
|
||||
},
|
||||
{
|
||||
desc: "T horizontal and down",
|
||||
@ -313,8 +314,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 0}, image.Point{1, 1}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][hAndDown],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][hAndDown],
|
||||
},
|
||||
{
|
||||
desc: "T vertical and right",
|
||||
@ -326,8 +327,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{0, 1}, image.Point{0, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][vAndRight],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][vAndRight],
|
||||
},
|
||||
{
|
||||
desc: "T vertical and left",
|
||||
@ -339,8 +340,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{2, 1}, image.Point{2, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][vAndLeft],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][vAndLeft],
|
||||
},
|
||||
{
|
||||
desc: "cross",
|
||||
@ -353,8 +354,8 @@ func TestNodeRune(t *testing.T) {
|
||||
newHVLineEdge(image.Point{1, 1}, image.Point{1, 2}): true,
|
||||
},
|
||||
},
|
||||
ls: LineStyleLight,
|
||||
want: lineStyleChars[LineStyleLight][vAndH],
|
||||
ls: linestyle.Light,
|
||||
want: lineStyleChars[linestyle.Light][vAndH],
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,11 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
func TestHVLines(t *testing.T) {
|
||||
@ -102,7 +103,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[hLine])
|
||||
@ -121,13 +122,13 @@ func TestHVLines(t *testing.T) {
|
||||
},
|
||||
},
|
||||
opts: []HVLineOption{
|
||||
HVLineStyle(LineStyleLight),
|
||||
HVLineStyle(linestyle.Light),
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[hLine])
|
||||
@ -155,7 +156,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[hLine],
|
||||
cell.FgColor(cell.ColorYellow),
|
||||
cell.BgColor(cell.ColorBlue),
|
||||
@ -186,7 +187,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[hLine])
|
||||
|
||||
@ -207,7 +208,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2}, parts[vLine])
|
||||
@ -229,7 +230,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, parts[vLine])
|
||||
|
||||
@ -254,7 +255,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[hLine])
|
||||
@ -284,7 +285,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, parts[vLine])
|
||||
@ -314,7 +315,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, parts[vLine])
|
||||
@ -343,7 +344,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, parts[vLine])
|
||||
@ -372,7 +373,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, parts[vLine])
|
||||
@ -401,7 +402,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, parts[bottomLeftCorner])
|
||||
@ -430,7 +431,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, parts[vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, parts[bottomRightCorner])
|
||||
@ -459,7 +460,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 2}, parts[hAndUp])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 2}, parts[hLine])
|
||||
@ -488,7 +489,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[hAndDown])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[hLine])
|
||||
@ -517,7 +518,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, parts[vAndLeft])
|
||||
@ -546,7 +547,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[vAndRight])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, parts[hLine])
|
||||
@ -575,7 +576,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, parts[hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 1}, parts[vAndH])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 1}, parts[hLine])
|
||||
@ -622,7 +623,7 @@ func TestHVLines(t *testing.T) {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
parts := lineStyleChars[LineStyleLight]
|
||||
parts := lineStyleChars[linestyle.Light]
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, parts[topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, parts[hAndDown])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, parts[topRightCorner])
|
||||
|
@ -17,7 +17,8 @@ package draw
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// line_style.go contains the Unicode characters used for drawing lines of
|
||||
@ -25,8 +26,8 @@ import (
|
||||
|
||||
// lineStyleChars maps the line styles to the corresponding component characters.
|
||||
// Source: http://en.wikipedia.org/wiki/Box-drawing_character.
|
||||
var lineStyleChars = map[LineStyle]map[linePart]rune{
|
||||
LineStyleLight: {
|
||||
var lineStyleChars = map[linestyle.LineStyle]map[linePart]rune{
|
||||
linestyle.Light: {
|
||||
hLine: '─',
|
||||
vLine: '│',
|
||||
topLeftCorner: '┌',
|
||||
@ -39,7 +40,7 @@ var lineStyleChars = map[LineStyle]map[linePart]rune{
|
||||
vAndRight: '├',
|
||||
vAndH: '┼',
|
||||
},
|
||||
LineStyleDouble: {
|
||||
linestyle.Double: {
|
||||
hLine: '═',
|
||||
vLine: '║',
|
||||
topLeftCorner: '╔',
|
||||
@ -52,7 +53,7 @@ var lineStyleChars = map[LineStyle]map[linePart]rune{
|
||||
vAndRight: '╠',
|
||||
vAndH: '╬',
|
||||
},
|
||||
LineStyleRound: {
|
||||
linestyle.Round: {
|
||||
hLine: '─',
|
||||
vLine: '│',
|
||||
topLeftCorner: '╭',
|
||||
@ -80,7 +81,7 @@ func init() {
|
||||
}
|
||||
|
||||
// lineParts returns the line component characters for the provided line style.
|
||||
func lineParts(ls LineStyle) (map[linePart]rune, error) {
|
||||
func lineParts(ls linestyle.LineStyle) (map[linePart]rune, error) {
|
||||
parts, ok := lineStyleChars[ls]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unsupported line style %d", ls)
|
||||
@ -88,32 +89,6 @@ func lineParts(ls LineStyle) (map[linePart]rune, error) {
|
||||
return parts, nil
|
||||
}
|
||||
|
||||
// LineStyle defines the supported line styles.Q
|
||||
type LineStyle int
|
||||
|
||||
// String implements fmt.Stringer()
|
||||
func (ls LineStyle) String() string {
|
||||
if n, ok := lineStyleNames[ls]; ok {
|
||||
return n
|
||||
}
|
||||
return "LineStyleUnknown"
|
||||
}
|
||||
|
||||
// lineStyleNames maps LineStyle values to human readable names.
|
||||
var lineStyleNames = map[LineStyle]string{
|
||||
LineStyleLight: "LineStyleLight",
|
||||
LineStyleDouble: "LineStyleDouble",
|
||||
LineStyleRound: "LineStyleRound",
|
||||
}
|
||||
|
||||
// Supported line styles.
|
||||
const (
|
||||
LineStyleNone LineStyle = iota
|
||||
LineStyleLight
|
||||
LineStyleDouble
|
||||
LineStyleRound
|
||||
)
|
||||
|
||||
// linePart identifies individual line parts.
|
||||
type linePart int
|
||||
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
)
|
||||
|
||||
// RectangleOption is used to provide options to the Rectangle function.
|
||||
|
@ -18,10 +18,10 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestRectangle(t *testing.T) {
|
||||
|
@ -21,9 +21,9 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
)
|
||||
|
||||
// OverrunMode represents
|
||||
|
@ -18,10 +18,10 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestTrimText(t *testing.T) {
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
)
|
||||
|
||||
// VerticalTextOption is used to provide options to Text().
|
||||
|
@ -18,10 +18,10 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestVerticalText(t *testing.T) {
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/mum4k/termdash/internal/event/eventqueue"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// Callback is a function provided by an event subscriber.
|
||||
|
@ -24,8 +24,8 @@ import (
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/event/testevent"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// receiverMode defines how the receiver behaves.
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// node is a single data item on the queue.
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
func TestQueue(t *testing.T) {
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
)
|
||||
|
||||
// optDiff is used to display differences in cell options.
|
@ -23,9 +23,9 @@ import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/event/eventqueue"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// Option is used to provide options.
|
@ -19,8 +19,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
)
|
||||
|
@ -19,13 +19,13 @@ import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille/testbraille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
)
|
||||
|
||||
func TestHV(t *testing.T) {
|
@ -20,7 +20,7 @@ import (
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/draw/segdisp/segment"
|
||||
"github.com/mum4k/termdash/internal/segdisp/segment"
|
||||
)
|
||||
|
||||
// MustHV draws the segment or panics.
|
@ -22,8 +22,8 @@ import (
|
||||
"image"
|
||||
"math"
|
||||
|
||||
"github.com/mum4k/termdash/internal/draw/segdisp/segment"
|
||||
"github.com/mum4k/termdash/internal/numbers"
|
||||
"github.com/mum4k/termdash/internal/segdisp/segment"
|
||||
)
|
||||
|
||||
// hvSegType maps horizontal and vertical segments to their type.
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -45,11 +45,11 @@ import (
|
||||
"image"
|
||||
"math"
|
||||
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw/segdisp/segment"
|
||||
"github.com/mum4k/termdash/internal/segdisp/segment"
|
||||
)
|
||||
|
||||
// Segment represents a single segment in the display.
|
@ -20,14 +20,14 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille/testbraille"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw/segdisp/segment"
|
||||
"github.com/mum4k/termdash/internal/draw/segdisp/segment/testsegment"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/segdisp/segment"
|
||||
"github.com/mum4k/termdash/internal/segdisp/segment/testsegment"
|
||||
)
|
||||
|
||||
func TestDraw(t *testing.T) {
|
@ -19,7 +19,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/draw/segdisp/sixteen"
|
||||
"github.com/mum4k/termdash/internal/segdisp/sixteen"
|
||||
)
|
||||
|
||||
// MustSetCharacter sets the character on the display or panics.
|
@ -19,7 +19,7 @@ import (
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// KeyScope indicates the scope at which the widget wants to receive keyboard
|
||||
|
51
linestyle/linestyle.go
Normal file
51
linestyle/linestyle.go
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright 2019 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package linestyle defines various line styles.
|
||||
package linestyle
|
||||
|
||||
// LineStyle defines the supported line styles.Q
|
||||
type LineStyle int
|
||||
|
||||
// String implements fmt.Stringer()
|
||||
func (ls LineStyle) String() string {
|
||||
if n, ok := lineStyleNames[ls]; ok {
|
||||
return n
|
||||
}
|
||||
return "LineStyleUnknown"
|
||||
}
|
||||
|
||||
// lineStyleNames maps LineStyle values to human readable names.
|
||||
var lineStyleNames = map[LineStyle]string{
|
||||
None: "LineStyleNone",
|
||||
Light: "LineStyleLight",
|
||||
Double: "LineStyleDouble",
|
||||
Round: "LineStyleRound",
|
||||
}
|
||||
|
||||
// Supported line styles.
|
||||
// See https://en.wikipedia.org/wiki/Box-drawing_character.
|
||||
const (
|
||||
// None indicates that no line should be present.
|
||||
None LineStyle = iota
|
||||
|
||||
// Light is line style using the '─' characters.
|
||||
Light
|
||||
|
||||
// Double is line style using the '═' characters.
|
||||
Double
|
||||
|
||||
// Round is line style using the rounded corners '╭' characters.
|
||||
Round
|
||||
)
|
60
linestyle/linestyle_test.go
Normal file
60
linestyle/linestyle_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright 2019 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package linestyle
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLineStyleName(t *testing.T) {
|
||||
tests := []struct {
|
||||
desc string
|
||||
ls LineStyle
|
||||
want string
|
||||
}{
|
||||
{
|
||||
desc: "unknown",
|
||||
ls: LineStyle(-1),
|
||||
want: "LineStyleUnknown",
|
||||
},
|
||||
{
|
||||
desc: "none",
|
||||
ls: None,
|
||||
want: "LineStyleNone",
|
||||
},
|
||||
{
|
||||
desc: "light",
|
||||
ls: Light,
|
||||
want: "LineStyleLight",
|
||||
},
|
||||
{
|
||||
desc: "double",
|
||||
ls: Double,
|
||||
want: "LineStyleDouble",
|
||||
},
|
||||
{
|
||||
desc: "round",
|
||||
ls: Round,
|
||||
want: "LineStyleRound",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
if got := tc.ls.String(); got != tc.want {
|
||||
t.Errorf("String => %q, want %q", got, tc.want)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ import (
|
||||
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/internal/event"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// DefaultRedrawInterval is the default for the RedrawInterval option.
|
||||
|
@ -28,13 +28,15 @@ import (
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/event/eventqueue"
|
||||
"github.com/mum4k/termdash/internal/event/testevent"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/terminal/termbox"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
"github.com/mum4k/termdash/widgets/fakewidget"
|
||||
"github.com/mum4k/termdash/widgets/gauge"
|
||||
)
|
||||
|
||||
// Example shows how to setup and run termdash with periodic redraw.
|
||||
@ -46,21 +48,25 @@ func Example() {
|
||||
}
|
||||
defer t.Close()
|
||||
|
||||
wOpts := widgetapi.Options{
|
||||
MinimumSize: fakewidget.MinimumSize,
|
||||
WantKeyboard: widgetapi.KeyScopeFocused,
|
||||
WantMouse: widgetapi.MouseScopeWidget,
|
||||
// Create some widgets.
|
||||
bc, err := barchart.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
g, err := gauge.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Create the container with two fake widgets.
|
||||
// Create the container with two widgets.
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.SplitVertical(
|
||||
container.Left(
|
||||
container.PlaceWidget(fakewidget.New(wOpts)),
|
||||
container.PlaceWidget(bc),
|
||||
),
|
||||
container.Right(
|
||||
container.PlaceWidget(fakewidget.New(wOpts)),
|
||||
container.PlaceWidget(g),
|
||||
),
|
||||
container.SplitPercent(30),
|
||||
),
|
||||
@ -86,16 +92,16 @@ func Example_triggered() {
|
||||
}
|
||||
defer t.Close()
|
||||
|
||||
wOpts := widgetapi.Options{
|
||||
MinimumSize: fakewidget.MinimumSize,
|
||||
WantKeyboard: widgetapi.KeyScopeFocused,
|
||||
WantMouse: widgetapi.MouseScopeWidget,
|
||||
// Create a widget.
|
||||
bc, err := barchart.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Create the container with a widget.
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.PlaceWidget(fakewidget.New(wOpts)),
|
||||
container.PlaceWidget(bc),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -25,12 +25,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminal/termbox"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
"github.com/mum4k/termdash/widgets/button"
|
||||
"github.com/mum4k/termdash/widgets/donut"
|
||||
@ -62,19 +62,19 @@ func layout(ctx context.Context, t terminalapi.Terminal) (*container.Container,
|
||||
segmentTextSpark := []container.Option{
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("Press Q to quit"),
|
||||
container.PlaceWidget(sd),
|
||||
),
|
||||
container.Bottom(
|
||||
container.SplitVertical(
|
||||
container.Left(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("A rolling text"),
|
||||
container.PlaceWidget(rollT),
|
||||
),
|
||||
container.Right(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("A SparkLine group"),
|
||||
container.SplitHorizontal(
|
||||
container.Top(container.PlaceWidget(spGreen)),
|
||||
@ -99,13 +99,13 @@ func layout(ctx context.Context, t terminalapi.Terminal) (*container.Container,
|
||||
gaugeAndHeartbeat := []container.Option{
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("A Gauge"),
|
||||
container.BorderColor(cell.ColorNumber(39)),
|
||||
container.PlaceWidget(g),
|
||||
),
|
||||
container.Bottom(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("A LineChart"),
|
||||
container.PlaceWidget(heartLC),
|
||||
),
|
||||
@ -138,7 +138,7 @@ func layout(ctx context.Context, t terminalapi.Terminal) (*container.Container,
|
||||
lcAndButtons := []container.Option{
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("Multiple series"),
|
||||
container.BorderTitleAlignRight(),
|
||||
container.PlaceWidget(sineLC),
|
||||
@ -162,7 +162,7 @@ func layout(ctx context.Context, t terminalapi.Terminal) (*container.Container,
|
||||
rightSide := []container.Option{
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("BarChart"),
|
||||
container.PlaceWidget(bc),
|
||||
container.BorderTitleAlignRight(),
|
||||
@ -170,7 +170,7 @@ func layout(ctx context.Context, t terminalapi.Terminal) (*container.Container,
|
||||
container.Bottom(
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("A Donut"),
|
||||
container.BorderTitleAlignRight(),
|
||||
container.PlaceWidget(don),
|
||||
|
@ -17,7 +17,7 @@ package termbox
|
||||
// cell_options.go converts termdash cell options to the termbox format.
|
||||
|
||||
import (
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
tbx "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ package termbox
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
tbx "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ package termbox
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
tbx "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
@ -19,9 +19,9 @@ package termbox
|
||||
import (
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
tbx "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
@ -21,9 +21,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
|
||||
tbx "github.com/nsf/termbox-go"
|
||||
)
|
@ -19,9 +19,9 @@ import (
|
||||
"context"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/event/eventqueue"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
tbx "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
func TestNewTerminal(t *testing.T) {
|
@ -19,8 +19,8 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
)
|
||||
|
||||
// event.go defines events that can be received through the terminal API.
|
@ -19,7 +19,7 @@ import (
|
||||
"context"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
)
|
||||
|
||||
// Terminal abstracts an implementation of a 2-D terminal.
|
@ -22,13 +22,13 @@ import (
|
||||
"image"
|
||||
"sync"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// BarChart displays multiple bars showing relative ratios of values.
|
||||
|
@ -19,12 +19,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
)
|
||||
|
||||
|
@ -22,11 +22,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminal/termbox"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/barchart"
|
||||
)
|
||||
|
||||
@ -98,7 +98,7 @@ func main() {
|
||||
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("PRESS Q TO QUIT"),
|
||||
container.PlaceWidget(bc),
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ package barchart
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
)
|
||||
|
||||
|
@ -22,14 +22,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/button"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/mouse/button"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// CallbackFn is the function called when the button is pressed.
|
||||
@ -146,14 +146,11 @@ func (b *Button) Draw(cvs *canvas.Canvas) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := draw.Text(cvs, b.text, start,
|
||||
return draw.Text(cvs, b.text, start,
|
||||
draw.TextOverrunMode(draw.OverrunModeThreeDot),
|
||||
draw.TextMaxX(buttonAr.Max.X),
|
||||
draw.TextCellOpts(cell.FgColor(b.opts.textColor)),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
)
|
||||
}
|
||||
|
||||
// Keyboard processes keyboard events, acts as a button press on the configured
|
||||
|
@ -22,16 +22,16 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// callbackTracker tracks whether callback was called.
|
||||
|
@ -21,12 +21,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminal/termbox"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/button"
|
||||
"github.com/mum4k/termdash/widgets/segmentdisplay"
|
||||
)
|
||||
@ -79,7 +79,7 @@ func main() {
|
||||
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("PRESS Q TO QUIT"),
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
|
@ -20,10 +20,10 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
)
|
||||
|
||||
// Option is used to provide options.
|
||||
|
@ -22,14 +22,14 @@ import (
|
||||
"image"
|
||||
"sync"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille"
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/numbers"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// progressType indicates how was the current progress provided by the caller.
|
||||
|
@ -19,15 +19,15 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/braille/testbraille"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
func TestDonut(t *testing.T) {
|
||||
|
@ -21,11 +21,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminal/termbox"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/donut"
|
||||
)
|
||||
|
||||
@ -112,7 +112,7 @@ func main() {
|
||||
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("PRESS Q TO QUIT"),
|
||||
container.SplitVertical(
|
||||
container.Left(
|
||||
|
@ -19,7 +19,7 @@ package donut
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
)
|
||||
|
||||
// Option is used to provide options.
|
||||
|
@ -24,10 +24,10 @@ import (
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// outputLines are the number of lines written by this plugin.
|
||||
|
@ -22,11 +22,11 @@ import (
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/keyboard"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/keyboard"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// keyEvents are keyboard events to send to the widget.
|
||||
|
@ -22,14 +22,15 @@ import (
|
||||
"image"
|
||||
"sync"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/area"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/cell/runewidth"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/internal/runewidth"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
)
|
||||
|
||||
// progressType indicates how was the current progress provided by the caller.
|
||||
@ -145,7 +146,7 @@ func (g *Gauge) width(ar image.Rectangle) int {
|
||||
|
||||
// hasBorder determines of the gauge has a border.
|
||||
func (g *Gauge) hasBorder() bool {
|
||||
return g.opts.border != draw.LineStyleNone
|
||||
return g.opts.border != linestyle.None
|
||||
}
|
||||
|
||||
// usable determines the usable area for the gauge itself.
|
||||
|
@ -19,14 +19,15 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/canvas"
|
||||
"github.com/mum4k/termdash/internal/canvas/testcanvas"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/draw/testdraw"
|
||||
"github.com/mum4k/termdash/internal/terminal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/faketerm"
|
||||
"github.com/mum4k/termdash/internal/widgetapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// percentCall contains arguments for a call to GaugePercent().
|
||||
@ -89,7 +90,7 @@ func TestGauge(t *testing.T) {
|
||||
desc: "draws resize needed character when canvas is smaller than requested",
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 35},
|
||||
canvas: image.Rect(0, 0, 1, 1),
|
||||
@ -126,7 +127,7 @@ func TestGauge(t *testing.T) {
|
||||
Char('o'),
|
||||
HorizontalTextAlign(align.HorizontalLeft),
|
||||
VerticalTextAlign(align.VerticalTop),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 0},
|
||||
canvas: image.Rect(0, 0, 10, 4),
|
||||
@ -164,7 +165,7 @@ func TestGauge(t *testing.T) {
|
||||
Char('o'),
|
||||
HorizontalTextAlign(align.HorizontalRight),
|
||||
VerticalTextAlign(align.VerticalBottom),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 0},
|
||||
canvas: image.Rect(0, 0, 10, 4),
|
||||
@ -182,7 +183,7 @@ func TestGauge(t *testing.T) {
|
||||
desc: "gauge showing percentage with border",
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
BorderTitle("title"),
|
||||
},
|
||||
percent: &percentCall{p: 35},
|
||||
@ -207,7 +208,7 @@ func TestGauge(t *testing.T) {
|
||||
desc: "respects border options",
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
Border(draw.LineStyleLight, cell.FgColor(cell.ColorBlue)),
|
||||
Border(linestyle.Light, cell.FgColor(cell.ColorBlue)),
|
||||
BorderTitle("title"),
|
||||
BorderTitleAlign(align.HorizontalRight),
|
||||
},
|
||||
@ -273,7 +274,7 @@ func TestGauge(t *testing.T) {
|
||||
desc: "gauge showing 100 percent with border",
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 100},
|
||||
canvas: image.Rect(0, 0, 10, 3),
|
||||
@ -622,7 +623,7 @@ func TestGauge(t *testing.T) {
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
TextLabel("long label"),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 0},
|
||||
canvas: image.Rect(0, 0, 10, 3),
|
||||
@ -666,7 +667,7 @@ func TestGauge(t *testing.T) {
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
TextLabel("long label"),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 100},
|
||||
canvas: image.Rect(0, 0, 10, 3),
|
||||
@ -717,7 +718,7 @@ func TestGauge(t *testing.T) {
|
||||
opts: []Option{
|
||||
Char('o'),
|
||||
TextLabel("long label"),
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
},
|
||||
percent: &percentCall{p: 50},
|
||||
canvas: image.Rect(0, 0, 10, 4),
|
||||
@ -832,7 +833,7 @@ func TestOptions(t *testing.T) {
|
||||
{
|
||||
desc: "border is accounted for in maximum and minimum size",
|
||||
opts: []Option{
|
||||
Border(draw.LineStyleLight),
|
||||
Border(linestyle.Light),
|
||||
Height(2),
|
||||
},
|
||||
want: widgetapi.Options{
|
||||
|
@ -21,11 +21,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/mum4k/termdash"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/container"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/internal/terminal/termbox"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
"github.com/mum4k/termdash/terminal/termbox"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/gauge"
|
||||
)
|
||||
|
||||
@ -88,7 +88,7 @@ func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
slim, err := gauge.New(
|
||||
gauge.Height(1),
|
||||
gauge.Border(draw.LineStyleLight),
|
||||
gauge.Border(linestyle.Light),
|
||||
gauge.BorderTitle("Percentage progress"),
|
||||
)
|
||||
if err != nil {
|
||||
@ -99,7 +99,7 @@ func main() {
|
||||
absolute, err := gauge.New(
|
||||
gauge.Height(1),
|
||||
gauge.Color(cell.ColorBlue),
|
||||
gauge.Border(draw.LineStyleLight),
|
||||
gauge.Border(linestyle.Light),
|
||||
gauge.BorderTitle("Absolute progress"),
|
||||
)
|
||||
if err != nil {
|
||||
@ -109,7 +109,7 @@ func main() {
|
||||
|
||||
noProgress, err := gauge.New(
|
||||
gauge.Height(1),
|
||||
gauge.Border(draw.LineStyleLight, cell.FgColor(cell.ColorMagenta)),
|
||||
gauge.Border(linestyle.Light, cell.FgColor(cell.ColorMagenta)),
|
||||
gauge.BorderTitle("Without progress text"),
|
||||
gauge.HideTextProgress(),
|
||||
)
|
||||
@ -134,7 +134,7 @@ func main() {
|
||||
t,
|
||||
container.SplitVertical(
|
||||
container.Left(
|
||||
container.Border(draw.LineStyleLight),
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("PRESS Q TO QUIT"),
|
||||
container.SplitHorizontal(
|
||||
container.Top(
|
||||
|
@ -19,9 +19,10 @@ package gauge
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/internal/cell"
|
||||
"github.com/mum4k/termdash/align"
|
||||
"github.com/mum4k/termdash/cell"
|
||||
"github.com/mum4k/termdash/internal/draw"
|
||||
"github.com/mum4k/termdash/linestyle"
|
||||
)
|
||||
|
||||
// Option is used to provide options.
|
||||
@ -42,7 +43,7 @@ type options struct {
|
||||
filledTextColor cell.Color
|
||||
emptyTextColor cell.Color
|
||||
// If set, draws a border around the gauge.
|
||||
border draw.LineStyle
|
||||
border linestyle.LineStyle
|
||||
borderCellOpts []cell.Option
|
||||
borderTitle string
|
||||
borderTitleHAlign align.Horizontal
|
||||
@ -179,7 +180,7 @@ func VerticalTextAlign(v align.Vertical) Option {
|
||||
}
|
||||
|
||||
// Border configures the gauge to have a border of the specified style.
|
||||
func Border(ls draw.LineStyle, cOpts ...cell.Option) Option {
|
||||
func Border(ls linestyle.LineStyle, cOpts ...cell.Option) Option {
|
||||
return option(func(opts *options) {
|
||||
opts.border = ls
|
||||
opts.borderCellOpts = cOpts
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/mum4k/termdash/internal/align"
|
||||
"github.com/mum4k/termdash/align"
|
||||
)
|
||||
|
||||
// LabelOrientation represents the orientation of text labels.
|
||||
|
@ -20,10 +20,10 @@ import (
|
||||
"image"
|
||||
"reflect"
|
||||
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/mouse/button"
|
||||
"github.com/mum4k/termdash/internal/button"
|
||||
"github.com/mum4k/termdash/internal/numbers"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/linechart/internal/axes"
|
||||
)
|
||||
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"github.com/mum4k/termdash/internal/mouse"
|
||||
"github.com/mum4k/termdash/internal/terminalapi"
|
||||
"github.com/mum4k/termdash/mouse"
|
||||
"github.com/mum4k/termdash/terminal/terminalapi"
|
||||
"github.com/mum4k/termdash/widgets/linechart/internal/axes"
|
||||
)
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user