static void Main(string[] args)
{
Console.WriteLine("DotQL Console. Execute: Control Enter or F5. Exit: Control C or Control F5");
StringBuilder sb = new StringBuilder();
bool done = false;
Command command = Command.None;
while (!done)
{
command = Command.None;
ConsoleKeyInfo info = Console.ReadKey(false);
switch (info.Key)
{
case ConsoleKey.F5:
if (info.Modifiers == ConsoleModifiers.Control)
{
command = Command.Stop;
}
else
{
command = Command.Execute;
}
break;
case ConsoleKey.Enter:
if (info.Modifiers == ConsoleModifiers.Control)
{
command = Command.Execute;
}
break;
default:
command = Command.None;
break;
}
switch (command)
{
case Command.Execute:
Execute(sb);
break;
case Command.Stop:
done = true;
Console.WriteLine("Stopped");
break;
case Command.None:
if (info.Key == ConsoleKey.Backspace)
{
sb.Remove(sb.Length - 1, 1);
Console.Write(" \b");
}
else
{
sb.Append(info.KeyChar);
}
break;
default:
break;
}
if (info.Key == ConsoleKey.Enter)
{
Console.WriteLine();
}
}
}