Skip to content

Commit

Permalink
Fix xClearToLineEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
devemlight committed Mar 1, 2025
1 parent 02d2a3c commit be61867
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/stdin/stdin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ import (
"errors"
"fmt"
"os"
"runtime"

"github.com/devemio/docker-color-output/internal/stdout"
)

var ErrEmpty = errors.New("empty")

const (
capRows = 50
)

//nolint:gochecknoglobals
var (
xClearToEnd = []byte("\033[J")
xClearToLineEnd = []byte("\033[K")
xMoveCursorHome = []byte("\033[H")
)
const capRows = 50

//nolint:cyclop
func Get(fn func(rows []string) error) error {
Expand All @@ -32,6 +24,16 @@ func Get(fn func(rows []string) error) error {
return fmt.Errorf("stdin: %w", ErrEmpty)
}

var (
xClearToEnd = []byte("\033[J")
xClearToLineEnd = []byte("\033[K")
xMoveCursorHome = []byte("\033[H")
)

if runtime.GOOS != "darwin" {
xClearToLineEnd = []byte(" \033[K")
}

var (
rows = make([]string, 0, capRows)
scanner = bufio.NewScanner(os.Stdin)
Expand Down

0 comments on commit be61867

Please sign in to comment.