Skip to content

Commit c10454b

Browse files
authored
Merge pull request #50 from zetamatta/fork
Support disable-bold,real-underline and native reverse-color.
2 parents 4e32bdb + 4b79b6e commit c10454b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

colorable_windows.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727
backgroundRed = 0x40
2828
backgroundIntensity = 0x80
2929
backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
30+
commonLvbReverse = 0x4000
31+
commonLvbUnderscore = 0x8000
3032

3133
cENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
3234
)
@@ -683,14 +685,18 @@ loop:
683685
switch {
684686
case n == 0 || n == 100:
685687
attr = w.oldattr
686-
case 1 <= n && n <= 5:
688+
case n == 4:
689+
attr |= commonLvbUnderscore
690+
case (1 <= n && n <= 3) || n == 5:
687691
attr |= foregroundIntensity
688692
case n == 7:
689-
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
690-
case n == 22 || n == 25:
691-
attr |= foregroundIntensity
693+
attr |= commonLvbReverse
694+
case n == 22:
695+
attr &^= foregroundIntensity
696+
case n == 24:
697+
attr &^= commonLvbUnderscore
692698
case n == 27:
693-
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
699+
attr &^= commonLvbReverse
694700
case 30 <= n && n <= 37:
695701
attr &= backgroundMask
696702
if (n-30)&1 != 0 {

0 commit comments

Comments
 (0)