Fix wrap around issues with inplace logging (#334)

## Changes
We deal with wraparounds for long lines of text in a bad way. This PR
fixes that by saving the cursor position

## Tests
Manually
This commit is contained in:
shreyas-goenka 2023-04-14 13:06:04 +02:00 committed by GitHub
parent df0293510e
commit b9c68b4bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -46,9 +46,16 @@ func (l *Logger) Log(event Event) {
switch l.Mode {
case flags.ModeInplace:
if l.isFirstEvent {
l.Writer.Write([]byte("\n"))
// save cursor location
l.Writer.Write([]byte("\033[s"))
}
l.Writer.Write([]byte("\033[1F"))
// move cursor to saved location
l.Writer.Write([]byte("\033[u"))
// clear from cursor to end of screen
l.Writer.Write([]byte("\033[0J"))
l.Writer.Write([]byte(event.String()))
l.Writer.Write([]byte("\n"))