GUI API for tab-complete

Allow the GUI to pass a request to the console client, not to the
server.
Any string starting with a null character is handled by the console:
Command is: \0commandname\0commandarg
Output from console: \0commandname\0result
eg. \0autocomplete\0/he -> \0autocomplete\0/help
Currently, only "autocomplete" command is implemented.
This commit is contained in:
ORelio 2013-08-18 18:26:20 +02:00
parent 29ea512dbb
commit 84b8b9da2a

View file

@ -157,6 +157,20 @@ namespace MinecraftClient
while (client.Client.Connected) while (client.Client.Connected)
{ {
text = ConsoleIO.ReadLine(); text = ConsoleIO.ReadLine();
if (ConsoleIO.basicIO && text.Length > 0 && text[0] == (char)0x00)
{
//Process a request from the GUI
string[] command = text.Substring(1).Split((char)0x00);
switch (command[0].ToLower())
{
case "autocomplete":
if (command.Length > 1) { ConsoleIO.WriteLine((char)0x00 + "autocomplete" + (char)0x00 + handler.AutoComplete(command[1])); }
else Console.WriteLine((char)0x00 + "autocomplete" + (char)0x00);
break;
}
}
else
{
if (text == "/quit" || text == "/reco" || text == "/reconnect") { break; } if (text == "/quit" || text == "/reco" || text == "/reconnect") { break; }
while (text.Length > 0 && text[0] == ' ') { text = text.Substring(1); } while (text.Length > 0 && text[0] == ' ') { text = text.Substring(1); }
if (text != "") if (text != "")
@ -184,6 +198,7 @@ namespace MinecraftClient
else handler.SendChatMessage(text); else handler.SendChatMessage(text);
} }
} }
}
if (text == "/quit") if (text == "/quit")
{ {