From f62bf806868e25a74b1794c9ab9fbb647d9858c4 Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Wed, 9 May 2018 21:37:01 +0100 Subject: [PATCH 1/5] Deleting binary file. --- widgets/gauge/demo/gaugedemo | Bin 4481 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 widgets/gauge/demo/gaugedemo diff --git a/widgets/gauge/demo/gaugedemo b/widgets/gauge/demo/gaugedemo deleted file mode 100644 index 4e80940c83a78d5abc5a83dbc34e8bd88b640531..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4481 zcmc&%U2GIp6dp@swPiIS8bij!A&RcVaPOVJ-DLv^(PY#_z_uV=Fz)Wm&X(@%HoLQd zCpAQa8cAx>hsH=ykk=*<6Jz45hUmM#fRg$G51>!}AP=5%@BG}U6CZ5VcG|t?eBZt2 z-0z+^9P=b3jW3(5nEqNqpBDy{bY#tupef7Byq0lxxxF~S+gTMa@P(W!a_=jhy5 zXQXKpt0Lyykk&NB9GBD$VlaVkoJwPw9JgDfVGvgrxGCWl$6bSzA%r3D840&JUb0EE zL>eW5zb@e=j(e2wN8slryv*?iCHxWiWeKlvJl!*DatrVWV@-r;SpharON2llz$0-EA`LH{I^s8F^l52;4i2CIhp@m>hH+@UsHb|$GzdFHJ{gKkG4~M zb)R9)*%F@Db4MjSujejGcwW!ll<>Ts+d7-(m)CPO3D4`f_a!{9=f0Hiyq^0F@W1W3 z;xUPk*K^Y{A+P67%7nb0Tb2oVJ$F?m%(PD(Pb=gKl6ujd*vA+P67%Y?k1`&=UA z_S}y$A+P67b&}r7^xUP?pXs@8Q-7xC{z(0qo_i!n*3b0ZGpRq*bFI{$>A5qf3(7tC zZm8{M)G*uFN7umjD)&)VHS{1D2Ikz;UdNkn*Sn!wqcqq7zX3CY*NEREgMO3vvtfJK z*xu{~g!4)0^#iv)Xp`f!uJ45d;@5}1M_e!H@g*M9KEiwA%7k(k#OkB5_v(Z)0){t0 z%LNM|4~@4XBShoth^IY{*6j%5#Mk<>Dq)ciiv9l7wtV@Z$LZXc?6NU-S2%2=quABeAU7@ zT1qgYJOtc=S~Gkt`cj>Egp?Ve)PRzD*L{Rx-h?m(2;&sgrdr!F4;5lm5m*M`UI5IF zT7#cmg>&G%u8k=VV^Ua0W~GgvZFMJn=oauCwWdFhycf2NDO${|i|_4!>DkFiw93u_?xfDtK0Yv<1Jln3?htffZy0KE z6fN{lgzFIsY9l8|iw4hm3(NIr&8iQVE z7((%)Q~yi#LPr3Qtd`V0MgfEI(tr^Z3960Gh#Z%#flX~zEvzD~cpU1N*R0m5H@uEk z@48yIr!{)`F1QHqf~Vj%=(}G3$yg+oRO4EXZwZos3XVFOMHLE8J9Q?0~%m(rA?y4yj zn1XnH+n92WzrwAm!EdH`A^t*O@J7haw3rmkWO(RMH@1@`V49*3_-gTF$g1M7Qf!KO zP(so?BP}2!%Yz*P53~L0_ITcIER2Qthak`g(QZ(bR2IG)Jy}->XIaQeobhI0X5x!B z1My>`VJ0A-0K1STNV~AJJaJB+K$ceinOJ2Ag7{Z2jw+j?YgLE)7H-|PSPRj^`$iR; zqx>F@?r5YjxWBncZEjMAw>4bhl&=Dxw1X>r8jk)ae-d7RSf!gI%H5EycVadyjQ Date: Fri, 11 May 2018 16:32:37 +0100 Subject: [PATCH 2/5] Fixing lint errors. - Missing comments. - Invalid comments. - Stuttering public name. --- cell/color.go | 1 + container/container.go | 9 +++-- draw/line_style.go | 1 + eventqueue/eventqueue.go | 4 +-- mouse/mouse.go | 1 + terminal/faketerm/faketerm.go | 16 ++++----- terminal/termbox/termbox.go | 17 ++++----- terminalapi/color_mode.go | 1 + widgets/fakewidget/fakewidget_test.go | 52 +++++++++++++-------------- widgets/gauge/gauge_test.go | 52 +++++++++++++-------------- widgets/gauge/options.go | 10 +++--- 11 files changed, 84 insertions(+), 80 deletions(-) diff --git a/cell/color.go b/cell/color.go index ab0a5d0..9e1e04c 100644 --- a/cell/color.go +++ b/cell/color.go @@ -40,6 +40,7 @@ var colorNames = map[Color]string{ ColorWhite: "ColorWhite", } +// The supported terminal colors. const ( ColorDefault Color = iota ColorBlack diff --git a/container/container.go b/container/container.go index 214afff..a4113a7 100644 --- a/container/container.go +++ b/container/container.go @@ -105,9 +105,8 @@ func (c *Container) hasWidget() bool { func (c *Container) usable() image.Rectangle { if c.hasBorder() { return area.ExcludeBorder(c.area) - } else { - return c.area } + return c.area } // widgetArea returns the area in the container that is available for the @@ -142,11 +141,11 @@ func (c *Container) widgetArea() (image.Rectangle, error) { // split splits the container's usable area into child areas. // Panics if the container isn't configured for a split. func (c *Container) split() (image.Rectangle, image.Rectangle) { - if ar := c.usable(); c.opts.split == splitTypeVertical { + ar := c.usable() + if c.opts.split == splitTypeVertical { return area.VSplit(ar) - } else { - return area.HSplit(ar) } + return area.HSplit(ar) } // createFirst creates and returns the first sub container of this container. diff --git a/draw/line_style.go b/draw/line_style.go index 4940dc4..f8dfa48 100644 --- a/draw/line_style.go +++ b/draw/line_style.go @@ -56,6 +56,7 @@ var lineStyleNames = map[LineStyle]string{ LineStyleLight: "LineStyleLight", } +// Supported line styles. const ( LineStyleNone LineStyle = iota LineStyleLight diff --git a/eventqueue/eventqueue.go b/eventqueue/eventqueue.go index 2eaa909..da7d320 100644 --- a/eventqueue/eventqueue.go +++ b/eventqueue/eventqueue.go @@ -80,7 +80,7 @@ func (u *Unbound) empty() bool { return u.first == nil } -// Put puts an event onto the queue. +// Push pushes an event onto the queue. func (u *Unbound) Push(e terminalapi.Event) { u.mu.Lock() defer u.mu.Unlock() @@ -98,7 +98,7 @@ func (u *Unbound) Push(e terminalapi.Event) { u.cond.Signal() } -// Get gets an event from the queue. Returns nil if the queue is empty. +// Pop pops an event from the queue. Returns nil if the queue is empty. func (u *Unbound) Pop() terminalapi.Event { u.mu.Lock() defer u.mu.Unlock() diff --git a/mouse/mouse.go b/mouse/mouse.go index 6aacf5b..0d3b08a 100644 --- a/mouse/mouse.go +++ b/mouse/mouse.go @@ -36,6 +36,7 @@ var buttonNames = map[Button]string{ ButtonWheelDown: "ButtonWheelDown", } +// Buttons recognized on the mouse. const ( buttonUnknown Button = iota ButtonLeft diff --git a/terminal/faketerm/faketerm.go b/terminal/faketerm/faketerm.go index 1b0ee0f..22fa15e 100644 --- a/terminal/faketerm/faketerm.go +++ b/terminal/faketerm/faketerm.go @@ -132,7 +132,7 @@ func (t *Terminal) String() string { return b.String() } -// Implements terminalapi.Terminal.Size. +// Size implements terminalapi.Terminal.Size. func (t *Terminal) Size() image.Point { t.mu.Lock() defer t.mu.Unlock() @@ -146,7 +146,7 @@ func (t *Terminal) Area() image.Rectangle { return image.Rect(0, 0, s.X, s.Y) } -// Implements terminalapi.Terminal.Clear. +// Clear implements terminalapi.Terminal.Clear. func (t *Terminal) Clear(opts ...cell.Option) error { t.mu.Lock() defer t.mu.Unlock() @@ -159,22 +159,22 @@ func (t *Terminal) Clear(opts ...cell.Option) error { return nil } -// Implements terminalapi.Terminal.Flush. +// Flush implements terminalapi.Terminal.Flush. func (t *Terminal) Flush() error { return nil // nowhere to flush to. } -// Implements terminalapi.Terminal.SetCursor. +// SetCursor implements terminalapi.Terminal.SetCursor. func (t *Terminal) SetCursor(p image.Point) { log.Fatal("unimplemented") } -// Implements terminalapi.Terminal.HideCursor. +// HideCursor implements terminalapi.Terminal.HideCursor. func (t *Terminal) HideCursor() { log.Fatal("unimplemented") } -// Implements terminalapi.Terminal.SetCell. +// SetCell implements terminalapi.Terminal.SetCell. func (t *Terminal) SetCell(p image.Point, r rune, opts ...cell.Option) error { t.mu.Lock() defer t.mu.Unlock() @@ -193,7 +193,7 @@ func (t *Terminal) SetCell(p image.Point, r rune, opts ...cell.Option) error { return nil } -// Implements terminalapi.Terminal.Event. +// Event implements terminalapi.Terminal.Event. func (t *Terminal) Event(ctx context.Context) terminalapi.Event { if t.events == nil { return terminalapi.NewErrorf("no event queue provided, use the WithEventQueue option when creating the fake terminal") @@ -210,5 +210,5 @@ func (t *Terminal) Event(ctx context.Context) terminalapi.Event { return ev } -// Closes the terminal. This is a no-op on the fake terminal. +// Close closes the terminal. This is a no-op on the fake terminal. func (t *Terminal) Close() {} diff --git a/terminal/termbox/termbox.go b/terminal/termbox/termbox.go index 3b2a6b0..29a5e56 100644 --- a/terminal/termbox/termbox.go +++ b/terminal/termbox/termbox.go @@ -86,13 +86,13 @@ func New(opts ...Option) (*Terminal, error) { return t, nil } -// Implements terminalapi.Terminal.Size. +// Size implements terminalapi.Terminal.Size. func (t *Terminal) Size() image.Point { w, h := tbx.Size() return image.Point{w, h} } -// Implements terminalapi.Terminal.Clear. +// Clear implements terminalapi.Terminal.Clear. func (t *Terminal) Clear(opts ...cell.Option) error { o := cell.NewOptions(opts...) fg, err := cellOptsToFg(o) @@ -107,22 +107,22 @@ func (t *Terminal) Clear(opts ...cell.Option) error { return tbx.Clear(fg, bg) } -// Implements terminalapi.Terminal.Flush. +// Flush implements terminalapi.Terminal.Flush. func (t *Terminal) Flush() error { return tbx.Flush() } -// Implements terminalapi.Terminal.SetCursor. +// SetCursor implements terminalapi.Terminal.SetCursor. func (t *Terminal) SetCursor(p image.Point) { tbx.SetCursor(p.X, p.Y) } -// Implements terminalapi.Terminal.HideCursor. +// HideCursor implements terminalapi.Terminal.HideCursor. func (t *Terminal) HideCursor() { tbx.HideCursor() } -// Implements terminalapi.Terminal.SetCell. +// SetCell implements terminalapi.Terminal.SetCell. func (t *Terminal) SetCell(p image.Point, r rune, opts ...cell.Option) error { o := cell.NewOptions(opts...) fg, err := cellOptsToFg(o) @@ -154,7 +154,7 @@ func (t *Terminal) pollEvents() { } } -// Implements terminalapi.Terminal.Event. +// Event implements terminalapi.Terminal.Event. func (t *Terminal) Event(ctx context.Context) terminalapi.Event { ev, err := t.events.Pull(ctx) if err != nil { @@ -163,8 +163,9 @@ func (t *Terminal) Event(ctx context.Context) terminalapi.Event { return ev } -// Closes the terminal, should be called when the terminal isn't required +// Close closes the terminal, should be called when the terminal isn't required // anymore to return the screen to a sane state. +// Implements terminalapi.Terminal.Close. func (t *Terminal) Close() { close(t.done) tbx.Close() diff --git a/terminalapi/color_mode.go b/terminalapi/color_mode.go index 5cf251f..d31ce43 100644 --- a/terminalapi/color_mode.go +++ b/terminalapi/color_mode.go @@ -35,6 +35,7 @@ var colorModeNames = map[ColorMode]string{ ColorModeGrayscale: "ColorModeGrayscale", } +// Supported color modes. const ( ColorMode8 ColorMode = iota ColorMode256 diff --git a/widgets/fakewidget/fakewidget_test.go b/widgets/fakewidget/fakewidget_test.go index 2f75ae3..1ecc201 100644 --- a/widgets/fakewidget/fakewidget_test.go +++ b/widgets/fakewidget/fakewidget_test.go @@ -29,26 +29,26 @@ import ( "github.com/mum4k/termdash/widgetapi" ) -// kEvents are keyboard events to send to the widget. -type kEvents struct { +// keyEvents are keyboard events to send to the widget. +type keyEvents struct { k *terminalapi.Keyboard wantErr bool } -// mEvents are mouse events to send to the widget. -type mEvents struct { +// mouseEvents are mouse events to send to the widget. +type mouseEvents struct { m *terminalapi.Mouse wantErr bool } func TestMirror(t *testing.T) { tests := []struct { - desc string - kEvents []kEvents // Keyboard events to send before calling Draw(). - mEvents []mEvents // Mouse events to send before calling Draw(). - cvs *canvas.Canvas - want func(size image.Point) *faketerm.Terminal - wantErr bool + desc string + keyEvents []keyEvents // Keyboard events to send before calling Draw(). + mouseEvents []mouseEvents // Mouse events to send before calling Draw(). + cvs *canvas.Canvas + want func(size image.Point) *faketerm.Terminal + wantErr bool }{ { desc: "canvas too small to draw a box", @@ -91,7 +91,7 @@ func TestMirror(t *testing.T) { }, { desc: "draws the last keyboard event", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnter}, }, @@ -112,7 +112,7 @@ func TestMirror(t *testing.T) { }, { desc: "skips the keyboard event if there isn't a line for it", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnd}, }, @@ -129,7 +129,7 @@ func TestMirror(t *testing.T) { }, { desc: "draws the last mouse event", - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -152,7 +152,7 @@ func TestMirror(t *testing.T) { }, { desc: "skips the mouse event if there isn't a line for it", - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -169,12 +169,12 @@ func TestMirror(t *testing.T) { }, { desc: "draws both keyboard and mouse events", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnter}, }, }, - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -193,7 +193,7 @@ func TestMirror(t *testing.T) { }, { desc: "KeyEsc and ButtonRight reset the last event and return error", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnter}, }, @@ -202,7 +202,7 @@ func TestMirror(t *testing.T) { wantErr: true, }, }, - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -227,17 +227,17 @@ func TestMirror(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { w := New(widgetapi.Options{}) - for _, kEv := range tc.kEvents { - err := w.Keyboard(kEv.k) - if (err != nil) != kEv.wantErr { - t.Errorf("Keyboard => got error:%v, wantErr: %v", err, kEv.wantErr) + for _, keyEv := range tc.keyEvents { + err := w.Keyboard(keyEv.k) + if (err != nil) != keyEv.wantErr { + t.Errorf("Keyboard => got error:%v, wantErr: %v", err, keyEv.wantErr) } } - for _, mEv := range tc.mEvents { - err := w.Mouse(mEv.m) - if (err != nil) != mEv.wantErr { - t.Errorf("Mouse => got error:%v, wantErr: %v", err, mEv.wantErr) + for _, mouseEv := range tc.mouseEvents { + err := w.Mouse(mouseEv.m) + if (err != nil) != mouseEv.wantErr { + t.Errorf("Mouse => got error:%v, wantErr: %v", err, mouseEv.wantErr) } } diff --git a/widgets/gauge/gauge_test.go b/widgets/gauge/gauge_test.go index f39423c..1357eb7 100644 --- a/widgets/gauge/gauge_test.go +++ b/widgets/gauge/gauge_test.go @@ -57,7 +57,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing percentage", gauge: New( - GaugeChar('o'), + Char('o'), ), percent: &percentCall{p: 35}, canvas: image.Rect(0, 0, 10, 3), @@ -77,7 +77,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text top and left", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalLeft), VerticalTextAlign(align.VerticalTop), ), @@ -95,7 +95,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text top and left with border", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalLeft), VerticalTextAlign(align.VerticalTop), Border(draw.LineStyleLight), @@ -115,7 +115,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text bottom and right", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalRight), VerticalTextAlign(align.VerticalBottom), ), @@ -133,7 +133,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text bottom and right with border", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalRight), VerticalTextAlign(align.VerticalBottom), Border(draw.LineStyleLight), @@ -153,7 +153,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing percentage with border", gauge: New( - GaugeChar('o'), + Char('o'), Border(draw.LineStyleLight), BorderTitle("title"), ), @@ -178,7 +178,7 @@ func TestGauge(t *testing.T) { { desc: "respects border options", gauge: New( - GaugeChar('o'), + Char('o'), Border(draw.LineStyleLight, cell.FgColor(cell.ColorBlue)), BorderTitle("title"), BorderTitleAlign(align.HorizontalRight), @@ -206,7 +206,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing zero percentage", gauge: New( - GaugeChar('o'), + Char('o'), ), percent: &percentCall{}, canvas: image.Rect(0, 0, 10, 3), @@ -222,7 +222,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing 100 percent", gauge: New( - GaugeChar('o'), + Char('o'), ), percent: &percentCall{p: 100}, canvas: image.Rect(0, 0, 10, 3), @@ -244,7 +244,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing 100 percent with border", gauge: New( - GaugeChar('o'), + Char('o'), Border(draw.LineStyleLight), ), percent: &percentCall{p: 100}, @@ -268,7 +268,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing absolute progress", gauge: New( - GaugeChar('o'), + Char('o'), ), absolute: &absoluteCall{done: 20, total: 100}, canvas: image.Rect(0, 0, 10, 3), @@ -288,7 +288,7 @@ func TestGauge(t *testing.T) { { desc: "gauge without text progress", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), percent: &percentCall{p: 35}, @@ -308,7 +308,7 @@ func TestGauge(t *testing.T) { { desc: "passing option to Percent() overrides one provided to New()", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), percent: &percentCall{p: 35, opts: []Option{ShowTextProgress()}}, @@ -329,7 +329,7 @@ func TestGauge(t *testing.T) { { desc: "passing option to Absolute() overrides one provided to New()", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), absolute: &absoluteCall{done: 20, total: 100, opts: []Option{ShowTextProgress()}}, @@ -350,7 +350,7 @@ func TestGauge(t *testing.T) { { desc: "gauge takes full size of the canvas", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), percent: &percentCall{p: 100}, @@ -370,7 +370,7 @@ func TestGauge(t *testing.T) { { desc: "gauge with text label", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), TextLabel("label"), ), @@ -394,7 +394,7 @@ func TestGauge(t *testing.T) { { desc: "gauge with progress text and text label", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), ), percent: &percentCall{p: 100}, @@ -417,7 +417,7 @@ func TestGauge(t *testing.T) { { desc: "text fully outside of gauge respects EmptyTextColor", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), EmptyTextColor(cell.ColorMagenta), FilledTextColor(cell.ColorBlue), @@ -442,7 +442,7 @@ func TestGauge(t *testing.T) { { desc: "text fully inside of gauge respects FilledTextColor", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), EmptyTextColor(cell.ColorMagenta), FilledTextColor(cell.ColorBlue), @@ -467,7 +467,7 @@ func TestGauge(t *testing.T) { { desc: "part of the text is inside and part outside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), EmptyTextColor(cell.ColorMagenta), FilledTextColor(cell.ColorBlue), @@ -495,7 +495,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is outside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), ), percent: &percentCall{p: 0}, @@ -514,7 +514,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is outside of gauge when drawn with border", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), Border(draw.LineStyleLight), ), @@ -535,7 +535,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), ), percent: &percentCall{p: 100}, @@ -558,7 +558,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside of gauge when drawn with border", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), Border(draw.LineStyleLight), ), @@ -583,7 +583,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside and outside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), ), percent: &percentCall{p: 50}, @@ -609,7 +609,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside and outside of gauge with border", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), Border(draw.LineStyleLight), ), diff --git a/widgets/gauge/options.go b/widgets/gauge/options.go index 7f20e9b..f96f674 100644 --- a/widgets/gauge/options.go +++ b/widgets/gauge/options.go @@ -65,12 +65,12 @@ func (o option) set(opts *options) { o(opts) } -// DefaultGaugeChar is the default value for the GaugeChar option. -const DefaultGaugeChar = draw.DefaultRectChar +// DefaultChar is the default value for the Char option. +const DefaultChar = draw.DefaultRectChar -// GaugeChar sets the rune that is used when drawing the rectangle representing -// the current progress. -func GaugeChar(ch rune) Option { +// Char sets the rune that is used when drawing the rectangle representing the +// current progress. +func Char(ch rune) Option { return option(func(opts *options) { opts.gaugeChar = ch }) From ec590d6149ba178246055d0790c2f1f4d17c6bee Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Mon, 14 May 2018 01:57:00 +0100 Subject: [PATCH 3/5] Adding missing keyword. --- doc/widget_development.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/widget_development.md b/doc/widget_development.md index b7dc0c0..8e93fae 100644 --- a/doc/widget_development.md +++ b/doc/widget_development.md @@ -56,7 +56,7 @@ A typical unit test creates the expected fake terminal, executes the widget to get the actual fake terminal and compares the two: ```go -TestWidget(t *testing.T) { +func TestWidget(t *testing.T) { tests := []struct { desc string canvas image.Rectangle From bf751529c4647f9cf50b7add6685c6e21fe709af Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Mon, 14 May 2018 21:42:25 +0100 Subject: [PATCH 4/5] Adding a disclaimer. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a43cbd9..8b287c2 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,7 @@ development](doc/widget_development.md) section. Run the [gaugedemo](widgets/gauge/demo/gaugedemo.go). [gaugedemo](widgets/gauge/demo/gaugedemo.go) + +## Disclaimer + +This is not an official Google product. From b98013ea45a0910b1690f51477199fa58162aeb5 Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Mon, 14 May 2018 22:32:07 +0100 Subject: [PATCH 5/5] Removing commit that doesn't belong to this history. --- container/draw.go | 3 +- draw/border.go | 3 +- draw/line_style.go | 1 + draw/testdraw/testdraw.go | 7 ++-- draw/text.go | 13 ++++--- draw/text_test.go | 39 +++++++++----------- widgets/fakewidget/fakewidget.go | 3 +- widgets/fakewidget/fakewidget_test.go | 52 +++++++++++++-------------- widgets/gauge/gauge.go | 13 +++---- widgets/gauge/gauge_test.go | 52 +++++++++++++-------------- widgets/gauge/options.go | 10 +++--- 11 files changed, 91 insertions(+), 105 deletions(-) diff --git a/container/draw.go b/container/draw.go index 9275b4f..91f1e6b 100644 --- a/container/draw.go +++ b/container/draw.go @@ -133,8 +133,7 @@ func drawResize(c *Container, area image.Rectangle) error { return err } - _, err = draw.Text(cvs, "⇄", image.Point{0, 0}) - if err != nil { + if err := draw.Text(cvs, "⇄", image.Point{0, 0}); err != nil { return err } return cvs.Apply(c.term) diff --git a/draw/border.go b/draw/border.go index cf72282..b885526 100644 --- a/draw/border.go +++ b/draw/border.go @@ -124,13 +124,12 @@ func drawTitle(c *canvas.Canvas, border image.Rectangle, opt *borderOptions) err return err } - _, err = Text( + return Text( c, opt.title, start, TextCellOpts(opt.titleCellOpts...), TextOverrunMode(opt.titleOM), TextMaxX(available.Max.X), ) - return err } // Border draws a border on the canvas. diff --git a/draw/line_style.go b/draw/line_style.go index 4940dc4..f8dfa48 100644 --- a/draw/line_style.go +++ b/draw/line_style.go @@ -56,6 +56,7 @@ var lineStyleNames = map[LineStyle]string{ LineStyleLight: "LineStyleLight", } +// Supported line styles. const ( LineStyleNone LineStyle = iota LineStyleLight diff --git a/draw/testdraw/testdraw.go b/draw/testdraw/testdraw.go index 241eba2..b47d490 100644 --- a/draw/testdraw/testdraw.go +++ b/draw/testdraw/testdraw.go @@ -31,13 +31,10 @@ func MustBorder(c *canvas.Canvas, border image.Rectangle, opts ...draw.BorderOpt } // MustText draws the text on the canvas or panics. -// Returns the number of written cells. -func MustText(c *canvas.Canvas, text string, start image.Point, opts ...draw.TextOption) int { - cells, err := draw.Text(c, text, start, opts...) - if err != nil { +func MustText(c *canvas.Canvas, text string, start image.Point, opts ...draw.TextOption) { + if err := draw.Text(c, text, start, opts...); err != nil { panic(fmt.Sprintf("draw.Text => unexpected error: %v", err)) } - return cells } // MustRectangle draws the rectangle on the canvas or panics. diff --git a/draw/text.go b/draw/text.go index 38956bb..913f079 100644 --- a/draw/text.go +++ b/draw/text.go @@ -125,11 +125,10 @@ func bounds(text string, maxRunes int, om OverrunMode) (string, error) { } // Text prints the provided text on the canvas starting at the provided point. -// Returns the number of cells written. -func Text(c *canvas.Canvas, text string, start image.Point, opts ...TextOption) (int, error) { +func Text(c *canvas.Canvas, text string, start image.Point, opts ...TextOption) error { ar := c.Area() if !start.In(ar) { - return -1, fmt.Errorf("the requested start point %v falls outside of the provided canvas %v", start, ar) + return fmt.Errorf("the requested start point %v falls outside of the provided canvas %v", start, ar) } opt := &textOptions{} @@ -138,7 +137,7 @@ func Text(c *canvas.Canvas, text string, start image.Point, opts ...TextOption) } if opt.maxX < 0 || opt.maxX > ar.Max.X { - return -1, fmt.Errorf("invalid TextMaxX(%v), must be a positive number that is <= canvas.width %v", opt.maxX, ar.Dx()) + return fmt.Errorf("invalid TextMaxX(%v), must be a positive number that is <= canvas.width %v", opt.maxX, ar.Dx()) } var wantMaxX int @@ -151,15 +150,15 @@ func Text(c *canvas.Canvas, text string, start image.Point, opts ...TextOption) maxRunes := wantMaxX - start.X trimmed, err := bounds(text, maxRunes, opt.overrunMode) if err != nil { - return -1, err + return err } cur := start for _, r := range trimmed { if err := c.SetCell(cur, r, opt.cellOpts...); err != nil { - return -1, err + return err } cur = image.Point{cur.X + 1, cur.Y} } - return cur.X - start.X, nil + return nil } diff --git a/draw/text_test.go b/draw/text_test.go index 05693df..cbc9e34 100644 --- a/draw/text_test.go +++ b/draw/text_test.go @@ -26,14 +26,13 @@ import ( func TestText(t *testing.T) { tests := []struct { - desc string - canvas image.Rectangle - text string - start image.Point - opts []TextOption - want func(size image.Point) *faketerm.Terminal - wantCells int - wantErr bool + desc string + canvas image.Rectangle + text string + start image.Point + opts []TextOption + want func(size image.Point) *faketerm.Terminal + wantErr bool }{ { desc: "start falls outside of the canvas", @@ -65,7 +64,6 @@ func TestText(t *testing.T) { want: func(size image.Point) *faketerm.Terminal { return faketerm.MustNew(size) }, - wantCells: 0, }, { desc: "text falls outside of the canvas on OverrunModeStrict", @@ -93,7 +91,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 1, }, { desc: "OverrunModeTrim trims longer text", @@ -112,7 +109,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 2, }, { desc: "text falls outside of the canvas on OverrunModeThreeDot", @@ -130,7 +126,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 1, }, { desc: "OverrunModeThreeDot trims longer text", @@ -149,7 +144,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 2, }, { desc: "requested MaxX is negative", @@ -190,6 +184,15 @@ func TestText(t *testing.T) { }, wantErr: true, }, + { + desc: "text is empty, nothing to do", + canvas: image.Rect(0, 0, 1, 1), + text: "", + start: image.Point{0, 0}, + want: func(size image.Point) *faketerm.Terminal { + return faketerm.MustNew(size) + }, + }, { desc: "draws text", canvas: image.Rect(0, 0, 3, 2), @@ -204,7 +207,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 2, }, { desc: "draws text with cell options", @@ -223,7 +225,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 2, }, { desc: "draws unicode character", @@ -238,7 +239,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 1, }, { desc: "draws multiple unicode characters", @@ -255,7 +255,6 @@ func TestText(t *testing.T) { testcanvas.MustApply(c, ft) return ft }, - wantCells: 3, }, } @@ -266,7 +265,7 @@ func TestText(t *testing.T) { t.Fatalf("canvas.New => unexpected error: %v", err) } - gotCells, err := Text(c, tc.text, tc.start, tc.opts...) + err = Text(c, tc.text, tc.start, tc.opts...) if (err != nil) != tc.wantErr { t.Errorf("Text => unexpected error: %v, wantErr: %v", err, tc.wantErr) } @@ -286,10 +285,6 @@ func TestText(t *testing.T) { if diff := faketerm.Diff(tc.want(c.Size()), got); diff != "" { t.Errorf("Text => %v", diff) } - - if gotCells != tc.wantCells { - t.Errorf("Text => unexpected number of cells, got %d, want %d", gotCells, tc.wantCells) - } }) } } diff --git a/widgets/fakewidget/fakewidget.go b/widgets/fakewidget/fakewidget.go index 9c133a8..b03fd08 100644 --- a/widgets/fakewidget/fakewidget.go +++ b/widgets/fakewidget/fakewidget.go @@ -96,8 +96,7 @@ func (mi *Mirror) Draw(cvs *canvas.Canvas) error { break } - _, err := draw.Text(cvs, mi.lines[i], start, draw.TextMaxX(usable.Max.X)) - if err != nil { + if err := draw.Text(cvs, mi.lines[i], start, draw.TextMaxX(usable.Max.X)); err != nil { return err } start = image.Point{start.X, start.Y + 1} diff --git a/widgets/fakewidget/fakewidget_test.go b/widgets/fakewidget/fakewidget_test.go index 2f75ae3..1ecc201 100644 --- a/widgets/fakewidget/fakewidget_test.go +++ b/widgets/fakewidget/fakewidget_test.go @@ -29,26 +29,26 @@ import ( "github.com/mum4k/termdash/widgetapi" ) -// kEvents are keyboard events to send to the widget. -type kEvents struct { +// keyEvents are keyboard events to send to the widget. +type keyEvents struct { k *terminalapi.Keyboard wantErr bool } -// mEvents are mouse events to send to the widget. -type mEvents struct { +// mouseEvents are mouse events to send to the widget. +type mouseEvents struct { m *terminalapi.Mouse wantErr bool } func TestMirror(t *testing.T) { tests := []struct { - desc string - kEvents []kEvents // Keyboard events to send before calling Draw(). - mEvents []mEvents // Mouse events to send before calling Draw(). - cvs *canvas.Canvas - want func(size image.Point) *faketerm.Terminal - wantErr bool + desc string + keyEvents []keyEvents // Keyboard events to send before calling Draw(). + mouseEvents []mouseEvents // Mouse events to send before calling Draw(). + cvs *canvas.Canvas + want func(size image.Point) *faketerm.Terminal + wantErr bool }{ { desc: "canvas too small to draw a box", @@ -91,7 +91,7 @@ func TestMirror(t *testing.T) { }, { desc: "draws the last keyboard event", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnter}, }, @@ -112,7 +112,7 @@ func TestMirror(t *testing.T) { }, { desc: "skips the keyboard event if there isn't a line for it", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnd}, }, @@ -129,7 +129,7 @@ func TestMirror(t *testing.T) { }, { desc: "draws the last mouse event", - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -152,7 +152,7 @@ func TestMirror(t *testing.T) { }, { desc: "skips the mouse event if there isn't a line for it", - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -169,12 +169,12 @@ func TestMirror(t *testing.T) { }, { desc: "draws both keyboard and mouse events", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnter}, }, }, - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -193,7 +193,7 @@ func TestMirror(t *testing.T) { }, { desc: "KeyEsc and ButtonRight reset the last event and return error", - kEvents: []kEvents{ + keyEvents: []keyEvents{ { k: &terminalapi.Keyboard{Key: keyboard.KeyEnter}, }, @@ -202,7 +202,7 @@ func TestMirror(t *testing.T) { wantErr: true, }, }, - mEvents: []mEvents{ + mouseEvents: []mouseEvents{ { m: &terminalapi.Mouse{Button: mouse.ButtonLeft}, }, @@ -227,17 +227,17 @@ func TestMirror(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { w := New(widgetapi.Options{}) - for _, kEv := range tc.kEvents { - err := w.Keyboard(kEv.k) - if (err != nil) != kEv.wantErr { - t.Errorf("Keyboard => got error:%v, wantErr: %v", err, kEv.wantErr) + for _, keyEv := range tc.keyEvents { + err := w.Keyboard(keyEv.k) + if (err != nil) != keyEv.wantErr { + t.Errorf("Keyboard => got error:%v, wantErr: %v", err, keyEv.wantErr) } } - for _, mEv := range tc.mEvents { - err := w.Mouse(mEv.m) - if (err != nil) != mEv.wantErr { - t.Errorf("Mouse => got error:%v, wantErr: %v", err, mEv.wantErr) + for _, mouseEv := range tc.mouseEvents { + err := w.Mouse(mouseEv.m) + if (err != nil) != mouseEv.wantErr { + t.Errorf("Mouse => got error:%v, wantErr: %v", err, mouseEv.wantErr) } } diff --git a/widgets/gauge/gauge.go b/widgets/gauge/gauge.go index a78bb02..d95d6fc 100644 --- a/widgets/gauge/gauge.go +++ b/widgets/gauge/gauge.go @@ -204,21 +204,19 @@ func (g *Gauge) drawText(cvs *canvas.Canvas) error { switch { case gaugeEndX < textStart.X: // The text entirely falls outside of the drawn gauge. - _, err := draw.Text(cvs, text, textStart, + return draw.Text(cvs, text, textStart, draw.TextOverrunMode(draw.OverrunModeThreeDot), draw.TextCellOpts(cell.FgColor(g.opts.emptyTextColor)), draw.TextMaxX(ar.Max.X), ) - return err case gaugeEndX >= textEndX: // The text entirely falls inside of the drawn gauge. - _, err := draw.Text(cvs, text, textStart, + return draw.Text(cvs, text, textStart, draw.TextOverrunMode(draw.OverrunModeThreeDot), draw.TextCellOpts(cell.FgColor(g.opts.filledTextColor)), draw.TextMaxX(ar.Max.X), ) - return err default: // Part of the text falls inside of the drawn gauge and part outside. @@ -227,17 +225,16 @@ func (g *Gauge) drawText(cvs *canvas.Canvas) error { insideText := utfText.Slice(0, insideCount) outsideText := utfText.Slice(insideCount, utfText.RuneCount()) - _, err := draw.Text(cvs, insideText, textStart, + if err := draw.Text(cvs, insideText, textStart, draw.TextOverrunMode(draw.OverrunModeTrim), draw.TextCellOpts(cell.FgColor(g.opts.filledTextColor)), - ) - if err != nil { + ); err != nil { return err } outsideStart := image.Point{textStart.X + insideCount, textStart.Y} if outsideStart.In(ar) { - if _, err := draw.Text(cvs, outsideText, outsideStart, + if err := draw.Text(cvs, outsideText, outsideStart, draw.TextOverrunMode(draw.OverrunModeThreeDot), draw.TextCellOpts(cell.FgColor(g.opts.emptyTextColor)), draw.TextMaxX(ar.Max.X), diff --git a/widgets/gauge/gauge_test.go b/widgets/gauge/gauge_test.go index f39423c..1357eb7 100644 --- a/widgets/gauge/gauge_test.go +++ b/widgets/gauge/gauge_test.go @@ -57,7 +57,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing percentage", gauge: New( - GaugeChar('o'), + Char('o'), ), percent: &percentCall{p: 35}, canvas: image.Rect(0, 0, 10, 3), @@ -77,7 +77,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text top and left", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalLeft), VerticalTextAlign(align.VerticalTop), ), @@ -95,7 +95,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text top and left with border", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalLeft), VerticalTextAlign(align.VerticalTop), Border(draw.LineStyleLight), @@ -115,7 +115,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text bottom and right", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalRight), VerticalTextAlign(align.VerticalBottom), ), @@ -133,7 +133,7 @@ func TestGauge(t *testing.T) { { desc: "aligns the progress text bottom and right with border", gauge: New( - GaugeChar('o'), + Char('o'), HorizontalTextAlign(align.HorizontalRight), VerticalTextAlign(align.VerticalBottom), Border(draw.LineStyleLight), @@ -153,7 +153,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing percentage with border", gauge: New( - GaugeChar('o'), + Char('o'), Border(draw.LineStyleLight), BorderTitle("title"), ), @@ -178,7 +178,7 @@ func TestGauge(t *testing.T) { { desc: "respects border options", gauge: New( - GaugeChar('o'), + Char('o'), Border(draw.LineStyleLight, cell.FgColor(cell.ColorBlue)), BorderTitle("title"), BorderTitleAlign(align.HorizontalRight), @@ -206,7 +206,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing zero percentage", gauge: New( - GaugeChar('o'), + Char('o'), ), percent: &percentCall{}, canvas: image.Rect(0, 0, 10, 3), @@ -222,7 +222,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing 100 percent", gauge: New( - GaugeChar('o'), + Char('o'), ), percent: &percentCall{p: 100}, canvas: image.Rect(0, 0, 10, 3), @@ -244,7 +244,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing 100 percent with border", gauge: New( - GaugeChar('o'), + Char('o'), Border(draw.LineStyleLight), ), percent: &percentCall{p: 100}, @@ -268,7 +268,7 @@ func TestGauge(t *testing.T) { { desc: "gauge showing absolute progress", gauge: New( - GaugeChar('o'), + Char('o'), ), absolute: &absoluteCall{done: 20, total: 100}, canvas: image.Rect(0, 0, 10, 3), @@ -288,7 +288,7 @@ func TestGauge(t *testing.T) { { desc: "gauge without text progress", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), percent: &percentCall{p: 35}, @@ -308,7 +308,7 @@ func TestGauge(t *testing.T) { { desc: "passing option to Percent() overrides one provided to New()", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), percent: &percentCall{p: 35, opts: []Option{ShowTextProgress()}}, @@ -329,7 +329,7 @@ func TestGauge(t *testing.T) { { desc: "passing option to Absolute() overrides one provided to New()", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), absolute: &absoluteCall{done: 20, total: 100, opts: []Option{ShowTextProgress()}}, @@ -350,7 +350,7 @@ func TestGauge(t *testing.T) { { desc: "gauge takes full size of the canvas", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), ), percent: &percentCall{p: 100}, @@ -370,7 +370,7 @@ func TestGauge(t *testing.T) { { desc: "gauge with text label", gauge: New( - GaugeChar('o'), + Char('o'), HideTextProgress(), TextLabel("label"), ), @@ -394,7 +394,7 @@ func TestGauge(t *testing.T) { { desc: "gauge with progress text and text label", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), ), percent: &percentCall{p: 100}, @@ -417,7 +417,7 @@ func TestGauge(t *testing.T) { { desc: "text fully outside of gauge respects EmptyTextColor", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), EmptyTextColor(cell.ColorMagenta), FilledTextColor(cell.ColorBlue), @@ -442,7 +442,7 @@ func TestGauge(t *testing.T) { { desc: "text fully inside of gauge respects FilledTextColor", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), EmptyTextColor(cell.ColorMagenta), FilledTextColor(cell.ColorBlue), @@ -467,7 +467,7 @@ func TestGauge(t *testing.T) { { desc: "part of the text is inside and part outside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("l"), EmptyTextColor(cell.ColorMagenta), FilledTextColor(cell.ColorBlue), @@ -495,7 +495,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is outside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), ), percent: &percentCall{p: 0}, @@ -514,7 +514,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is outside of gauge when drawn with border", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), Border(draw.LineStyleLight), ), @@ -535,7 +535,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), ), percent: &percentCall{p: 100}, @@ -558,7 +558,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside of gauge when drawn with border", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), Border(draw.LineStyleLight), ), @@ -583,7 +583,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside and outside of gauge", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), ), percent: &percentCall{p: 50}, @@ -609,7 +609,7 @@ func TestGauge(t *testing.T) { { desc: "truncates text that is inside and outside of gauge with border", gauge: New( - GaugeChar('o'), + Char('o'), TextLabel("long label"), Border(draw.LineStyleLight), ), diff --git a/widgets/gauge/options.go b/widgets/gauge/options.go index 7f20e9b..f96f674 100644 --- a/widgets/gauge/options.go +++ b/widgets/gauge/options.go @@ -65,12 +65,12 @@ func (o option) set(opts *options) { o(opts) } -// DefaultGaugeChar is the default value for the GaugeChar option. -const DefaultGaugeChar = draw.DefaultRectChar +// DefaultChar is the default value for the Char option. +const DefaultChar = draw.DefaultRectChar -// GaugeChar sets the rune that is used when drawing the rectangle representing -// the current progress. -func GaugeChar(ch rune) Option { +// Char sets the rune that is used when drawing the rectangle representing the +// current progress. +func Char(ch rune) Option { return option(func(opts *options) { opts.gaugeChar = ch })