fyne-io/terminal

Clear terminal escape code not working.

figuerom16 opened this issue · 2 comments

t.Write([]byte{27, '[', '2', 'J'})
Running the clear terminal escape code does not clear the terminal and changes nothing.

Normal clearing does work below.

...
t.Write([]byte{0x3})
time.Sleep(100 * time.Millisecond)
t.Write([]byte("clear\n"))
time.Sleep(100 * time.Millisecond)
...

I might be trying to access the escape incorrectly in escape.go
'J': escapeEraseInScreen
...
case 2: t.clearScreen()

Edit: I see that t.clearScreen() is very literal and needs more handling than just accessing that function.

Sticking with the normal clear method seems to be the safest.
This works the best for canceling and clearing.
t.Write([]byte{0x3, 0xD, 'c', 'l', 'e', 'a', 'r', 0xD})

Escape codes are parsed from incoming terminal commands - not from the Go code controlling the terminal. If you want to clear the screen use Go APIs we expose.