From 9a601da6e4a8b50f115e1a51acd4be045045ef40 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 3 Oct 2015 11:51:57 -0700 Subject: [PATCH] fixes #12 Windows reverse video broken --- console_win.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/console_win.go b/console_win.go index 9e6c10a..71393dd 100644 --- a/console_win.go +++ b/console_win.go @@ -586,8 +586,17 @@ func mapStyle(style Style) uint16 { if b == ColorDefault { b = ColorBlack } - attr := mapColor2RGB(f) - attr |= (mapColor2RGB(b) << 4) + var attr uint16 + // We simulate reverse by doing the color swap ourselves. + // Apparently windows cannot really do this except in DBCS + // views. + if a&AttrReverse != 0 { + attr = mapColor2RGB(b) + attr |= (mapColor2RGB(f) << 4) + } else { + attr = mapColor2RGB(f) + attr |= (mapColor2RGB(b) << 4) + } if a&AttrBold != 0 { attr |= 0x8 } @@ -595,11 +604,9 @@ func mapStyle(style Style) uint16 { attr &^= 0x8 } if a&AttrUnderline != 0 { + // Best effort -- doesn't seem to work though. attr |= 0x8000 } - if a&AttrReverse != 0 { - attr |= 0x4000 - } // Blink is unsupported return attr }