briandowns / spinner

Go (golang) package with 90 configurable terminal spinner/progress indicators.
Apache License 2.0
2.33k stars 129 forks source link

Move cursor to the beginning of the line before erasing #126

Closed HarryMichal closed 2 years ago

HarryMichal commented 2 years ago

The \033[K escape sequence signifies 'clear from cursor position to the end of the line'. Without moving the cursor to the beggining of the line first it results in no text being deleted. The behaviour of Carriage Return (\r) in terminal emulators is not formally standardized but it is generally interpreted as a move to the beginning of the line.

Tested on both Linux and Windows (cmd.exe, WSL2 and Windows Terminal).

Fixes https://github.com/briandowns/spinner/issues/123

briandowns commented 2 years ago

Thanks for the contribution!