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", spinnerText := fmt.Sprintf("%s %s",
utils.DecorateText("⚡ CAIRE", utils.StatusMessage), utils.DecorateText("⚡ CAIRE", utils.StatusMessage),
utils.DecorateText("is resizing the image...", utils.DefaultMessage)) 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 *newWidth > 0 || *newHeight > 0 || *percentage || *square {
if *faceDetect && len(*cascade) == 0 { if *faceDetect && len(*cascade) == 0 {

View File

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

View File

@@ -24,13 +24,13 @@ type Spinner struct {
} }
// NewSpinner instantiates a new progress indicator. // 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{ return &Spinner{
mu: &sync.RWMutex{}, mu: &sync.RWMutex{},
delay: d, delay: d,
writer: os.Stderr, writer: os.Stderr,
message: msg, message: msg,
hideCursor: hideCursor, hideCursor: true,
stopChan: make(chan struct{}, 1), stopChan: make(chan struct{}, 1),
} }
} }

View File

@@ -8,7 +8,7 @@ import (
"time" "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 type MessageType int
// The message types used accross the CLI application. // The message types used accross the CLI application.