public string Edit(string prompt, string initial)
{
edit_thread = Thread.CurrentThread;
searching = 0;
Console.CancelKeyPress += InterruptEdit;
done = false;
history.CursorToEnd();
max_rendered = 0;
Prompt = prompt;
shown_prompt = prompt;
InitText(initial);
history.Append(initial);
do
{
try
{
EditLoop();
}
catch (ThreadAbortException)
{
searching = 0;
Thread.ResetAbort();
Console.WriteLine();
SetPrompt(prompt);
SetText("");
}
} while (!done);
Console.WriteLine();
Console.CancelKeyPress -= InterruptEdit;
if (text == null)
{
history.Close();
return null;
}
string result = text.ToString();
if (result != "")
history.Accept(result);
else
history.RemoveLast();
return result;
}