about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/display/term.nim6
-rw-r--r--src/types/color.nim3
2 files changed, 9 insertions, 0 deletions
diff --git a/src/display/term.nim b/src/display/term.nim
index 80fa88f9..42946dcc 100644
--- a/src/display/term.nim
+++ b/src/display/term.nim
@@ -274,6 +274,12 @@ proc processFormat*(term: Terminal, format: var Format, cellf: Format): string =
   var cellf = cellf
   case term.colormode
   of ANSI:
+    if not cellf.bgcolor.rgb and cellf.bgcolor.color > 15:
+      let color = cellf.bgcolor.eightbit
+      cellf.bgcolor = cellColor(eightBitToRGB(color))
+    if not cellf.fgcolor.rgb and cellf.fgcolor.color > 15:
+      let color = cellf.fgcolor.eightbit
+      cellf.fgcolor = cellColor(eightBitToRGB(color))
     if cellf.bgcolor.rgb:
       let color = approximateANSIColor(cellf.bgcolor.rgbcolor)
       if color == ANSI_BLACK:
diff --git a/src/types/color.nim b/src/types/color.nim
index 09847147..a22ce1e5 100644
--- a/src/types/color.nim
+++ b/src/types/color.nim
@@ -36,6 +36,9 @@ func rgbcolor*(color: CellColor): RGBColor =
 func color*(color: CellColor): uint8 =
   cast[uint8](color.n)
 
+func eightbit*(color: CellColor): EightBitColor =
+  EightBitColor(color.color)
+
 func cellColor*(rgb: RGBColor): CellColor =
   return CellColor(rgb: true, n: uint32(rgb))