浏览代码

24bit colors

Yasuhiro Matsumoto 8 年之前
父节点
当前提交
68849ea30c
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. 30 0
      colorable_windows.go

+ 30 - 0
colorable_windows.go

@@ -627,6 +627,21 @@ loop:
 								attr |= n256foreAttr[n256]
 								attr |= n256foreAttr[n256]
 								i += 2
 								i += 2
 							}
 							}
+						} else if len(token) == 5 && token[i+1] == "2" {
+							var r, g, b int
+							r, _ = strconv.Atoi(token[i+2])
+							g, _ = strconv.Atoi(token[i+3])
+							b, _ = strconv.Atoi(token[i+4])
+							i += 4
+							if r > 127 {
+								attr |= foregroundRed
+							}
+							if g > 127 {
+								attr |= foregroundGreen
+							}
+							if b > 127 {
+								attr |= foregroundBlue
+							}
 						} else {
 						} else {
 							attr = attr & (w.oldattr & backgroundMask)
 							attr = attr & (w.oldattr & backgroundMask)
 						}
 						}
@@ -654,6 +669,21 @@ loop:
 								attr |= n256backAttr[n256]
 								attr |= n256backAttr[n256]
 								i += 2
 								i += 2
 							}
 							}
+						} else if len(token) == 5 && token[i+1] == "2" {
+							var r, g, b int
+							r, _ = strconv.Atoi(token[i+2])
+							g, _ = strconv.Atoi(token[i+3])
+							b, _ = strconv.Atoi(token[i+4])
+							i += 4
+							if r > 127 {
+								attr |= backgroundRed
+							}
+							if g > 127 {
+								attr |= backgroundGreen
+							}
+							if b > 127 {
+								attr |= backgroundBlue
+							}
 						} else {
 						} else {
 							attr = attr & (w.oldattr & foregroundMask)
 							attr = attr & (w.oldattr & foregroundMask)
 						}
 						}