mirror of https://github.com/mum4k/termdash.git
Fixing lint issues found on Go report card.
This commit is contained in:
parent
662382e8ba
commit
0ef875039b
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue