public string Edit(string prompt, string initial, IExternalHistory historyInput = null) { edit_thread = Thread.CurrentThread; searching = 0; Console.CancelKeyPress += InterruptEdit; externalHistory = historyInput; 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); if (!tabUsed) { Console.WriteLine(); } Console.CancelKeyPress -= InterruptEdit; if (text == null) { history.Close(); return(null); } string result = text.ToString(); if (!tabUsed) { if (result != "") { history.Accept(result); } else { history.RemoveLast(); } } tabUsed = false; return(result); }
public string Edit (string prompt, string initial,IExternalHistory historyInput = null) { edit_thread = Thread.CurrentThread; searching = 0; Console.CancelKeyPress += InterruptEdit; externalHistory = historyInput; 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); if (!tabUsed) Console.WriteLine (); Console.CancelKeyPress -= InterruptEdit; if (text == null) { history.Close (); return null; } string result = text.ToString (); if (!tabUsed) { if (result != "") history.Accept (result); else history.RemoveLast (); } tabUsed = false; return result; }