public static string ShowHistory(string id = "", int num = 10) { Shell s = Shell.GetShell(id); if (s != null) { if (s.MainControl.Dispatcher.CheckAccess()) { ShellTextControl c = s.MainControl as ShellTextControl; if (c != null) { ShellTextBox b = c.GetContents; if (b != null) { return(b.GetHistory(num)); } } } else { return((string)s.MainControl.Dispatcher.Invoke(new Func <string>(() => { return ShowHistory(s.ShellId, num); }))); } } return("Error: no history available."); }
public static string SetCommandPrompt(string id = "", string prompt = null) { Shell s = Shell.GetShell(id); if (s != null) { if (s.MainControl.Dispatcher.CheckAccess()) { ShellTextControl c = s.MainControl as ShellTextControl; if (c != null) { ShellTextBox b = c.GetContents; if (b != null) { if (prompt == null) { return(b.GetPromptPrefix()); } prompt = prompt.Trim(); b.SetPromptPrefix(prompt); return(""); } } } else { return((string)s.MainControl.Dispatcher.Invoke(new Func <string>(() => { return SetCommandPrompt(s.ShellId, prompt); }))); } } return("Error: could not access prompt."); }