Example #1
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
}
Example #2
0
// Save saves the current coloring so that it can be Restored later.
func (w *Wrapper) Save() error {
	w.saved = w32.GetConsoleScreenBufferInfo(w.h)
	if w.saved == nil {
		return syscall.Errno(w32.GetLastError())
	}
	return nil
}
Example #3
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
}