public void SetOptions(NiFindOptions options, NiFindOptions optionsMask) { _view.BeginUpdate(); Options = (Options & ~optionsMask) | options; bool replace = options.HasFlag(NiFindOptions.Replace); _view.SetMode(replace ? FindMode.Replace : FindMode.Find); if ((optionsMask & NiFindOptions.TargetMask) != 0) { switch (Options & NiFindOptions.TargetMask) { case NiFindOptions.Document: _view.SetTarget(Finder.FindTarget.CurrentDocument); break; case NiFindOptions.OpenDocument: _view.SetTarget(Finder.FindTarget.AllOpenDocuments); break; default: _view.SetTarget(Finder.FindTarget.EntireProject); break; } } _view.SetIncludeSubFolders(Options.HasFlag(NiFindOptions.SubFolders)); _view.SetMatchCase(Options.HasFlag(NiFindOptions.MatchCase)); _view.SetMatchWholeWord(Options.HasFlag(NiFindOptions.WholeWord)); _view.SetUseRegularExpressions(Options.HasFlag(NiFindOptions.RegExp)); _view.SetKeepOpen(Options.HasFlag(NiFindOptions.KeepOpen)); _view.EndUpdate(); }
public void SetOptions(NiFindOptions options, NiFindOptions optionsMask) { _view.BeginUpdate(); Options = (Options & ~optionsMask) | options; bool replace = options.HasFlag(NiFindOptions.Replace); _view.SetMode(replace ? FindMode.Replace : FindMode.Find); if ((optionsMask & NiFindOptions.TargetMask) != 0) { switch (Options & NiFindOptions.TargetMask) { case NiFindOptions.Document: _view.SetTarget(Finder.FindTarget.CurrentDocument); break; case NiFindOptions.OpenDocument: _view.SetTarget(Finder.FindTarget.AllOpenDocuments); break; default: _view.SetTarget(Finder.FindTarget.EntireProject); break; } } _view.SetIncludeSubFolders(Options.HasFlag(NiFindOptions.SubFolders)); _view.SetMatchCase(Options.HasFlag(NiFindOptions.MatchCase)); _view.SetMatchWholeWord(Options.HasFlag(NiFindOptions.WholeWord)); _view.SetUseRegularExpressions(Options.HasFlag(NiFindOptions.RegExp)); _view.SetKeepOpen(Options.HasFlag(NiFindOptions.KeepOpen)); _view.EndUpdate(); }
public HResult OpenDialog(NiFindOptions options, NiFindOptions optionsMask) { try { if (_form != null && _form.IsDisposed) _form = null; bool show = _form == null; if (_form == null) { // We need to set the site early because SetOptions depends // on this. _form = new FindForm { Site = new SiteProxy(this) }; } _form.SetOptions(options, optionsMask); if (show) _form.Show(((INiEnv)GetService(typeof(INiEnv))).MainWindow); else _form.Activate(); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
private void SetOption(NiFindOptions option, bool value) { if (value) _findManager.Options |= option; else _findManager.Options &= ~option; }
public static void Show(IServiceProvider serviceProvider, Control parent, NiFindOptions options, NiFindOptions optionsMask, INiFindTarget findTarget) { if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); if (parent == null) throw new ArgumentNullException("parent"); if (findTarget == null) throw new ArgumentNullException("findTarget"); var control = parent.Controls.OfType<FindControl>().SingleOrDefault(); if (control == null) { control = new FindControl { Anchor = AnchorStyles.Right, Site = new SiteProxy(serviceProvider) }; control.Left = parent.ClientSize.Width - control.Width; parent.Controls.Add(control); } control._findManager.FindTarget = findTarget; control._findManager.SetOptions(options, optionsMask); control._findWhat.Focus(); }
public static void Show(IServiceProvider serviceProvider, Control parent, NiFindOptions options, NiFindOptions optionsMask, INiFindTarget findTarget) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (parent == null) { throw new ArgumentNullException("parent"); } if (findTarget == null) { throw new ArgumentNullException("findTarget"); } var control = parent.Controls.OfType <FindControl>().SingleOrDefault(); if (control == null) { control = new FindControl { Anchor = AnchorStyles.Right, Site = new SiteProxy(serviceProvider) }; control.Left = parent.ClientSize.Width - control.Width; parent.Controls.Add(control); } control._findManager.FindTarget = findTarget; control._findManager.SetOptions(options, optionsMask); control._findWhat.Focus(); }
public static FindState Create(FindManager manager, NiFindOptions options, INiFindTarget findTarget) { return new FindState(findTarget) { Options = options, FindWhat = manager._view.GetFindWhatText(), ReplaceWith = manager._view.GetReplaceWithText(), LookIn = manager._view.GetLookInText(), LookInFileTypes = manager._view.GetLookAtFileTypesText() }; }
private void SetOption(NiFindOptions option, bool value) { if (value) { _findManager.Options |= option; } else { _findManager.Options &= ~option; } }
public static FindState Create(FindManager manager, NiFindOptions options, INiFindTarget findTarget) { return(new FindState(findTarget) { Options = options, FindWhat = manager._view.GetFindWhatText(), ReplaceWith = manager._view.GetReplaceWithText(), LookIn = manager._view.GetLookInText(), LookInFileTypes = manager._view.GetLookAtFileTypesText() }); }
public HResult FindInText(string find, string replace, NiFindOptions options, string text, int offset, out int found, out int matchLength, out string replacementText, out bool isFound) { found = 0; matchLength = 0; replacementText = null; isFound = false; try { if (find == null) throw new ArgumentNullException("find"); if (text == null) throw new ArgumentNullException("text"); string pattern = options.HasFlag(NiFindOptions.RegExp) ? find : Regex.Escape(find); if (options.HasFlag(NiFindOptions.WholeWord)) pattern = @"\b" + pattern + @"\b"; var regexOptions = RegexOptions.Multiline; if (!options.HasFlag(NiFindOptions.MatchCase)) regexOptions |= RegexOptions.IgnoreCase; if (options.HasFlag(NiFindOptions.Backwards)) regexOptions |= RegexOptions.RightToLeft; var match = new Regex(pattern, regexOptions).Match(text, offset); isFound = match.Success; if (isFound) { found = match.Index; matchLength = match.Length; } if (replace != null) throw new NotImplementedException(); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult OpenDialog(NiFindOptions options, NiFindOptions optionsMask) { try { if (_form != null && _form.IsDisposed) { _form = null; } bool show = _form == null; if (_form == null) { // We need to set the site early because SetOptions depends // on this. _form = new FindForm { Site = new SiteProxy(this) }; } _form.SetOptions(options, optionsMask); if (show) { _form.Show(((INiEnv)GetService(typeof(INiEnv))).MainWindow); } else { _form.Activate(); } return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public HResult Find(string search, NiFindOptions options, bool resetStartPoint, INiFindHelper helper, out NiFindResult result) { return(Replace(search, null, options, resetStartPoint, helper, out result)); }
private void OpenFindWindow(NiFindOptions options) { FindControl.Show(Site, ActiveTextAreaControl.TextArea, options, NiFindOptions.ActionMask, FindTarget); }
public HResult Replace(string search, string replace, NiFindOptions options, bool resetStartPoint, INiFindHelper helper, out NiFindResult result) { return Control.FindTarget.Replace(search, replace, options, resetStartPoint, helper, out result); }
public void SetOptions(NiFindOptions options, NiFindOptions optionsMask) { _findManager.SetOptions(options, optionsMask); }
public void SetOptions(NiFindOptions options, NiFindOptions optionsMask) { _findManager.SetOptions(options, optionsMask); }
public HResult Replace(string search, string replace, NiFindOptions options, bool resetStartPoint, INiFindHelper helper, out NiFindResult result) { result = NiFindResult.NotFound; try { if (search == null) { throw new ArgumentNullException("search"); } if (helper == null) { throw new ArgumentNullException("helper"); } var document = _textAreaControl.Document; string text = document.TextContent; int offset; if (options.HasFlag(NiFindOptions.Backwards)) { if (resetStartPoint) { offset = text.Length; } else { offset = _textAreaControl.Caret.Offset; } } else { if (resetStartPoint) { offset = 0; } else if (_textAreaControl.SelectionManager.HasSomethingSelected) { offset = _textAreaControl.SelectionManager.SelectionCollection.Last().EndOffset; } else { offset = _textAreaControl.Caret.Offset; } } int matchLength; string replacement; bool found; ErrorUtil.ThrowOnFailure(helper.FindInText( search, replace, options, text, offset, out offset, out matchLength, out replacement, out found )); if (found) { MarkSpan(GetTextSpan(document, offset, matchLength)); result = replace == null ? NiFindResult.Found : NiFindResult.Replaced; } else { result = NiFindResult.NotFound; } return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public HResult Find(string search, NiFindOptions options, bool resetStartPoint, INiFindHelper helper, out NiFindResult result) { return Replace(search, null, options, resetStartPoint, helper, out result); }
public HResult Replace(string search, string replace, NiFindOptions options, bool resetStartPoint, INiFindHelper helper, out NiFindResult result) { result = NiFindResult.NotFound; try { if (search == null) throw new ArgumentNullException("search"); if (helper == null) throw new ArgumentNullException("helper"); var document = _textAreaControl.Document; string text = document.TextContent; int offset; if (options.HasFlag(NiFindOptions.Backwards)) { if (resetStartPoint) offset = text.Length; else offset = _textAreaControl.Caret.Offset; } else { if (resetStartPoint) offset = 0; else if (_textAreaControl.SelectionManager.HasSomethingSelected) offset = _textAreaControl.SelectionManager.SelectionCollection.Last().EndOffset; else offset = _textAreaControl.Caret.Offset; } int matchLength; string replacement; bool found; ErrorUtil.ThrowOnFailure(helper.FindInText( search, replace, options, text, offset, out offset, out matchLength, out replacement, out found )); if (found) { MarkSpan(GetTextSpan(document, offset, matchLength)); result = replace == null ? NiFindResult.Found : NiFindResult.Replaced; } else { result = NiFindResult.NotFound; } return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
private void OpenFindWindow(NiFindOptions options) { FindControl.Show(Site, ActiveTextAreaControl.TextArea, options, NiFindOptions.ActionMask, FindTarget); }
public HResult FindInText(string find, string replace, NiFindOptions options, string text, int offset, out int found, out int matchLength, out string replacementText, out bool isFound) { found = 0; matchLength = 0; replacementText = null; isFound = false; try { if (find == null) { throw new ArgumentNullException("find"); } if (text == null) { throw new ArgumentNullException("text"); } string pattern = options.HasFlag(NiFindOptions.RegExp) ? find : Regex.Escape(find); if (options.HasFlag(NiFindOptions.WholeWord)) { pattern = @"\b" + pattern + @"\b"; } var regexOptions = RegexOptions.Multiline; if (!options.HasFlag(NiFindOptions.MatchCase)) { regexOptions |= RegexOptions.IgnoreCase; } if (options.HasFlag(NiFindOptions.Backwards)) { regexOptions |= RegexOptions.RightToLeft; } var match = new Regex(pattern, regexOptions).Match(text, offset); isFound = match.Success; if (isFound) { found = match.Index; matchLength = match.Length; } if (replace != null) { throw new NotImplementedException(); } return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public HResult Replace(string search, string replace, NiFindOptions options, bool resetStartPoint, INiFindHelper helper, out NiFindResult result) { return(Control.FindTarget.Replace(search, replace, options, resetStartPoint, helper, out result)); }