/// <summary>
 /// Gets search config for find and replace
 /// </summary>
 private FRConfiguration GetFRConfig(String path, String mask, Boolean recursive)
 {
     if (path.Trim() == "<Project>")
     {
         if (PluginBase.CurrentProject != null)
         {
             PathWalker    walker;
             List <String> allFiles = new List <String>();
             IProject      project  = PluginBase.CurrentProject;
             String        projPath = Path.GetDirectoryName(project.ProjectPath);
             walker = new PathWalker(projPath, mask, recursive);
             allFiles.AddRange(walker.GetFiles());
             for (var i = 0; i < project.SourcePaths.Length; i++)
             {
                 String sourcePath = project.GetAbsolutePath(project.SourcePaths[i]);
                 if (Directory.Exists(sourcePath) && !sourcePath.StartsWith(projPath))
                 {
                     walker = new PathWalker(sourcePath, mask, recursive);
                     allFiles.AddRange(walker.GetFiles());
                 }
             }
             return(new FRConfiguration(allFiles, this.GetFRSearch()));
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(new FRConfiguration(path, mask, recursive, this.GetFRSearch()));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the files
        /// </summary>
        public List <String> GetFiles()
        {
            switch (type)
            {
            case OperationType.FindInRange:
                return(this.files);

            case OperationType.FindInSource:
                if (this.files == null)
                {
                    this.files = new List <String>();
                    this.files.Add(path);
                }
                return(files);

            case OperationType.FindInFile:
                if (this.files == null)
                {
                    this.files = new List <String>();
                    this.files.Add(path);
                }
                return(this.files);

            case OperationType.FindInPath:
                if (this.files == null)
                {
                    PathWalker walker = new PathWalker(this.path, this.mask, this.recursive);
                    this.files = walker.GetFiles();
                }
                return(this.files);
            }
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generates the menu for the selected sci control
        /// </summary>
        public void GenerateSnippets(ScintillaNet.ScintillaControl sci)
        {
            var files = new List <string>();

            string specific = Path.Combine(Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage), SurroundWithCommand.SurroundFolder);

            if (Directory.Exists(specific))
            {
                var walker = new PathWalker(specific, "*" + SurroundWithCommand.SurroundExt, false);
                files.AddRange(walker.GetFiles());
            }

            string global = Path.Combine(PathHelper.SnippetDir, SurroundWithCommand.SurroundFolder);

            if (Directory.Exists(global))
            {
                var walker = new PathWalker(global, "*" + SurroundWithCommand.SurroundExt, false);
                files.AddRange(walker.GetFiles());
            }

            items.Clear();
            if (files.Count > 0)
            {
                files.Sort();
                foreach (string file in files)
                {
                    string content = File.ReadAllText(file);
                    if (content.IndexOfOrdinal("{0}") >= 0)
                    {
                        items.Add(new SurroundWithItem(Path.GetFileNameWithoutExtension(file)));
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets search config for find and replace
 /// </summary>
 private FRConfiguration GetFRConfig(String path, String mask, Boolean recursive)
 {
     if (path.Trim() == "<Project>")
     {
         if (PluginBase.CurrentProject != null)
         {
             PathWalker    walker;
             List <String> allFiles = new List <String>();
             IProject      project  = PluginBase.CurrentProject;
             String        projPath = Path.GetDirectoryName(project.ProjectPath);
             walker = new PathWalker(projPath, mask, recursive);
             List <String> projFiles = walker.GetFiles();
             foreach (String file in projFiles)
             {
                 if (!IsFileHidden(file, project))
                 {
                     allFiles.Add(file);
                 }
             }
             return(new FRConfiguration(allFiles, this.GetFRSearch()));
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(new FRConfiguration(path, mask, recursive, this.GetFRSearch()));
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Generates the menu for the selected sci control
        /// </summary>
        public void GenerateSnippets(ScintillaNet.ScintillaControl sci)
        {
            String        path;
            String        content;
            PathWalker    walker;
            List <String> files;

            items = new List <String>();
            String surroundFolder = "surround";

            path = Path.Combine(PathHelper.SnippetDir, surroundFolder);
            if (Directory.Exists(path))
            {
                walker = new PathWalker(PathHelper.SnippetDir + surroundFolder, "*.fds", false);
                files  = walker.GetFiles();
                foreach (String file in files)
                {
                    items.Add(file);
                }
            }
            path = Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage);
            path = Path.Combine(path, surroundFolder);
            if (Directory.Exists(path))
            {
                walker = new PathWalker(path, "*.fds", false);
                files  = walker.GetFiles();
                foreach (String file in files)
                {
                    items.Add(file);
                }
            }
            if (items.Count > 0)
            {
                items.Sort();
            }
            this.DropDownItems.Clear();
            foreach (String itm in items)
            {
                content = File.ReadAllText(itm);
                if (content.IndexOf("{0}") > -1)
                {
                    this.DropDownItems.Insert(this.DropDownItems.Count, new ToolStripMenuItem(Path.GetFileNameWithoutExtension(itm), image));
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Inserts text from the snippets class
        /// </summary>
        public static Boolean InsertTextByWord(String word, Boolean emptyUndoBuffer)
        {
            ScintillaControl sci = Globals.SciControl;

            if (sci == null)
            {
                return(false);
            }
            Boolean canShowList = false;
            String  snippet     = null;

            if (word == null)
            {
                canShowList = true;
                word        = sci.GetWordFromPosition(sci.CurrentPos);
            }
            if (word != null && word.Length > 0)
            {
                snippet = GetSnippet(word, sci.ConfigurationLanguage, sci.Encoding);
            }
            // let plugins handle the snippet
            Hashtable data = new Hashtable();

            data["word"]    = word;
            data["snippet"] = snippet;
            DataEvent de = new DataEvent(EventType.Command, "SnippetManager.Expand", data);

            EventManager.DispatchEvent(Globals.MainForm, de);
            if (de.Handled)
            {
                return(true);
            }
            snippet = (string)data["snippet"];
            if (!String.IsNullOrEmpty(sci.SelText))
            {
                // Remember the previous selection
                ArgsProcessor.PrevSelText = sci.SelText;
            }
            if (snippet != null)
            {
                Int32  endPos   = sci.SelectionEnd;
                Int32  startPos = sci.SelectionStart;
                String curWord  = sci.GetWordFromPosition(endPos);
                if (startPos == endPos)
                {
                    endPos   = sci.WordEndPosition(sci.CurrentPos, true);
                    startPos = sci.WordStartPosition(sci.CurrentPos, true);
                    sci.SetSel(startPos, endPos);
                }
                if (!String.IsNullOrEmpty(curWord))
                {
                    // Remember the current word
                    ArgsProcessor.PrevSelWord = curWord;
                }
                SnippetHelper.InsertSnippetText(sci, endPos, snippet);
                return(true);
            }
            else if (canShowList)
            {
                ICompletionListItem        item;
                List <ICompletionListItem> items = new List <ICompletionListItem>();
                PathWalker    walker             = new PathWalker(PathHelper.SnippetDir, "*.fds", false);
                List <String> files = walker.GetFiles();
                foreach (String file in files)
                {
                    item = new SnippetItem(Path.GetFileNameWithoutExtension(file), file);
                    items.Add(item);
                }
                String path = Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage);
                if (Directory.Exists(path))
                {
                    walker = new PathWalker(path, "*.fds", false);
                    files  = walker.GetFiles();
                    foreach (String file in files)
                    {
                        item = new SnippetItem(Path.GetFileNameWithoutExtension(file), file);
                        items.Add(item);
                    }
                }
                if (items.Count > 0)
                {
                    items.Sort();
                    if (!String.IsNullOrEmpty(sci.SelText))
                    {
                        word = sci.SelText;
                    }
                    else
                    {
                        word = sci.GetWordFromPosition(sci.CurrentPos);
                        if (word == null)
                        {
                            word = String.Empty;
                        }
                    }
                    CompletionList.OnInsert += new InsertedTextHandler(HandleListInsert);
                    CompletionList.OnCancel += new InsertedTextHandler(HandleListInsert);
                    CompletionList.Show(items, false, word);
                    return(true);
                }
            }
            return(false);
        }