utils: hide the cursor on progress indicator

This commit is contained in:
esimov
2021-05-31 15:28:15 +03:00
parent e40114a85d
commit dbadbde8b6
4 changed files with 6 additions and 4 deletions

View File

@@ -99,7 +99,8 @@ func main() {
spinnerText := fmt.Sprintf("%s %s",
utils.DecorateText("⚡ CAIRE", utils.StatusMessage),
utils.DecorateText("is resizing the image...", utils.DefaultMessage))
spinner = utils.NewSpinner(spinnerText, time.Millisecond*200, true)
spinner = utils.NewSpinner(spinnerText, time.Millisecond*100)
if *newWidth > 0 || *newHeight > 0 || *percentage || *square {
if *faceDetect && len(*cascade) == 0 {

View File

@@ -9,6 +9,7 @@ import (
func (c *Carver) Grayscale(src *image.NRGBA) *image.NRGBA {
dx, dy := src.Bounds().Max.X, src.Bounds().Max.Y
dst := image.NewNRGBA(src.Bounds())
for x := 0; x < dx; x++ {
for y := 0; y < dy; y++ {
r, g, b, _ := src.At(x, y).RGBA()

View File

@@ -24,13 +24,13 @@ type Spinner struct {
}
// NewSpinner instantiates a new progress indicator.
func NewSpinner(msg string, d time.Duration, hideCursor bool) *Spinner {
func NewSpinner(msg string, d time.Duration) *Spinner {
return &Spinner{
mu: &sync.RWMutex{},
delay: d,
writer: os.Stderr,
message: msg,
hideCursor: hideCursor,
hideCursor: true,
stopChan: make(chan struct{}, 1),
}
}

View File

@@ -8,7 +8,7 @@ import (
"time"
)
// MessageType is a placeholder for the various the message types.
// MessageType is a custom type used as a placeholder for various message types.
type MessageType int
// The message types used accross the CLI application.