/// <summary> /// Replaces all regex matches in all project files with replaceText /// Results are added to results panel and highlighted /// </summary> /// <param name="regex"></param> /// <param name="replaceText"></param> private static void ReplaceAll(Regex regex, string replaceText) { Main.Instance.DisableEdit(); Status.Text = Messages.Replacing; Application.DoEvents(); SearchResultsPanel.Reset(); ProcessAll(i => { string t; Match m; Place p; do { m = regex.Match(t = i.Text); if (m.Success) { p = i.Editor.PositionToPlace(m.Index); t = t.Substring(0, m.Index) + replaceText + t.Substring(m.Index + m.Length); i.Editor.BeginAutoUndo(); i.Editor.Text = t; i.Editor.EndAutoUndo(); SearchResultsPanel.Add(new SearchResult { Path = i.Path, File = i.FileName, Fragment = m.Value, Replacement = replaceText, Line = p.iLine + 1, Column = p.iChar + 1 }); } } while (m.Success); }); SearchResultsPanel.CloseIfEmpty(); Status.Text = Messages.Ready; Application.DoEvents(); Main.Instance.EnableEdit(); }
public static void FindTrack(ScnTrack track) { Main.Instance.DisableEdit(); Status.Text = Messages.Searching; Application.DoEvents(); SearchResultsPanel.Reset(); ProcessAll(i => { if (i.Path == track.SourcePath) { i.Open(); var p = i.Editor.PositionToPlace(track.SourceIndex); SearchResultsPanel.Add(new SearchResult { Path = i.Path, File = i.FileName, Fragment = i.Text.Substring(track.SourceIndex, track.SourceLength), Line = p.iLine + 1, Column = 1 }); } }); SearchResultsPanel.CloseIfEmpty(); Status.Text = Messages.Ready; Application.DoEvents(); Main.Instance.EnableEdit(); }
private static void FindAll(Regex regex) { Main.Instance.DisableEdit(); Status.Text = Messages.Searching; Application.DoEvents(); SearchResultsPanel.Reset(); ProcessAll(i => { foreach (Match m in regex.Matches(i.Text)) { i.Open(); var p = i.Editor.PositionToPlace(m.Index);// i.Editor.MarkSearchResult(m.Index, m.Length); SearchResultsPanel.Add(new SearchResult { Path = i.Path, File = i.FileName, Fragment = m.Value, Line = p.iLine + 1, Column = p.iChar + 1 }); } }); SearchResultsPanel.CloseIfEmpty(); Status.Text = Messages.Ready; Application.DoEvents(); Main.Instance.EnableEdit(); }