Ejemplo n.º 1
0
 public SearchPattern Clone()
 {
     SearchPattern sp = new SearchPattern();
     sp.CaseSensitive = this.CaseSensitive;
     sp.Expresion = this.Expresion;
     sp.ReplaceExpresion = this.ReplaceExpresion;
     sp.SearchTyp = this.SearchTyp;
     sp.WholeWorlds =this.WholeWorlds;
     sp.CloseFiles = new List<string>(this.CloseFiles.ToArray());
     sp.OpenFiles = new List<string>(this.OpenFiles.ToArray());
     return sp;
 }
Ejemplo n.º 2
0
 public List<FindResult> FindReplaceAll(SearchPattern expresion)
 {
     return null;
 }
Ejemplo n.º 3
0
 bool IEditor.SearchPreviu(SearchPattern expresion)
 {
     return false;
     //throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 bool IEditor.ReplaceAll(SearchPattern expresion)
 {
     return false;
     //throw new NotImplementedException();
 }
Ejemplo n.º 5
0
        private void StartFindReplaceInFiles(SearchPattern sp)
        {
            MainClass.MainWindow.FindOutput.Clear();

            // first - find/replace in open files
            List<string> notOpen = new List<string>(sp.CloseFiles);
            List<string> opened = new List<string>(sp.OpenFiles);

            List<string> allOpened = new List<string>(MainClass.MainWindow.EditorNotebook.OpenFiles);
            // files in not opened -vsetky subory rozdelime na otvorene a zavrete
            if(sp.CloseFiles.Count>0){
                // Except(sp.CloseFiles,allOpened);
                notOpen =new List<string>(sp.CloseFiles.Except(allOpened,StringComparer.CurrentCultureIgnoreCase).ToList().ToArray());
                opened = new List<string>(sp.CloseFiles.Except(notOpen,StringComparer.CurrentCultureIgnoreCase).ToList().ToArray());

                sp.CloseFiles = new List<string>(notOpen);
                sp.OpenFiles = new List<string>(opened);
            }

            TaskList tl = new TaskList();

            /*if(opened.Count>0){
                SearchPattern spO = sp.Clone();
                spO.OpenFiles = new List<string>(opened);

                FindInOpenFileTask rt = new FindInOpenFileTask();
                rt.Initialize(spO);

                tl.TasksList.Clear();
                tl.TasksList.Add(rt);

                sp.CloseFiles = new List<string>(notOpen);

            }*/

            // find replace in closed files

            FindReplaceTask ft = new FindReplaceTask();
            //ReplaceTask ft = new ReplaceTask();
            ft.Initialize(sp);

            tl.TasksList.Add(ft);

            MainClass.MainWindow.RunSecondaryTaskList(tl, MainClass.MainWindow.FindOutputWritte,false);
        }
Ejemplo n.º 6
0
        private SearchPattern GetSearchPattern()
        {
            SearchPattern sp = new SearchPattern();
            sp.CaseSensitive = this.chbCaseSensitive.Active;
            sp.WholeWorlds = this.chbWholeWords.Active;
            sp.Expresion = this.entrExpresion.Text;
            sp.CloseFiles = new List<string>();
            sp.OpenFiles = new List<string>();

            switch (cbPlace.Active)
            {
                case 0:{
                    sp.SearchTyp =  SearchPattern.TypSearch.CurentDocument;
                    break;
                }
                case 1:{
                sp.SearchTyp =  SearchPattern.TypSearch.AllOpenDocument;
                sp.OpenFiles = new List<string>(MainClass.MainWindow.EditorNotebook.OpenFiles.ToArray());
                break;
                }
                case 2:{
                sp.SearchTyp =  SearchPattern.TypSearch.CurentProject;
                if(MainClass.Workspace.ActualProject == null)
                    return sp;
                MainClass.Workspace.ActualProject.GetAllFiles(ref sp.CloseFiles,MainClass.Workspace.ActualProject.AbsolutProjectDir,textExtension,true);
                break;
                }
                case 3:{
                sp.SearchTyp =  SearchPattern.TypSearch.AllOpenProject;
                foreach (Project p in MainClass.Workspace.Projects)
                    p.GetAllFiles(ref sp.CloseFiles,p.AbsolutProjectDir,textExtension,true);
                break;
                }
            }

            return sp;
        }
Ejemplo n.º 7
0
 public bool SearchNext(SearchPattern expresion)
 {
     return false;
     //throw new NotImplementedException ();
 }
Ejemplo n.º 8
0
 public void SetSearchExpresion(SearchPattern expresion)
 {
     searchPatern = expresion;
 }
Ejemplo n.º 9
0
 public void Search(SearchPattern expresion)
 {
     searchPatern = expresion;
     IEditor se = CurentEditor();
     if (se != null)
         se.SearchExpression(expresion);
 }
Ejemplo n.º 10
0
 public void ReplaceAll(SearchPattern expresion)
 {
     IEditor se = CurentEditor();
     if (se != null)
         se.ReplaceAll(expresion);
 }
Ejemplo n.º 11
0
        bool DelayedTooltipShow()
        {
            try {
                int caretOffset = this.Caret.Offset;
                int start = Math.Min (caretOffset, this.Document.Length - 1);
                while (start > 0) {
                    char ch = this.Document.GetCharAt (start);
                    if (!char.IsLetterOrDigit (ch) && ch != '_' && ch != '#') { //.
                        start++;
                        break;
                    }
                    start--;
                }

                int end = Math.Max (caretOffset, 0);
                while (end < this.Document.Length) {
                    char ch = this.Document.GetCharAt (end);
                    if (!char.IsLetterOrDigit (ch) && ch != '_')
                        break;
                    end++;
                }

                if (start < 0 || start >= end)
                    return false;

                string expression = this.Document.GetTextBetween (start, end);

                int i = MainClass.CompletedCache.ListDataKeywords.FindIndex(x=>x.DisplayText ==expression);

                if(i>-1){
                    popupTimer = 0;
                    return false;
                }

                SearchPattern searchPattern = new SearchPattern();
                searchPattern.CaseSensitive = true;
                searchPattern.WholeWorlds = true;
                searchPattern.Expresion =expression;
                searchPattern.ReplaceExpresion = null;

                List<FindResult> list = FindReplaceAll(searchPattern);

                foreach (var r in list) {
                    GetMarker (r);
                }

            } catch (Exception e) {
                Tool.Logger.Error("Unhandled Exception in HighlightingUsagesExtension",null);
                Tool.Logger.Error(e.Message,null);
            } finally {
                popupTimer = 0;
            }
            return false;
        }
Ejemplo n.º 12
0
        public List<FindResult> FindReplaceAll(SearchPattern searchPattern)
        {
            List<FindResult> result = new List<FindResult>();

            string expresion = searchPattern.Expresion.ToString();
            string replaceExpresion = null;
            if(searchPattern.ReplaceExpresion!= null)
                replaceExpresion = searchPattern.ReplaceExpresion.ToString();

            string text = this.Document.Text;
            var comparison = searchPattern.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
            int idx = 0;
            int delta = 0;

            while ((idx = text.IndexOf (expresion, idx, text.Length - idx, comparison)) >= 0) {
                if (!searchPattern.WholeWorlds || IsWholeWordAt (text, idx, expresion.Length)) {
                    int localDelta = 0;
                    if (replaceExpresion != null) {

                        Replace (ref text,idx + delta, expresion.Length, replaceExpresion);

                        delta += replaceExpresion.Length - expresion.Length;
                        localDelta = replaceExpresion.Length - expresion.Length;
                    }

                    int lineNumber =  this.Document.OffsetToLineNumber(idx);
                    LineSegment ls = this.Document.GetLine(lineNumber);
                    int lengthLine =ls.EndOffset-ls.Offset +localDelta;
                    string line = text.Substring(ls.Offset,lengthLine);
                    result.Add(new FindResult((object)(lineNumber+1),(object)line,(object)idx,(object)(idx+expresion.Length) ));
                }
                idx += expresion.Length;
            }

            Gtk.Application.Invoke (delegate {
                this.QueueDraw();
            });

            return result;
        }