]> git.proxmox.com Git - grub2.git/commitdiff
Support serial colors
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 7 May 2010 16:07:05 +0000 (18:07 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 7 May 2010 16:07:05 +0000 (18:07 +0200)
term/ieee1275/ofconsole.c
term/terminfo.c

index d143a6313ba3a1fbc24f52b58a2dc2be59541c96..151425a910c4a30230356a3c8f62a07985403ce0 100644 (file)
@@ -39,16 +39,18 @@ struct color
   int blue;
 };
 
+/* Use serial colors as they are default on most firmwares and some firmwares
+   ignore set-color!. Additionally output may be redirected to serial.  */
 static struct color colors[] =
   {
     // {R, G, B}
-    {0x00, 0x00, 0x00},
-    {0x00, 0x00, 0xA8}, // 1 = blue
+    {0x00, 0x00, 0x00}, // 0 = black
+    {0xA8, 0x00, 0x00}, // 1 = red
     {0x00, 0xA8, 0x00}, // 2 = green
-    {0x00, 0xA8, 0xA8}, // 3 = cyan
-    {0xA8, 0x00, 0x00}, // 4 = red
+    {0xFE, 0xFE, 0x54}, // 3 = yellow
+    {0x00, 0x00, 0xA8}, // 4 = blue
     {0xA8, 0x00, 0xA8}, // 5 = magenta
-    {0xFE, 0xFE, 0x54}, // 6 = yellow
+    {0x00, 0xA8, 0xA8}, // 6 = cyan
     {0xFE, 0xFE, 0xFE}  // 7 = white
   };
 
index f0e234106134f512ba23a4a2e270513aa5e7c544..4a07ba04f64e46d4af1cc2c1b334a5e8126c116c 100644 (file)
@@ -255,9 +255,8 @@ grub_terminfo_setcolor (struct grub_term_output *term,
   struct grub_terminfo_output_state *data
     = (struct grub_terminfo_output_state *) term->data;
 
-  /* Discard bright bit.  */
-  data->normal_color = normal_color & 0x77;
-  data->highlight_color = highlight_color & 0x77;
+  data->normal_color = normal_color;
+  data->highlight_color = highlight_color;
 }
 
 void
@@ -283,6 +282,17 @@ grub_terminfo_setcolorstate (struct grub_term_output *term,
     {
       int fg;
       int bg;
+      /* Map from VGA to terminal colors.  */
+      const int colormap[8] 
+       = { 0, /* Black. */
+           4, /* Blue. */
+           2, /* Green. */
+           6, /* Cyan. */
+           1, /* Red.  */
+           5, /* Magenta.  */
+           3, /* Yellow.  */
+           7, /* White.  */
+      };
 
       switch (state)
        {
@@ -299,7 +309,8 @@ grub_terminfo_setcolorstate (struct grub_term_output *term,
          return;
        }
 
-      putstr (term, grub_terminfo_tparm (data->setcolor, fg, bg));
+      putstr (term, grub_terminfo_tparm (data->setcolor, colormap[fg & 7],
+                                        colormap[bg & 7]));
       return;
     }