change console window title format
This commit is contained in:
parent
fa179198a0
commit
33dc19ded2
|
@ -83,6 +83,43 @@ namespace BizHawk.MultiClient
|
||||||
public Action<string> Emit;
|
public Action<string> Emit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static string SkipEverythingButProgramInCommandLine(string cmdLine)
|
||||||
|
{
|
||||||
|
//skip past the program name. can anyone think of a better way to do this?
|
||||||
|
//we could use CommandLineToArgvW (commented out below) but then we would just have to re-assemble and potentially re-quote it
|
||||||
|
int childCmdLine = 0;
|
||||||
|
int lastSlash = 0;
|
||||||
|
int lastGood = 0;
|
||||||
|
bool quote = false;
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
char cur = cmdLine[childCmdLine];
|
||||||
|
childCmdLine++;
|
||||||
|
if (childCmdLine == cmdLine.Length) break;
|
||||||
|
bool thisIsQuote = (cur == '\"');
|
||||||
|
if (cur == '\\' || cur == '/')
|
||||||
|
lastSlash = childCmdLine;
|
||||||
|
if (quote)
|
||||||
|
{
|
||||||
|
if (thisIsQuote)
|
||||||
|
quote = false;
|
||||||
|
else lastGood = childCmdLine;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cur == ' ' || cur == '\t')
|
||||||
|
break;
|
||||||
|
if (thisIsQuote)
|
||||||
|
quote = true;
|
||||||
|
lastGood = childCmdLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string remainder = cmdLine.Substring(childCmdLine);
|
||||||
|
string path = cmdLine.Substring(lastSlash, lastGood - lastSlash);
|
||||||
|
return path + " " + remainder;
|
||||||
|
}
|
||||||
|
|
||||||
static IntPtr oldOut, conOut;
|
static IntPtr oldOut, conOut;
|
||||||
static bool hasConsole;
|
static bool hasConsole;
|
||||||
static bool attachedConsole;
|
static bool attachedConsole;
|
||||||
|
@ -109,7 +146,15 @@ namespace BizHawk.MultiClient
|
||||||
attachedConsole = true;
|
attachedConsole = true;
|
||||||
|
|
||||||
if (!attachedConsole)
|
if (!attachedConsole)
|
||||||
|
{
|
||||||
Win32.AllocConsole();
|
Win32.AllocConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
IntPtr ptr = Win32.GetCommandLine();
|
||||||
|
string commandLine = Marshal.PtrToStringAuto(ptr);
|
||||||
|
Console.Title = SkipEverythingButProgramInCommandLine(commandLine);
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldRedirectStdout)
|
if (shouldRedirectStdout)
|
||||||
{
|
{
|
||||||
|
@ -135,7 +180,6 @@ namespace BizHawk.MultiClient
|
||||||
var cstw = new StreamWriter(cstm) { AutoFlush = true };
|
var cstw = new StreamWriter(cstm) { AutoFlush = true };
|
||||||
Console.SetOut(cstw);
|
Console.SetOut(cstw);
|
||||||
Console.SetError(cstw);
|
Console.SetError(cstw);
|
||||||
Console.Title = "BizHawk Console";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseConsole()
|
static void ReleaseConsole()
|
||||||
|
|
|
@ -293,6 +293,9 @@ namespace BizHawk
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
public static extern FileType GetFileType(IntPtr hFile);
|
public static extern FileType GetFileType(IntPtr hFile);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||||
|
public static extern System.IntPtr GetCommandLine();
|
||||||
|
|
||||||
public enum FileType : uint
|
public enum FileType : uint
|
||||||
{
|
{
|
||||||
FileTypeChar = 0x0002,
|
FileTypeChar = 0x0002,
|
||||||
|
|
Loading…
Reference in New Issue