Skip to content

Commit ebb2473

Browse files
committed
allow switch between both modes
1 parent 1d609fc commit ebb2473

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

ICSharpCode.AvalonEdit/Search/SearchCommands.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ namespace ICSharpCode.AvalonEdit.Search {
3333
/// Search commands for AvalonEdit.
3434
/// </summary>
3535
public static class SearchCommands {
36+
/// <summary>
37+
/// Opens the Find panel
38+
/// </summary>
39+
public static readonly RoutedCommand Find = new RoutedCommand(
40+
"Find", typeof(SearchPanel),
41+
new InputGestureCollection { new KeyGesture(Key.F, ModifierKeys.Control) }
42+
);
43+
44+
/// <summary>
45+
/// Opens the Replace panel
46+
/// </summary>
47+
public static readonly RoutedCommand Replace = new RoutedCommand(
48+
"Replace", typeof(SearchPanel),
49+
new InputGestureCollection { new KeyGesture(Key.H, ModifierKeys.Control) }
50+
);
51+
3652
/// <summary>
3753
/// Finds the next occurrence in the file.
3854
/// </summary>
@@ -97,6 +113,8 @@ internal SearchInputHandler(TextArea textArea, SearchPanel panel)
97113
internal void RegisterGlobalCommands(CommandBindingCollection commandBindings) {
98114
commandBindings.Add(new CommandBinding(ApplicationCommands.Find, ExecuteFind));
99115
commandBindings.Add(new CommandBinding(ApplicationCommands.Replace, ExecuteReplace));
116+
commandBindings.Add(new CommandBinding(SearchCommands.Find, ExecuteFind));
117+
commandBindings.Add(new CommandBinding(SearchCommands.Replace, ExecuteReplace));
100118
commandBindings.Add(new CommandBinding(SearchCommands.FindNext, ExecuteFindNext, CanExecuteWithOpenSearchPanel));
101119
commandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, ExecuteFindPrevious, CanExecuteWithOpenSearchPanel));
102120
commandBindings.Add(new CommandBinding(SearchCommands.ReplaceNext, ExecuteReplaceNext, CanExecuteWithOpenSearchPanel));
@@ -106,6 +124,8 @@ internal void RegisterGlobalCommands(CommandBindingCollection commandBindings) {
106124
void RegisterCommands(ICollection<CommandBinding> commandBindings) {
107125
commandBindings.Add(new CommandBinding(ApplicationCommands.Find, ExecuteFind));
108126
commandBindings.Add(new CommandBinding(ApplicationCommands.Replace, ExecuteReplace));
127+
commandBindings.Add(new CommandBinding(SearchCommands.Find, ExecuteFind));
128+
commandBindings.Add(new CommandBinding(SearchCommands.Replace, ExecuteReplace));
109129
commandBindings.Add(new CommandBinding(SearchCommands.FindNext, ExecuteFindNext, CanExecuteWithOpenSearchPanel));
110130
commandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, ExecuteFindPrevious, CanExecuteWithOpenSearchPanel));
111131
commandBindings.Add(new CommandBinding(SearchCommands.ReplaceNext, ExecuteReplaceNext, CanExecuteWithOpenSearchPanel));

ICSharpCode.AvalonEdit/Search/SearchPanel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ void AttachInternal(TextArea textArea) {
267267
textArea.DocumentChanged += textArea_DocumentChanged;
268268
KeyDown += SearchLayerKeyDown;
269269

270+
this.CommandBindings.Add(new CommandBinding(SearchCommands.Find, (sender, e) => Open(false)));
271+
this.CommandBindings.Add(new CommandBinding(SearchCommands.Replace, (sender, e) => Open(true)));
270272
this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext()));
271273
this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious()));
272274
this.CommandBindings.Add(new CommandBinding(SearchCommands.ReplaceNext, (sender, e) => ReplaceNext()));

0 commit comments

Comments
 (0)