|
|
@@ -411,11 +411,6 @@ func (w *Writer) Write(data []byte) (n int, err error) {
|
|
|
var bw [1]byte
|
|
|
loop:
|
|
|
for {
|
|
|
- r1, _, err := procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
- if r1 == 0 {
|
|
|
- break loop
|
|
|
- }
|
|
|
-
|
|
|
c1, err := er.ReadByte()
|
|
|
if err != nil {
|
|
|
break loop
|
|
|
@@ -460,6 +455,7 @@ loop:
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.y -= short(n)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
case 'B':
|
|
|
@@ -467,6 +463,7 @@ loop:
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.y += short(n)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
case 'C':
|
|
|
@@ -474,6 +471,7 @@ loop:
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.x -= short(n)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
case 'D':
|
|
|
@@ -482,7 +480,7 @@ loop:
|
|
|
continue
|
|
|
}
|
|
|
if n, err = strconv.Atoi(buf.String()); err == nil {
|
|
|
- var csbi consoleScreenBufferInfo
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.x += short(n)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
}
|
|
|
@@ -491,6 +489,7 @@ loop:
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.x = 0
|
|
|
csbi.cursorPosition.y += short(n)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
@@ -499,6 +498,7 @@ loop:
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.x = 0
|
|
|
csbi.cursorPosition.y -= short(n)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
@@ -507,9 +507,11 @@ loop:
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
csbi.cursorPosition.x = short(n - 1)
|
|
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
|
case 'H':
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
if buf.Len() > 0 {
|
|
|
token := strings.Split(buf.String(), ";")
|
|
|
switch len(token) {
|
|
|
@@ -545,6 +547,7 @@ loop:
|
|
|
}
|
|
|
var count, written dword
|
|
|
var cursor coord
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
switch n {
|
|
|
case 0:
|
|
|
cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
|
|
|
@@ -566,6 +569,7 @@ loop:
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
var cursor coord
|
|
|
switch n {
|
|
|
case 0:
|
|
|
@@ -580,6 +584,7 @@ loop:
|
|
|
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
|
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
|
case 'm':
|
|
|
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
|
attr := csbi.attributes
|
|
|
cs := buf.String()
|
|
|
if cs == "" {
|
|
|
@@ -700,6 +705,7 @@ loop:
|
|
|
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)))
|