Skip to content

Commit 5f931ee

Browse files
Maximilian WittmerMaximilian Wittmer
authored andcommitted
FindReplaceOverlay: add support from mnemonics from the Dialog
In order to preserve the workflow of users who use the Mnemonics of the Find/Replace Dialog a lot, add support to these key combinations as well fixes #2080
1 parent fe8a805 commit 5f931ee

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,28 @@
8080
public class FindReplaceOverlay extends Dialog {
8181
private final class KeyboardShortcuts {
8282
private static final List<KeyStroke> SEARCH_FORWARD = List.of( //
83-
KeyStroke.getInstance(SWT.CR), KeyStroke.getInstance(SWT.KEYPAD_CR));
83+
KeyStroke.getInstance(SWT.CR), KeyStroke.getInstance(SWT.KEYPAD_CR),
84+
KeyStroke.getInstance(SWT.ALT, 'n'));
8485
private static final List<KeyStroke> SEARCH_BACKWARD = List.of( //
8586
KeyStroke.getInstance(SWT.SHIFT, SWT.CR), KeyStroke.getInstance(SWT.SHIFT, SWT.KEYPAD_CR));
8687
private static final List<KeyStroke> SEARCH_ALL = List.of( //
87-
KeyStroke.getInstance(SWT.MOD1, SWT.CR), KeyStroke.getInstance(SWT.MOD1, SWT.KEYPAD_CR));
88+
KeyStroke.getInstance(SWT.MOD1, SWT.CR), KeyStroke.getInstance(SWT.MOD1, SWT.KEYPAD_CR),
89+
KeyStroke.getInstance(SWT.ALT, 's'));
90+
private static final List<KeyStroke> REPLACE_ALL = List.of( //
91+
KeyStroke.getInstance(SWT.MOD1, SWT.CR), KeyStroke.getInstance(SWT.MOD1, SWT.KEYPAD_CR),
92+
KeyStroke.getInstance(SWT.ALT, 'a'));
8893
private static final List<KeyStroke> OPTION_CASE_SENSITIVE = List.of( //
89-
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'C'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'c'));
94+
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'C'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'c'),
95+
KeyStroke.getInstance(SWT.ALT, 'c'));
9096
private static final List<KeyStroke> OPTION_WHOLE_WORD = List.of( //
91-
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'W'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'w'));
97+
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'W'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'w'),
98+
KeyStroke.getInstance(SWT.ALT, 'w'));
9299
private static final List<KeyStroke> OPTION_REGEX = List.of( //
93-
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'P'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'p'));
100+
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'P'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'p'),
101+
KeyStroke.getInstance(SWT.ALT, 'X'));
94102
private static final List<KeyStroke> OPTION_SEARCH_IN_SELECTION = List.of( //
95-
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'A'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'a'));
103+
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'A'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'a'),
104+
KeyStroke.getInstance(SWT.ALT, 'l'));
96105
private static final List<KeyStroke> CLOSE = List.of( //
97106
KeyStroke.getInstance(SWT.ESC), KeyStroke.getInstance(SWT.MOD1, 'F'),
98107
KeyStroke.getInstance(SWT.MOD1, 'f'));
@@ -597,7 +606,7 @@ private void createReplaceTools() {
597606
return;
598607
}
599608
performReplaceAll();
600-
}).withShortcuts(KeyboardShortcuts.SEARCH_ALL).build();
609+
}).withShortcuts(KeyboardShortcuts.REPLACE_ALL).build();
601610
}
602611

603612
private void createSearchBar() {

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceShortcutUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static private KeyStroke extractKeyStroke(KeyEvent e) {
3636
if (ctrlDown && e.character != e.keyCode && e.character < 0x20 && (e.keyCode & SWT.KEYCODE_BIT) == 0) {
3737
character += 0x40;
3838
}
39-
KeyStroke actualStroke = KeyStroke.getInstance(e.stateMask & (SWT.MOD1 | SWT.SHIFT),
39+
KeyStroke actualStroke = KeyStroke.getInstance(e.stateMask & (SWT.MOD1 | SWT.SHIFT | SWT.ALT),
4040
character == 0 ? e.keyCode : character);
4141
return actualStroke;
4242
}

0 commit comments

Comments
 (0)