Ejemplo n.º 1
0
 protected static string TestEditor(IClipEditor editor, string input, params string[] commands)
 {
     editor.SourceData = input;
     editor.DefineParameters();
     for (int i = 0; i < commands.Length; i++)
     {
         editor.SetNextParameter(commands[i]);
     }
     editor.Edit();
     return(editor.SourceData);
 }
Ejemplo n.º 2
0
 public IClipEditor GetClipEditor(string editorName)
 {
     ClipEditor = (from e in Editors
                   where e.EditorName.Equals(editorName, StringComparison.CurrentCultureIgnoreCase)
                   select e).FirstOrDefault();
     if (ClipEditor == null)
     {
         ClipEditor = new UdfEditor(editorName);
     }
     return(ClipEditor);
 }
Ejemplo n.º 3
0
        protected void AndCommandIsRan(string editorWithCommands)
        {
            string[]      args    = editorWithCommands.ParseArguments();
            EditorManager manager = new EditorManager();
            IClipEditor   editor  = manager.GetClipEditor(args[0]);

            manager.ClipEditor.EditorResponse           += (a, b) => { editorResponse = b.ResponseString; };
            manager.ClipEditor.PersistentEditorResponse += (a, b) => { persistentEditorResponse = b.ResponseString; };

            string[] realArgs = new string[args.Length - 1];
            for (int i = 0; i < realArgs.Length; i++)
            {
                realArgs[i] = args[i + 1];
            }

            actual = TestEditor(editor, this.contents, realArgs);
        }
Ejemplo n.º 4
0
        public EditorDescription Help(string[] arguments)
        {
            if (arguments.Length > 1)
            {
                ClipEditor = (from e in Editors
                              where e.EditorName.Equals(arguments[1], StringComparison.CurrentCultureIgnoreCase)
                              select e).FirstOrDefault();
                if (ClipEditor == null)
                {
                    EditorDescription foundEditors = new EditorDescription();
                    foreach (IClipEditor ci in (from e in Editors
                                                where e.EditorName.ToLower().Contains(arguments[1].ToLower()) ||
                                                arguments[1].ToLower().Contains(e.EditorName.ToLower()) ||
                                                e.LongDescription.Contains(arguments[1].ToLower())
                                                select e))
                    {
                        foundEditors.Append(EditorDescription.Category.Emphasized, ci.EditorName);
                        foundEditors.AppendLine(EditorDescription.Category.PlainText, String.Concat(" - ", ci.ShortDescription));
                    }
                    return(foundEditors);
                }
                return(ClipEditor.LongDescription);
            }

            var allEditors = new EditorDescription();

            allEditors.AppendLine(EditorDescription.Category.Warning, Disclaimer);
            foreach (IClipEditor ce in Editors)
            {
                allEditors.Append(EditorDescription.Category.Emphasized, ce.EditorName);
                allEditors.AppendLine(EditorDescription.Category.PlainText, String.Concat(" - ", ce.ShortDescription));
            }
            allEditors.AppendLine("---------------------");
            allEditors.AppendLine("User Defined");
            allEditors.AppendLine("---------------------");

            UserFunctionsList ufl = new UserFunctionsList();

            ufl.DescribeFunctions(allEditors);

            return(allEditors);
        }
Ejemplo n.º 5
0
 private static void SaveThisCommand(string commandName, IClipEditor editor)
 {
     string[] parms = (from Parameter p in editor.ParameterList
                       orderby p.Sequence
                       select "\"" + (p.Value ?? p.DefaultValue ?? String.Empty).Replace("\"","\\q")+"\"").ToArray();
     ClippyLib.RecentCommands.SaveThisCommand(commandName, String.Join(" ", parms));
 }
Ejemplo n.º 6
0
        public string Help(string[] arguments)
        {
            if (arguments.Length > 1)
            {
                ClipEditor = (from e in Editors
                              where e.EditorName.Equals(arguments[1], StringComparison.CurrentCultureIgnoreCase)
                              select e).FirstOrDefault();
                if(ClipEditor == null)
                {
                    StringBuilder finder = new StringBuilder();
                    foreach(IClipEditor ci in (from e in Editors
                                               where e.EditorName.ToLower().Contains(arguments[1].ToLower())
                                               || arguments[1].ToLower().Contains(e.EditorName.ToLower())
                                               || e.LongDescription.ToLower().Contains(arguments[1].ToLower())
                                               select e))
                    {
                        finder.AppendLine(ci.EditorName);
                    }
                    return finder.ToString();
                }
                return ClipEditor.LongDescription;
            }
            StringBuilder output = new StringBuilder(Disclaimer);
            foreach (IClipEditor ce in Editors)
            {
                output.AppendFormat("{0}  -  {1}\r\n", ce.EditorName, ce.ShortDescription);
            }
            output.Append("---------------------\r\nUser Defined\r\n---------------------\r\n");
            UdfEditor.DescribeFunctions(output);

            return output.ToString();
        }
Ejemplo n.º 7
0
 public IClipEditor GetClipEditor(string editorName)
 {
     ClipEditor = (from e in Editors
                   where e.EditorName.Equals(editorName, StringComparison.CurrentCultureIgnoreCase)
                   select e).FirstOrDefault();
     if (ClipEditor == null)
         ClipEditor = new UdfEditor(editorName);
     ClipEditor.DefineParameters();
     return ClipEditor;
 }
Ejemplo n.º 8
0
        private static void AssertEditor(string expected, IClipEditor editor, string input, params string[] commands)
        {
            string actual = TestEditor(editor, input, commands);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
 private static string TestEditor(IClipEditor editor, string input, string command)
 {
     return(TestEditor(editor, input, new [] { command }));
 }
Ejemplo n.º 10
0
 private static string TestEditor(IClipEditor editor, string input)
 {
     return(TestEditor(editor, input, new string[0]));
 }