]> jfr.im git - irc/kvirc/KVIrc.git/commitdiff
Add KviControlCodes::getExtendedColor
authorVladimir Panteleev <redacted>
Sun, 2 Dec 2018 19:44:27 +0000 (19:44 +0000)
committerBenjamin Staneck <redacted>
Wed, 16 Jan 2019 20:40:14 +0000 (21:40 +0100)
src/kvilib/irc/KviControlCodes.cpp
src/kvilib/irc/KviControlCodes.h

index 3f49652b512349e2a99506e00e5487f539786f7e..6f4f5dad8b0d582108af0cd06a900a1e02be5846 100644 (file)
@@ -306,4 +306,102 @@ namespace KviControlCodes
                }
        }
 #endif
+
+       // Get extended (16-98) mIRC color.
+       // Unlike the 0-15 ones, these are not configurable.
+       // https://modern.ircdocs.horse/formatting.html#colors-16-98
+       // Returns (kvi_u32_t)-1 if index is out of bounds.
+       kvi_u32_t getExtendedColor(int index)
+       {
+               const int minColor = KVI_MIRCCOLOR_MAX + 1; // 16
+               const int maxColor = KVI_EXTCOLOR_MAX;
+               static const kvi_u32_t colors[maxColor - minColor + 1] = {
+                       0x470000,
+                       0x472100,
+                       0x474700,
+                       0x324700,
+                       0x004700,
+                       0x00472c,
+                       0x004747,
+                       0x002747,
+                       0x000047,
+                       0x2e0047,
+                       0x470047,
+                       0x47002a,
+                       0x740000,
+                       0x743a00,
+                       0x747400,
+                       0x517400,
+                       0x007400,
+                       0x007449,
+                       0x007474,
+                       0x004074,
+                       0x000074,
+                       0x4b0074,
+                       0x740074,
+                       0x740045,
+                       0xb50000,
+                       0xb56300,
+                       0xb5b500,
+                       0x7db500,
+                       0x00b500,
+                       0x00b571,
+                       0x00b5b5,
+                       0x0063b5,
+                       0x0000b5,
+                       0x7500b5,
+                       0xb500b5,
+                       0xb5006b,
+                       0xff0000,
+                       0xff8c00,
+                       0xffff00,
+                       0xb2ff00,
+                       0x00ff00,
+                       0x00ffa0,
+                       0x00ffff,
+                       0x008cff,
+                       0x0000ff,
+                       0xa500ff,
+                       0xff00ff,
+                       0xff0098,
+                       0xff5959,
+                       0xffb459,
+                       0xffff71,
+                       0xcfff60,
+                       0x6fff6f,
+                       0x65ffc9,
+                       0x6dffff,
+                       0x59b4ff,
+                       0x5959ff,
+                       0xc459ff,
+                       0xff66ff,
+                       0xff59bc,
+                       0xff9c9c,
+                       0xffd39c,
+                       0xffff9c,
+                       0xe2ff9c,
+                       0x9cff9c,
+                       0x9cffdb,
+                       0x9cffff,
+                       0x9cd3ff,
+                       0x9c9cff,
+                       0xdc9cff,
+                       0xff9cff,
+                       0xff94d3,
+                       0x000000,
+                       0x131313,
+                       0x282828,
+                       0x363636,
+                       0x4d4d4d,
+                       0x656565,
+                       0x818181,
+                       0x9f9f9f,
+                       0xbcbcbc,
+                       0xe2e2e2,
+                       0xffffff,
+               };
+               if (index < minColor || index > maxColor)
+                       return (kvi_u32_t)-1;
+               return colors[index - minColor];
+       }
 }
index e65f9918357b5a90a235bf91396d71f72dd3b9ec..fa0305471584036e9f4962180d6e2deb014f822d 100644 (file)
@@ -43,6 +43,7 @@
 #include "KviCString.h"
 
 #define KVI_MIRCCOLOR_MAX 15
+#define KVI_EXTCOLOR_MAX 98
 
 // ASCII Stuff: the following defines are meant to be escape sequences
 //              that can go through an IRC connection
@@ -178,6 +179,8 @@ namespace KviControlCodes
        inline const QChar * getUnicodeColorBytes(const QChar * pData, unsigned char * pcByte1, unsigned char * pcByte2)
                { return (QChar *)getColorBytesW((const kvi_wchar_t *)pData,pcByte1,pcByte2); }
 #endif
+
+       KVILIB_API kvi_u32_t getExtendedColor(int index);
 }
 
 #endif //_KVI_CONTROLCODES_H_