Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
53 src/AddIns/Misc/SearchAndReplace/Project/Commands/SearchMainMenuCommands.cs
@@ -51,59 +51,6 @@ public override void Run()
}
}
- /// <summary>
- /// Finds the next text match based on the text currently
- /// selected. It uses the currently active search options and only changes
- /// the current find pattern. If the currently active search is inside the
- /// current text selection then the quick find will change the search so it is
- /// across the active document, otherwise it will not change the current setting.
- /// </summary>
- /// <remarks>
- /// If there is a piece of text selected on a single line then the quick
- /// find will search for that. If multiple lines of text are selected then
- /// the word at the start of the selection is determined and searche for.
- /// If no text is selected then the word next to the caret is used. If
- /// no text is selected, but the caret is immediately surrounded by whitespace
- /// then quick find does nothing.
- /// </remarks>
- public class FindNextSelected : AbstractMenuCommand
- {
- public override void Run()
- {
- ITextEditor textArea = SearchManager.GetActiveTextEditor();
- if (textArea == null) {
- return;
- }
-
- // Determine what text we should search for.
- string textToFind;
-
- string selectedText = textArea.SelectedText;
- if (selectedText.Length > 0) {
- if (Find.IsMultipleLines(selectedText)) {
- // Locate the nearest word at the selection start.
- textToFind = textArea.Document.GetWordAt(textArea.SelectionStart);
- } else {
- // Search for selected text.
- textToFind = selectedText;
- }
- } else {
- textToFind = textArea.Document.GetWordAt(textArea.Caret.Offset);
- }
-
- if (textToFind != null && textToFind.Length > 0) {
- SearchOptions.CurrentFindPattern = textToFind;
- if (SearchOptions.SearchTarget == SearchTarget.CurrentSelection) {
- SearchOptions.SearchTarget = SearchTarget.CurrentDocument;
- }
- var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection() : null);
- var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
- var result = SearchManager.FindNext(strategy, location);
- SearchManager.SelectResult(result);
- }
- }
- }
-
public class Replace : AbstractMenuCommand
{
public override void Run()
View
5 src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.addin
@@ -23,11 +23,6 @@
icon = "Icons.16x16.FindNextIcon"
shortcut = "F3"
class = "SearchAndReplace.FindNext"/>
- <MenuItem id = "FindNextSelected"
- insertafter = "FindNext"
- label = "${res:XML.MainMenu.SearchMenu.FindNextSelected}"
- shortcut = "Control|F3"
- class = "SearchAndReplace.FindNextSelected"/>
<MenuItem id = "Replace"
insertafter = "FindNextSelected"
insertbefore = "SearchSeparator"
View
3 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/ISearchStrategy.cs
@@ -36,6 +36,9 @@ public interface ISearchStrategy : IEquatable<ISearchStrategy>
/// </summary>
public interface ISearchResult : ISegment
{
+ /// <summary>
+ /// Replaces parts of the replacement string with parts from the match. (e.g. $1)
+ /// </summary>
string ReplaceWith(string replacement);
}
View
2 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchCommands.cs
@@ -71,7 +71,7 @@ void RegisterCommands(ICollection<CommandBinding> commandBindings)
void ExecuteFind(object sender, ExecutedRoutedEventArgs e)
{
- if (panel == null) {
+ if (panel == null || panel.IsClosed) {
panel = new SearchPanel();
panel.Attach(TextArea);
}
View
40 src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Search/SearchPanel.cs
@@ -21,6 +21,9 @@
namespace ICSharpCode.AvalonEdit.Search
{
+ /// <summary>
+ /// Provides search functionality for AvalonEdit. It is displayed in the top-right corner of the TextArea.
+ /// </summary>
public class SearchPanel : Control
{
TextArea textArea;
@@ -30,46 +33,76 @@ public class SearchPanel : Control
TextBox searchTextBox;
SearchPanelAdorner adorner;
+ /// <summary>
+ /// Dependency property for <see cref="UseRegex"/>.
+ /// </summary>
public static readonly DependencyProperty UseRegexProperty =
DependencyProperty.Register("UseRegex", typeof(bool), typeof(SearchPanel),
new FrameworkPropertyMetadata(false, SearchPatternChangedCallback));
+ /// <summary>
+ /// Gets/sets whether the search pattern should be interpreted as regular expression.
+ /// </summary>
public bool UseRegex {
get { return (bool)GetValue(UseRegexProperty); }
set { SetValue(UseRegexProperty, value); }
}
+ /// <summary>
+ /// Dependency property for <see cref="MatchCase"/>.
+ /// </summary>
public static readonly DependencyProperty MatchCaseProperty =
DependencyProperty.Register("MatchCase", typeof(bool), typeof(SearchPanel),
new FrameworkPropertyMetadata(false, SearchPatternChangedCallback));
+ /// <summary>
+ /// Gets/sets whether the search pattern should be interpreted case-sensitive.
+ /// </summary>
public bool MatchCase {
get { return (bool)GetValue(MatchCaseProperty); }
set { SetValue(MatchCaseProperty, value); }
}
+ /// <summary>
+ /// Dependency property for <see cref="WholeWords"/>.
+ /// </summary>
public static readonly DependencyProperty WholeWordsProperty =
DependencyProperty.Register("WholeWords", typeof(bool), typeof(SearchPanel),
new FrameworkPropertyMetadata(false, SearchPatternChangedCallback));
+ /// <summary>
+ /// Gets/sets whether the search pattern should only match whole words.
+ /// </summary>
public bool WholeWords {
get { return (bool)GetValue(WholeWordsProperty); }
set { SetValue(WholeWordsProperty, value); }
}
+ /// <summary>
+ /// Dependency property for <see cref="SearchPattern"/>.
+ /// </summary>
public static readonly DependencyProperty SearchPatternProperty =
DependencyProperty.Register("SearchPattern", typeof(string), typeof(SearchPanel),
new FrameworkPropertyMetadata("", SearchPatternChangedCallback));
+ /// <summary>
+ /// Gets/sets the search pattern.
+ /// </summary>
public string SearchPattern {
get { return (string)GetValue(SearchPatternProperty); }
set { SetValue(SearchPatternProperty, value); }
}
+ /// <summary>
+ /// Dependency property for <see cref="MarkerBrush"/>.
+ /// </summary>
public static readonly DependencyProperty MarkerBrushProperty =
DependencyProperty.Register("MarkerBrush", typeof(Brush), typeof(SearchPanel),
new FrameworkPropertyMetadata(Brushes.LightGreen, MarkerBrushChangedCallback));
+ /// <summary>
+ /// Gets/sets the Brush used for marking search results in the TextView.
+ /// </summary>
public Brush MarkerBrush {
get { return (Brush)GetValue(MarkerBrushProperty); }
set { SetValue(MarkerBrushProperty, value); }
@@ -291,6 +324,11 @@ void SearchLayerKeyDown(object sender, KeyEventArgs e)
}
/// <summary>
+ /// Gets whether the Panel is already closed.
+ /// </summary>
+ public bool IsClosed { get; private set; }
+
+ /// <summary>
/// Closes the SearchPanel.
/// </summary>
public void Close()
@@ -303,6 +341,8 @@ public void Close()
if (currentDocument != null)
currentDocument.TextChanged -= textArea_Document_TextChanged;
messageView.IsOpen = false;
+ textArea.Focus();
+ IsClosed = true;
}
}

No commit comments for this range

Something went wrong with that request. Please try again.