API to save/restore cursor position

This commit is contained in:
Kovid Goyal 2023-02-11 07:44:45 +05:30
parent 1aa9f1e62d
commit a2e4efbb14
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -195,6 +195,14 @@ func (self *Loop) Println(args ...any) {
self.QueueWriteString("\r\n") self.QueueWriteString("\r\n")
} }
func (self *Loop) SaveCursor() {
self.QueueWriteString("\x1b7")
}
func (self *Loop) RestoreCursor() {
self.QueueWriteString("\x1b8")
}
func (self *Loop) Printf(format string, args ...any) { func (self *Loop) Printf(format string, args ...any) {
format = strings.ReplaceAll(format, "\n", "\r\n") format = strings.ReplaceAll(format, "\n", "\r\n")
self.QueueWriteString(fmt.Sprintf(format, args...)) self.QueueWriteString(fmt.Sprintf(format, args...))