mirror of
https://github.com/esimov/caire.git
synced 2025-10-12 20:11:04 +08:00
utils: hide the cursor on progress indicator
This commit is contained in:
@@ -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 {
|
||||||
|
@@ -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()
|
||||||
|
@@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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.
|
||||||
|
Reference in New Issue
Block a user