cursor
cursor copied to clipboard
Restoring the buffer
In Terminal window with the height of 10 - what's the expected result?
n := 50
for i := 0; i < n; i++ {
fmt.Printf("foo-%d\n", i)
}
cursor.Up(n)
I am getting
$ go run test.go
foo-0
foo-1
foo-2
foo-3
foo-4
foo-5
foo-6
foo-7
foo-8
foo-9
foo-10
foo-11
foo-12
foo-13
foo-14
foo-15
foo-16
foo-17
foo-18
foo-19
foo-20
foo-21
foo-22
foo-23
foo-24
foo-25
foo-26
foo-27
foo-28
foo-29
foo-30
foo-31
foo-32
foo-33
foo-34
foo-35
foo-36
foo-37
foo-38
foo-39
foo-40
$
Same with UpAndClear(n).
I suspect that's more an ANSI thing rather than the libraries fault. But is there a way to better deal with that?
Yes, the cursor cannot go out of the terminals boundaries.
You could try to enable the alternative buffer mode (https://gist.github.com/ConnerWill/d4b6c776b509add763e17f9f113fd25b#common-private-modes). When you disable it, its content gets deleted. This is currently not supported by cursor, as not every terminal supports it. But I am thinking about adding the feature, as it should be fine if we document it correctly.