/// <summary> /// For Actor. /// </summary> public static void ShowHistory() { var m = new UI.CommandHistoryMenu(string.Empty); string code = m.Show(); if (code == null) { return; } // insert to command lines switch (Far.Api.Window.Kind) { case WindowKind.Panels: Far.Api.CommandLine.Text = Entry.CommandInvoke1.Prefix + ": " + code; return; case WindowKind.Editor: var editor = Far.Api.Editor; if (!(editor.Host is Interactive)) { break; } editor.GoToEnd(true); editor.InsertText(code); editor.Redraw(); return; case WindowKind.Dialog: var dialog = Far.Api.Dialog; var typeId = dialog.TypeId; if (typeId != UI.InputDialog.TypeId) { break; } var line = Far.Api.Line; if (line == null || line.IsReadOnly) { break; } line.Text = code; return; } // show "Invoke commands" var ui = new UI.InputDialog() { Title = Res.Me, History = Res.History, Prompt = new string[] { Res.InvokeCommands }, Text = code }; if (!ui.Show()) { return; } // invoke input A.Psf.Act(ui.Text, null, true); }
public string InputCode() { var ui = new UI.InputDialog() { Caption = Res.Me, History = Res.History, UseLastHistory = true, Prompt = new string[] { Res.InvokeCommands } }; return(ui.Show() ? ui.Text : null); }
/// <summary> /// Reads a string. /// </summary> public override string ReadLine() { for (;;) { var ui = new UI.InputDialog() { History = Res.HistoryPrompt }; var text = ui.Show(); if (text != null) { return(text); } A.AskStopPipeline(); } }
public static void InvokePipelineForEach(IEnumerable <PSObject> input) { List <PSObject> items = new List <PSObject>(input); if (items.Count == 0) { return; } // keep $_ var dash = Psf.Engine.SessionState.PSVariable.GetValue("_"); // set $_ to a sample for TabExpansion Psf.Engine.SessionState.PSVariable.Set("_", items[0]); try { // show the dialog, get the code UI.InputDialog ui = new UI.InputDialog() { Title = Res.Me, History = Res.HistoryApply, UseLastHistory = true, Prompt = new string[] { "For each $_ in " + items.Count + " selected:" } }; if (!ui.Show()) { return; } string code = ui.Text.Trim(); if (code.Length == 0) { return; } // invoke the pipeline using the input Psf.Engine.SessionState.PSVariable.Set("_", items); Psf.Act("$_ | .{process{ " + code + " }}", null, false); } finally { // restore $_ Psf.Engine.SessionState.PSVariable.Set("_", dash); } }
/// <summary> /// Reads a string. /// </summary> public override string ReadLine() { string text; { for (;;) { var ui = new UI.InputDialog() { History = Res.HistoryPrompt }; if (ui.Show()) { text = ui.Text; break; } A.AskStopPipeline(); } } return(text); }
/// <summary> /// Reads a string. /// </summary> public override string ReadLine() { string text; if (Far.Api.UI.IsCommandMode) { for (; ; ) { var ui = new UI.ReadLine() { History = Res.HistoryPrompt }; if (ui.Show()) { text = ui.Text; break; } A.AskStopPipeline(); } WriteLine(text); } else { for (; ; ) { var ui = new UI.InputDialog() { History = Res.HistoryPrompt }; if (ui.Show()) { text = ui.Text; break; } A.AskStopPipeline(); } } return text; }
public static void ShowHistory() { var m = new UI.CommandHistoryMenu(string.Empty); string code = m.Show(); if (code == null) return; // insert to command lines switch (Far.Api.Window.Kind) { case WindowKind.Panels: Far.Api.CommandLine.Text = Entry.CommandInvoke1.Prefix + ": " + code; return; case WindowKind.Editor: var editor = Far.Api.Editor; if (!(editor.Host is EditorConsole)) break; editor.GoToEnd(true); editor.InsertText(code); editor.Redraw(); return; case WindowKind.Dialog: var dialog = Far.Api.Dialog; var typeId = dialog.TypeId; if (typeId != UI.InputConsole.TypeId && typeId != UI.InputDialog.TypeId) break; var line = Far.Api.Line; if (line == null || line.IsReadOnly) break; line.Text = code; return; } // show "Invoke commands" var ui = new UI.InputDialog() { Caption = Res.Me, History = Res.History, Prompt = new string[] { Res.InvokeCommands }, Text = code }; if (!ui.Show()) return; // invoke input A.Psf.Act(ui.Text, null, true); }
public static void InvokePipelineForEach(IEnumerable<PSObject> input) { List<PSObject> items = new List<PSObject>(input); if (items.Count == 0) return; // keep $_ var dash = Psf.Engine.SessionState.PSVariable.GetValue("_"); // set $_ to a sample for TabExpansion Psf.Engine.SessionState.PSVariable.Set("_", items[0]); try { // show the dialog, get the code UI.InputDialog ui = new UI.InputDialog() { Caption = Res.Me, History = Res.HistoryApply, UseLastHistory = true, Prompt = new string[] { "For each $_ in " + items.Count + " selected:" } }; if (!ui.Show()) return; string code = ui.Text.Trim(); if (code.Length == 0) return; // invoke the pipeline using the input Psf.Engine.SessionState.PSVariable.Set("_", items); Psf.Act("$_ | .{process{ " + code + " }}", null, false); } finally { // restore $_ Psf.Engine.SessionState.PSVariable.Set("_", dash); } }
public string InputCode() { var ui = new UI.InputDialog() { Caption = Res.Me, History = Res.History, UseLastHistory = true, Prompt = new string[] { Res.InvokeCommands } }; return ui.Show() ? ui.Text : null; }