// 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 }
// 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 }
// 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 }