1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-05-10 19:29:15 +08:00

Merge pull request #197 from mum4k/lint

Fixing lint issues found on Go report card.
This commit is contained in:
Jakub Sobon 2019-04-28 23:09:02 -04:00 committed by GitHub
commit f32921589c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 22 deletions

View File

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `Donut` widget now guarantees spacing between the donut and its label.
### Fixed
- Lint issues found on the Go report card.
## [0.9.0] - 28-Apr-2019
### Added

View File

@ -186,16 +186,16 @@ func Shrink(area image.Rectangle, topCells, rightCells, bottomCells, leftCells i
}
}
shrinked := area
shrinked.Min.X, _ = numbers.MinMaxInts([]int{shrinked.Min.X + leftCells, shrinked.Max.X})
_, shrinked.Max.X = numbers.MinMaxInts([]int{shrinked.Max.X - rightCells, shrinked.Min.X})
shrinked.Min.Y, _ = numbers.MinMaxInts([]int{shrinked.Min.Y + topCells, shrinked.Max.Y})
_, shrinked.Max.Y = numbers.MinMaxInts([]int{shrinked.Max.Y - bottomCells, shrinked.Min.Y})
shrunk := area
shrunk.Min.X, _ = numbers.MinMaxInts([]int{shrunk.Min.X + leftCells, shrunk.Max.X})
_, shrunk.Max.X = numbers.MinMaxInts([]int{shrunk.Max.X - rightCells, shrunk.Min.X})
shrunk.Min.Y, _ = numbers.MinMaxInts([]int{shrunk.Min.Y + topCells, shrunk.Max.Y})
_, shrunk.Max.Y = numbers.MinMaxInts([]int{shrunk.Max.Y - bottomCells, shrunk.Min.Y})
if shrinked.Dx() == 0 || shrinked.Dy() == 0 {
if shrunk.Dx() == 0 || shrunk.Dy() == 0 {
return image.ZR, nil
}
return shrinked, nil
return shrunk, nil
}
// ShrinkPercent returns a new area whose size is reduced by percentage of its

View File

@ -192,15 +192,12 @@ func (d *Donut) drawLabel(cvs *canvas.Canvas, labelAr image.Rectangle) error {
if err != nil {
return err
}
if err := draw.Text(
return draw.Text(
cvs, d.opts.label, start,
draw.TextOverrunMode(draw.OverrunModeThreeDot),
draw.TextMaxX(labelAr.Max.X),
draw.TextCellOpts(d.opts.labelCellOpts...),
); err != nil {
return err
}
return nil
)
}
// Draw draws the Donut widget onto the canvas.

View File

@ -110,15 +110,12 @@ func (ti *TextInput) drawLabel(cvs *canvas.Canvas, labelAr image.Rectangle) erro
if err != nil {
return err
}
if err := draw.Text(
return draw.Text(
cvs, ti.opts.label, start,
draw.TextOverrunMode(draw.OverrunModeThreeDot),
draw.TextMaxX(labelAr.Max.X),
draw.TextCellOpts(ti.opts.labelCellOpts...),
); err != nil {
return err
}
return nil
)
}
// drawField draws the text input field.
@ -131,14 +128,11 @@ func (ti *TextInput) drawField(cvs *canvas.Canvas, text string) error {
text = hideText(text, ti.opts.hideTextWith)
}
if err := draw.Text(
return draw.Text(
cvs, text, ti.forField.Min,
draw.TextMaxX(ti.forField.Max.X),
draw.TextCellOpts(cell.FgColor(ti.opts.textColor)),
); err != nil {
return err
}
return nil
)
}
// drawCursor draws the cursor within the text input field.

View File

@ -143,6 +143,9 @@ func main() {
button.GlobalKey(keyboard.KeyEnter),
button.FillColor(cell.ColorNumber(220)),
)
if err != nil {
panic(err)
}
clearB, err := button.New("Clear", func() error {
input.ReadAndClear()
updateText <- ""
@ -151,6 +154,9 @@ func main() {
button.WidthFor("Submit"),
button.FillColor(cell.ColorNumber(220)),
)
if err != nil {
panic(err)
}
quitB, err := button.New("Quit", func() error {
cancel()
return nil
@ -158,6 +164,9 @@ func main() {
button.WidthFor("Submit"),
button.FillColor(cell.ColorNumber(196)),
)
if err != nil {
panic(err)
}
builder := grid.New()
builder.Add(