Просмотр исходного кода

Merge pull request #51 from zetamatta/fork2

Fix: on Windows 8.1, ESC[7m (REVERSE) does not work.
mattn 5 лет назад
Родитель
Сommit
f1b5a0ed46
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      colorable_windows.go

+ 5 - 5
colorable_windows.go

@@ -27,7 +27,6 @@ const (
 	backgroundRed       = 0x40
 	backgroundIntensity = 0x80
 	backgroundMask      = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
-	commonLvbReverse    = 0x4000
 	commonLvbUnderscore = 0x8000
 
 	cENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
@@ -689,14 +688,15 @@ loop:
 						attr |= commonLvbUnderscore
 					case (1 <= n && n <= 3) || n == 5:
 						attr |= foregroundIntensity
-					case n == 7:
-						attr |= commonLvbReverse
+					case n == 7 || n == 27:
+						attr =
+							(attr &^ (foregroundMask | backgroundMask)) |
+								((attr & foregroundMask) << 4) |
+								((attr & backgroundMask) >> 4)
 					case n == 22:
 						attr &^= foregroundIntensity
 					case n == 24:
 						attr &^= commonLvbUnderscore
-					case n == 27:
-						attr &^= commonLvbReverse
 					case 30 <= n && n <= 37:
 						attr &= backgroundMask
 						if (n-30)&1 != 0 {