Skip to content

Commit a1bbcef

Browse files
committed
Added Debug options: 'ansi' and 'custom_colours'
1 parent c46a700 commit a1bbcef

File tree

1 file changed

+85
-5
lines changed

1 file changed

+85
-5
lines changed

world_debug.cpp

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ extern tInfoTypeMapping InfoTypes [];
2525

2626
#define SHOW_TRUE(x) ((x) ? "yes" : "no")
2727

28+
static char * sColourNames [8] =
29+
{
30+
"Black",
31+
"Red",
32+
"Green",
33+
"Yellow",
34+
"Blue",
35+
"Magenta",
36+
"Cyan",
37+
"White"
38+
};
39+
2840
// compare-less for colours
2941
struct colour_less : binary_function<COLORREF, COLORREF, bool>
3042
{
@@ -88,7 +100,7 @@ static void ShowOneColour (CMUSHclientDoc * pDoc,
88100

89101
pDoc->ColourTell (strTextColour, ColourToName (iColour), strName);
90102

91-
strName = CFormat ("R=%3i G=%3i B=%3i ", // RGB
103+
strName = CFormat (" R=%3i G=%3i B=%3i ", // RGB
92104
iRed,
93105
iGreen,
94106
iBlue);
@@ -114,6 +126,34 @@ static void ShowOneColour (CMUSHclientDoc * pDoc,
114126

115127
} // end of ShowOneColour
116128

129+
static void ShowAnsiColour (CMUSHclientDoc * pDoc,
130+
CString strColourName,
131+
const COLORREF iColour)
132+
133+
{
134+
int iRed = GetRValue (iColour);
135+
int iGreen = GetGValue (iColour);
136+
int iBlue = GetBValue (iColour);
137+
138+
CString strName = CFormat ("%-24s ", (LPCTSTR) strColourName);
139+
140+
CString strTextColour = "black";
141+
142+
// if colour is dark, use white, otherwise use black
143+
if (((GetRValue (iColour) & 0xFF) +
144+
(GetGValue (iColour) & 0xFF) +
145+
(GetBValue (iColour) & 0xFF) ) < (128 * 3))
146+
strTextColour = "white";
147+
148+
pDoc->ColourTell (strTextColour, ColourToName (iColour), strName);
149+
pDoc->ColourTell (ColourToName (iColour), ColourToName (pDoc->m_normalcolour [0]), strName);
150+
pDoc->ColourTell (ColourToName (pDoc->m_normalcolour [7]), ColourToName (iColour), strName);
151+
152+
pDoc->Note ("");
153+
154+
} // end of ShowAnsiColour
155+
156+
117157
VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
118158
{
119159
VARIANT vaResult;
@@ -150,7 +190,7 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
150190
//-----------------------------------------------------------------------
151191
// colours
152192
//-----------------------------------------------------------------------
153-
if (strcmp (Command, "colours") == 0)
193+
if (strcmp (Command, "colours") == 0 || strcmp (Command, "colors") == 0)
154194
{
155195

156196
multimap<COLORREF, string, colour_less> mColours;
@@ -176,7 +216,7 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
176216
//-----------------------------------------------------------------------
177217
// colours256
178218
//-----------------------------------------------------------------------
179-
else if (strcmp (Command, "colours256") == 0)
219+
else if (strcmp (Command, "colours256") == 0 || strcmp (Command, "colors256") == 0)
180220
{
181221

182222
for (int i = 0; i < 256; i++)
@@ -211,6 +251,44 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
211251

212252
} // end of colours256
213253

254+
//-----------------------------------------------------------------------
255+
// ansi
256+
//-----------------------------------------------------------------------
257+
if (strcmp (Command, "ansi") == 0)
258+
{
259+
260+
int i;
261+
262+
Note (TFormat ("%-24s %-24s %-24s", " Name", " On normal background", " Under normal text"));
263+
Note ("------------------------ ------------------------ ------------------------ ");
264+
265+
for (i = 0; i < 8; i++)
266+
{
267+
CString strName = TFormat (" Normal #%i (%s)", i, sColourNames [i]);
268+
ShowAnsiColour (this, strName, m_normalcolour [i]);
269+
} // end for loop
270+
271+
for (i = 0; i < 8; i++)
272+
{
273+
CString strName = TFormat (" Bold #%i (%s)", i, sColourNames [i]);
274+
ShowAnsiColour (this, strName, m_boldcolour [i]);
275+
} // end for loop
276+
277+
} // end of ansi
278+
279+
//-----------------------------------------------------------------------
280+
// custom_colour
281+
//-----------------------------------------------------------------------
282+
if (strcmp (Command, "custom_colours") == 0 || strcmp (Command, "custom_colors") == 0)
283+
{
284+
int i;
285+
for (i = 0; i < MAX_CUSTOM; i++)
286+
{
287+
CString strName = TFormat (" Custom #%2i (%s)", i + 1, m_strCustomColourName [i]);
288+
ColourNote ( ColourToName (m_customtext [i]), ColourToName (m_customback [i]), strName);
289+
} // end for loop
290+
} // end of custom_colour
291+
214292
//-----------------------------------------------------------------------
215293
// entities
216294
//-----------------------------------------------------------------------
@@ -1374,10 +1452,12 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
13741452
Note ("actions");
13751453
Note ("aliases");
13761454
Note ("alpha_options");
1455+
Note ("ansi");
13771456
Note ("arrays");
1378-
Note ("colours");
1379-
Note ("colours256");
1457+
Note ("colours (or colors)");
1458+
Note ("colours256 (or colors256)");
13801459
Note ("commands");
1460+
Note ("custom_colours (or custom_colors)");
13811461
Note ("entities");
13821462
Note ("global_options");
13831463
Note ("included_options");

0 commit comments

Comments
 (0)