Dont write escape code for zero movement

This commit is contained in:
Kovid Goyal 2022-10-07 12:25:37 +05:30
parent 350060e0f6
commit 936a7a5f97
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -210,21 +210,25 @@ func (self *Loop) SetCursorShape(shape CursorShapes, blink bool) {
}
func (self *Loop) MoveCursorHorizontally(amt int) {
suffix := "C"
if amt < 0 {
suffix = "D"
amt *= -1
if amt != 0 {
suffix := "C"
if amt < 0 {
suffix = "D"
amt *= -1
}
self.QueueWriteString(fmt.Sprintf("\x1b[%d%s", amt, suffix))
}
self.QueueWriteString(fmt.Sprintf("\x1b[%d%s", amt, suffix))
}
func (self *Loop) MoveCursorVertically(amt int) {
suffix := "B"
if amt < 0 {
suffix = "A"
amt *= -1
if amt != 0 {
suffix := "B"
if amt < 0 {
suffix = "A"
amt *= -1
}
self.QueueWriteString(fmt.Sprintf("\x1b[%d%s", amt, suffix))
}
self.QueueWriteString(fmt.Sprintf("\x1b[%d%s", amt, suffix))
}
func (self *Loop) ClearToEndOfScreen() {