예제 #1
0
        public static List <Controller.Find> FindString(TextEditor Editor, string SearchQuery, bool IgnoreCase)
        {
            Controller.Find find      = new Controller.Find();
            int             lastIndex = 0;
            CompareInfo     myComp    = CultureInfo.InvariantCulture.CompareInfo;

            List <Controller.Find> curSearch = new List <Controller.Find>();

            string Text = Editor.Text;

            if (SearchQuery.Length > 0 && Text.Length > 0)
            {
                while ((find.Index = myComp.IndexOf(Text, SearchQuery, lastIndex, (IgnoreCase == true) ? CompareOptions.IgnoreCase : CompareOptions.None)) != -1)
                {
                    lastIndex = find.Index + SearchQuery.Length;
                    find.Line = (find.Index == -1) ? -1 : Editor.TextArea.Document.GetLineByOffset(find.Index).LineNumber;
                    curSearch.Add(new Controller.Find()
                    {
                        Index = find.Index,
                        Line  = find.Line
                    });
                }
                return(curSearch);
            }
            return(null);
        }
예제 #2
0
        public static Controller.Find FindString(TextEditor Editor, string SearchQuery, int lastIndex, bool IgnoreCase)
        {
            Controller.Find find   = new Controller.Find();
            CompareInfo     myComp = CultureInfo.InvariantCulture.CompareInfo;

            string Text = Editor.Text;

            if (SearchQuery.Length > 0 && Text.Length > 0)
            {
                find.Index = myComp.IndexOf(Text, SearchQuery, lastIndex, (IgnoreCase == true) ? CompareOptions.IgnoreCase : CompareOptions.None);
                find.Line  = (find.Index == -1) ? -1 : Editor.TextArea.Document.GetLineByOffset(find.Index).LineNumber;
                return(find);
            }
            return(null);
        }