Skip to content

Commit

Permalink
convert to Writer field
Browse files Browse the repository at this point in the history
  • Loading branch information
segrey committed Jun 25, 2020
1 parent 0ef2a7a commit 94e912b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions colorable_windows.go
Expand Up @@ -95,6 +95,7 @@ type Writer struct {
oldattr word
oldpos coord
rest bytes.Buffer
mutex sync.Mutex
}

// NewColorable returns new instance of Writer which handles escape sequence from File.
Expand Down Expand Up @@ -432,14 +433,10 @@ func atoiWithDefault(s string, def int) (int, error) {
return strconv.Atoi(s)
}

var (
writeMutex sync.Mutex
)

// Write writes data on console
func (w *Writer) Write(data []byte) (n int, err error) {
writeMutex.Lock()
defer writeMutex.Unlock()
w.mutex.Lock()
defer w.mutex.Unlock()
var csbi consoleScreenBufferInfo
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))

Expand Down

0 comments on commit 94e912b

Please sign in to comment.