Exemplo n.º 1
0
// Restore restores a previously Saved coloring. It is an error to call Restore
// without ever having called Save.
func (w *Wrapper) Restore() error {
	if w.saved == nil {
		return errors.New("attempted to restore without saving.")
	}
	if !w32.SetConsoleTextAttribute(w.h, w.saved.WAttributes) {
		return syscall.Errno(w32.GetLastError())
	}
	return nil
}
Exemplo n.º 2
0
// Change the coloring to c, but only in those bits where m is 1.
func (w *Wrapper) SetMask(c Color, m uint16) error {
	current := w32.GetConsoleScreenBufferInfo(w.h)
	if current == nil {
		return syscall.Errno(w32.GetLastError())
	}
	if !w32.SetConsoleTextAttribute(w.h, apply(current.WAttributes, uint16(c), uint16(m))) {
		return syscall.Errno(w32.GetLastError())
	}
	return nil
}