From 3f9cff64144092afe670f2988acef194f367231d Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Wed, 14 Sep 2016 11:32:22 +0300 Subject: [PATCH] color map for linux console --- src/dlangui/platforms/console/consoleapp.d | 59 +++++++++++++++------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/src/dlangui/platforms/console/consoleapp.d b/src/dlangui/platforms/console/consoleapp.d index 5d21b3a0..567dd3a2 100644 --- a/src/dlangui/platforms/console/consoleapp.d +++ b/src/dlangui/platforms/console/consoleapp.d @@ -286,24 +286,47 @@ class ConsoleDrawBuf : DrawBuf { return dr + dg + db; } } - static immutable RGB[16] CONSOLE_COLORS_RGB = [ - RGB(0,0,0), - RGB(0,0,128), - RGB(0,128,0), - RGB(0,128,128), - RGB(128,0,0), - RGB(128,0,128), - RGB(128,128,0), - RGB(192,192,192), - RGB(0x7c,0x7c,0x7c), // ligth gray - RGB(0,0,255), - RGB(0,255,0), - RGB(0,255,255), - RGB(255,0,0), - RGB(255,0,255), - RGB(255,255,0), - RGB(255,255,255), - ]; + static if (Windows) { + // windows color table + static immutable RGB[16] CONSOLE_COLORS_RGB = [ + RGB(0,0,0), + RGB(0,0,128), + RGB(0,128,0), + RGB(0,128,128), + RGB(128,0,0), + RGB(128,0,128), + RGB(128,128,0), + RGB(192,192,192), + RGB(0x7c,0x7c,0x7c), // ligth gray + RGB(0,0,255), + RGB(0,255,0), + RGB(0,255,255), + RGB(255,0,0), + RGB(255,0,255), + RGB(255,255,0), + RGB(255,255,255), + ]; + } else { + // linux color table + static immutable RGB[16] CONSOLE_COLORS_RGB = [ + RGB(0,0,0), + RGB(128,0,0), + RGB(0,128,0), + RGB(128,128,0), + RGB(0,0,128), + RGB(128,0,128), + RGB(0,128,128), + RGB(192,192,192), + RGB(0x7c,0x7c,0x7c), // ligth gray + RGB(255,0,0), + RGB(0,255,0), + RGB(255,255,0), + RGB(0,0,255), + RGB(255,0,255), + RGB(0,255,255), + RGB(255,255,255), + ]; + } static ubyte toConsoleColor(uint color, bool forBackground = false) { if (forBackground && ((color >> 24) & 0xFF) >= 0x80)