parent
7899586b81
commit
067cf3a29b
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
9
tools/ColorTool/ColorTool/Resources.Designer.cs
generated
9
tools/ColorTool/ColorTool/Resources.Designer.cs
generated
|
@ -98,6 +98,15 @@ namespace ColorTool {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Usage: colortool -o <filename>.
|
||||
/// </summary>
|
||||
public static string OutputUsage {
|
||||
get {
|
||||
return ResourceManager.GetString("OutputUsage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not find or load "{0}".
|
||||
/// </summary>
|
||||
|
|
|
@ -131,6 +131,9 @@
|
|||
<data name="InvalidNumberOfColors" xml:space="preserve">
|
||||
<value>Invalid scheme - did not find 16 colors</value>
|
||||
</data>
|
||||
<data name="OutputUsage" xml:space="preserve">
|
||||
<value>Usage: colortool -o <filename></value>
|
||||
</data>
|
||||
<data name="SchemeNotFound" xml:space="preserve">
|
||||
<value>Could not find or load "{0}"</value>
|
||||
</data>
|
||||
|
@ -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</value>
|
||||
-v, --version : Display the version number
|
||||
-o, --output <filename> : output the current color table to an file (in .ini format)
|
||||
</value>
|
||||
</data>
|
||||
<data name="WroteToDefaults" xml:space="preserve">
|
||||
<value>Wrote selected scheme to the defaults.</value>
|
||||
|
|
Loading…
Reference in a new issue