|
@@ -72,6 +72,7 @@ type Writer struct {
|
|
|
handle syscall.Handle
|
|
handle syscall.Handle
|
|
|
lastbuf bytes.Buffer
|
|
lastbuf bytes.Buffer
|
|
|
oldattr word
|
|
oldattr word
|
|
|
|
|
+ oldpos coord
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func NewColorable(file *os.File) io.Writer {
|
|
func NewColorable(file *os.File) io.Writer {
|
|
@@ -83,7 +84,7 @@ func NewColorable(file *os.File) io.Writer {
|
|
|
var csbi consoleScreenBufferInfo
|
|
var csbi consoleScreenBufferInfo
|
|
|
handle := syscall.Handle(file.Fd())
|
|
handle := syscall.Handle(file.Fd())
|
|
|
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
|
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
- return &Writer{out: file, handle: handle, oldattr: csbi.attributes}
|
|
|
|
|
|
|
+ return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
|
|
|
} else {
|
|
} else {
|
|
|
return file
|
|
return file
|
|
|
}
|
|
}
|
|
@@ -644,6 +645,11 @@ loop:
|
|
|
ci.visible = 0
|
|
ci.visible = 0
|
|
|
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
|
}
|
|
}
|
|
|
|
|
+ case 's':
|
|
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
|
|
+ w.oldpos = csbi.cursorPosition
|
|
|
|
|
+ case 'u':
|
|
|
|
|
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return len(data) - w.lastbuf.Len(), nil
|
|
return len(data) - w.lastbuf.Len(), nil
|