diff --git a/tools/ColorTool/ColorTool/IniSchemeParser.cs b/tools/ColorTool/ColorTool/IniSchemeParser.cs
index 3b1789f57..224b296f4 100644
--- a/tools/ColorTool/ColorTool/IniSchemeParser.cs
+++ b/tools/ColorTool/ColorTool/IniSchemeParser.cs
@@ -17,7 +17,7 @@ namespace ColorTool
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
// These are in Windows Color table order - BRG, not RGB.
- static string[] COLOR_NAMES = {
+ public static string[] COLOR_NAMES = {
"DARK_BLACK",
"DARK_BLUE",
"DARK_GREEN",
diff --git a/tools/ColorTool/ColorTool/Program.cs b/tools/ColorTool/ColorTool/Program.cs
index b2a5002eb..6399729d8 100644
--- a/tools/ColorTool/ColorTool/Program.cs
+++ b/tools/ColorTool/ColorTool/Program.cs
@@ -89,6 +89,11 @@ namespace ColorTool
Console.WriteLine(Resources.Usage);
}
+ static void OutputUsage()
+ {
+ Console.WriteLine(Resources.OutputUsage);
+ }
+
static void Version()
{
//System.Reflection.Assembly.GetEntryAssembly();
@@ -196,6 +201,7 @@ namespace ColorTool
}
return success;
}
+
static bool SetDefaults(uint[] colorTable)
{
RegistryKey consoleKey = Registry.CurrentUser.OpenSubKey("Console", true);
@@ -208,6 +214,37 @@ namespace ColorTool
return true;
}
+ static bool ExportCurrentAsIni(string outputPath)
+ {
+ CONSOLE_SCREEN_BUFFER_INFO_EX csbiex = CONSOLE_SCREEN_BUFFER_INFO_EX.Create();
+ int STD_OUTPUT_HANDLE = -11;
+ IntPtr hOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ bool success = GetConsoleScreenBufferInfoEx(hOut, ref csbiex);
+ if (success)
+ {
+ using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputPath))
+ {
+ file.WriteLine("[table]");
+ for (int i = 0; i < 16; i++)
+ {
+ string line = IniSchemeParser.COLOR_NAMES[i];
+ line += " = ";
+ uint color = csbiex.ColorTable[i];
+ uint r = color & (0x000000ff);
+ uint g = (color & (0x0000ff00)) >> 8;
+ uint b = (color & (0x00ff0000)) >> 16;
+ line += r + "," + g + "," + b;
+ file.WriteLine(line);
+ }
+ }
+ }
+ else
+ {
+ Console.WriteLine("Failed to get conosle information.");
+ }
+ return success;
+ }
+
static void Main(string[] args)
{
@@ -216,9 +253,9 @@ namespace ColorTool
Usage();
return;
}
-
- foreach (string arg in args)
+ for (int i = 0; i < args.Length; i++)
{
+ string arg = args[i];
switch (arg)
{
case "-c":
@@ -247,6 +284,17 @@ namespace ColorTool
case "--version":
Version();
return;
+ case "-o":
+ case "--output":
+ if (i+1 < args.Length)
+ {
+ ExportCurrentAsIni(args[i + 1]);
+ }
+ else
+ {
+ OutputUsage();
+ }
+ return;
default:
break;
}
diff --git a/tools/ColorTool/ColorTool/Resources.Designer.cs b/tools/ColorTool/ColorTool/Resources.Designer.cs
index e053d6d11..379c408f0 100644
--- a/tools/ColorTool/ColorTool/Resources.Designer.cs
+++ b/tools/ColorTool/ColorTool/Resources.Designer.cs
@@ -98,6 +98,15 @@ namespace ColorTool {
}
}
+ ///
+ /// Looks up a localized string similar to Usage: colortool -o <filename>.
+ ///
+ public static string OutputUsage {
+ get {
+ return ResourceManager.GetString("OutputUsage", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Could not find or load "{0}".
///
diff --git a/tools/ColorTool/ColorTool/Resources.resx b/tools/ColorTool/ColorTool/Resources.resx
index 7f369ffd6..d9b0420ab 100644
--- a/tools/ColorTool/ColorTool/Resources.resx
+++ b/tools/ColorTool/ColorTool/Resources.resx
@@ -131,6 +131,9 @@
Invalid scheme - did not find 16 colors
+
+ Usage: colortool -o <filename>
+
Could not find or load "{0}"
@@ -151,7 +154,9 @@ Options:
-q, --quiet : Don't print the color table after applying
-d, --defaults : Apply the scheme to only the defaults in the registry
-b, --both : Apply the scheme to both the current console and the defaults.
- -v, --version : Display the version number
+ -v, --version : Display the version number
+ -o, --output <filename> : output the current color table to an file (in .ini format)
+
Wrote selected scheme to the defaults.