void OnCommandInvoke1(object sender, ModuleCommandEventArgs e) { string currentDirectory = A.Psf.SyncPaths(); try { // if command ends with `#` then omit history and echo else make echo with prefix var echo = e.Command.TrimEnd(); var addHistory = !e.IsMacro; if (echo.EndsWith("#")) { addHistory = false; echo = null; } else { var colon = e.Command.Length > 0 && char.IsWhiteSpace(e.Command[0]) ? ":" : ": "; echo = CommandInvoke1.Prefix + colon + e.Command; } var ok = A.Psf.Act(e.Command, new ConsoleOutputWriter(echo), addHistory); e.Ignore = !ok; } finally { A.SetCurrentDirectoryFinally(currentDirectory); } }
public override void Invoke(object sender, ModuleCommandEventArgs e) { InitRegex(Manager); ILine line = null; IEditor editor = null; var kind = Far.Api.Window.Kind; if (kind == WindowKind.Editor) { editor = Far.Api.Editor; } else { line = Far.Api.Line; if (line == null) return; } switch (e.Command.Trim()) { case "step-left": Run(editor, line, Operation.Step, false, false); break; case "step-right": Run(editor, line, Operation.Step, true, false); break; case "select-left": Run(editor, line, Operation.Select, false, false); break; case "select-right": Run(editor, line, Operation.Select, true, false); break; case "delete-left": Run(editor, line, Operation.Delete, false, false); break; case "delete-right": Run(editor, line, Operation.Delete, true, false); break; case "vertical-left": Run(editor, line, Operation.Select, false, true); break; case "vertical-right": Run(editor, line, Operation.Select, true, true); break; case "go-to-smart-home": Home(editor, line, false); break; case "select-to-smart-home": Home(editor, line, true); break; default: throw new ModuleException("Unknown command: " + e.Command); } }
public override void Invoke(object sender, ModuleCommandEventArgs e) { var filename = e.Command; if (filename.EndsWith(".pak")) { new PakExplorer(new FPakFile(filename)).OpenPanel(); } else if (filename.EndsWith(".bnk")) { new BankExplorer(new BankFile(File.ReadAllBytes(filename))).OpenPanel(); } else if (filename.EndsWith(".uasset")) { //var viewer = Far.Api.CreateViewer(); //viewer.DeleteSource = DeleteSource.File; //viewer.DisableHistory = true; //viewer.FileName = Path.GetTempFileName(); //viewer.Switching = Switching.Disabled; //viewer.Title = filename; //viewer.ViewMode = ViewerViewMode.Text; //viewer.WordWrapMode = true; // TODO: Write data to viewer.FileName //viewer.Open(OpenMode.Modal); if (false) { var files = Directory.GetFiles(Far.Api.CurrentDirectory, "*.uasset", SearchOption.AllDirectories); foreach (var file in files) { bool bDelete = false; using (var stream = File.CreateText(file + ".log")) { try { new UAsset(File.ReadAllBytes(file), 506); } catch { bDelete = true; } finally { File.Delete(file); } } if (bDelete) { File.Delete(file + ".log"); } } } else { new UAsset(File.ReadAllBytes(filename), GetCookedAssetVersion()); } } }
/// <summary> /// This method implements the command action. /// The command text is the Command property value. /// </summary> public override void Invoke(object sender, ModuleCommandEventArgs e) { switch (e.Command.Trim().ToUpper()) { case "PROCESS": DoProcess(); break; case "ASSEMBLY": DoAssembly(); break; default: // Show help in the help viewer Far.Net.ShowHelpTopic("DemoCommand"); break; } }
void OnCommandInvoke2(object sender, ModuleCommandEventArgs e) { string currentDirectory = A.Psf.SyncPaths(); try { A.Psf.Act(e.Command, null, !e.IsMacro); } finally { A.SetCurrentDirectoryFinally(currentDirectory); } }
void OnCommandInvoke1(object sender, ModuleCommandEventArgs e) { string currentDirectory = A.Psf.SyncPaths(); try { A.Psf.Act(e.Command, new ConsoleOutputWriter(CommandInvoke1.Prefix + ":" + e.Command), !e.IsMacro); } finally { A.SetCurrentDirectoryFinally(currentDirectory); } }
/// <summary> /// This method implements the command action. /// The command text is the Command property value. /// </summary> public override void Invoke(object sender, ModuleCommandEventArgs e) { switch (e.Command.Trim().ToUpper()) { case "PROCESS": DoProcess(); break; case "ASSEMBLY": DoAssembly(); break; case "RESOURCES": DoResources(); break; default: // Show help in the help viewer Far.Api.ShowHelpTopic("DemoCommand"); break; } }
public void Invoke(object sender, ModuleCommandEventArgs e) { if (e == null) throw new ArgumentNullException("e"); Log.Source.TraceInformation("Invoking {0} Command='{1}'", this, e.Command); Invoking(); if (_Handler != null) { _Handler(sender, e); } else { ModuleCommand instance = (ModuleCommand)GetInstance(); instance.Invoke(sender, e); } }
public override void Invoke(object sender, ModuleCommandEventArgs e) { InitRegex(Manager); ILine line = null; IEditor editor = null; var kind = Far.Api.Window.Kind; if (kind == WindowKind.Editor) { editor = Far.Api.Editor; } else { line = Far.Api.Line; if (line == null) { return; } } switch (e.Command.Trim()) { case "step-left": Run(editor, line, Operation.Step, false, false); break; case "step-right": Run(editor, line, Operation.Step, true, false); break; case "select-left": Run(editor, line, Operation.Select, false, false); break; case "select-right": Run(editor, line, Operation.Select, true, false); break; case "delete-left": Run(editor, line, Operation.Delete, false, false); break; case "delete-right": Run(editor, line, Operation.Delete, true, false); break; case "vertical-left": Run(editor, line, Operation.Select, false, true); break; case "vertical-right": Run(editor, line, Operation.Select, true, true); break; case "go-to-smart-home": Home(editor, line, false); break; case "select-to-smart-home": Home(editor, line, true); break; default: throw new ModuleException("Unknown command: " + e.Command); } }
public void Invoke(object sender, ModuleCommandEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } Log.Source.TraceInformation("Invoking {0} Command='{1}'", this, e.Command); Invoking(); if (_Handler != null) { _Handler(sender, e); } else { ModuleCommand instance = (ModuleCommand)GetInstance(); instance.Invoke(sender, e); } }
public override void Invoke(object sender, ModuleCommandEventArgs e) { // tokenize var tokens = Parser.Tokenize(e.Command, "-XPath"); // open the empty panel if (tokens.Count == 0) { (new SuperExplorer()).OpenPanel(); return; } // the module panel Panel panel = Far.Api.Panel as Panel; if (panel == null) { Far.Api.Message("This is not a module panel."); return; } // the search var search = new SearchFileCommand(panel.Explorer); // parameters var parameters = new string[] { "-Asynchronous", "-Depth", "-Directory", "-Recurse", "-XFile", "-XPath", }; // parse, setup the search bool async = false; for (int iToken = 0; iToken < tokens.Count; ++iToken) { var token = tokens[iToken]; var parameter = Parser.ResolveName(token, parameters); // mask if (parameter == null) { if (search.Filter != null) throw new ModuleException("Invalid command line."); var mask = token; if (!Far.Api.IsMaskValid(mask)) throw new ModuleException("Invalid mask."); search.Filter = delegate(Explorer explorer, FarFile file) { return Far.Api.IsMaskMatch(file.Name, mask); }; continue; } switch (parameter) { case "-XPath": { search.XPath = tokens[iToken + 1]; if (search.XPath.Length == 0) throw new ModuleException("Invalid -XPath."); iToken = tokens.Count; break; } case "-XFile": { if (++iToken >= token.Length) throw new ModuleException("Invalid -XFile."); search.XFile = tokens[iToken]; break; } case "-Depth": { if (++iToken >= token.Length) throw new ModuleException("Invalid -Depth."); search.Depth = int.Parse(tokens[iToken]); break; } case "-Directory": { search.Directory = true; break; } case "-Recurse": { search.Recurse = true; break; } case "-Asynchronous": { async = true; break; } } } // go if (async) search.InvokeAsync(panel); else search.Invoke(panel); }
public override void Invoke(object sender, ModuleCommandEventArgs e) { // tokenize var tokens = Parser.Tokenize(e.Command, "-XPath"); // open the empty panel if (tokens.Count == 0) { (new SuperExplorer()).OpenPanel(); return; } // the module panel Panel panel = Far.Api.Panel as Panel; if (panel == null) { Far.Api.Message("This is not a module panel."); return; } // the search var search = new SearchFileCommand(panel.Explorer); // parameters var parameters = new string[] { "-Asynchronous", "-Depth", "-Directory", "-Recurse", "-XFile", "-XPath", }; // parse, setup the search bool async = false; for (int iToken = 0; iToken < tokens.Count; ++iToken) { var token = tokens[iToken]; var parameter = Parser.ResolveName(token, parameters); // mask if (parameter == null) { if (search.Filter != null) { throw new ModuleException("Invalid command line."); } var mask = token; if (!Far.Api.IsMaskValid(mask)) { throw new ModuleException("Invalid mask."); } search.Filter = delegate(Explorer explorer, FarFile file) { return(Far.Api.IsMaskMatch(file.Name, mask)); }; continue; } switch (parameter) { case "-XPath": { search.XPath = tokens[iToken + 1]; if (search.XPath.Length == 0) { throw new ModuleException("Invalid -XPath."); } iToken = tokens.Count; break; } case "-XFile": { if (++iToken >= token.Length) { throw new ModuleException("Invalid -XFile."); } search.XFile = tokens[iToken]; break; } case "-Depth": { if (++iToken >= token.Length) { throw new ModuleException("Invalid -Depth."); } search.Depth = int.Parse(tokens[iToken]); break; } case "-Directory": { search.Directory = true; break; } case "-Recurse": { search.Recurse = true; break; } case "-Asynchronous": { async = true; break; } } } // go if (async) { search.InvokeAsync(panel); } else { search.Invoke(panel); } }