Skip to content

Commit 0fd31ea

Browse files
committed
Add keymaps customization support
1 parent 1e0f52b commit 0fd31ea

File tree

8 files changed

+1050
-849
lines changed

8 files changed

+1050
-849
lines changed

arduino-ide-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@theia/editor": "next",
2424
"@theia/filesystem": "next",
2525
"@theia/git": "next",
26+
"@theia/keymaps": "next",
2627
"@theia/markers": "next",
2728
"@theia/monaco": "next",
2829
"@theia/navigator": "next",

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { ProblemContribution as TheiaProblemContribution } from '@theia/markers/
2424
import { ProblemContribution } from './theia/markers/problem-contribution';
2525
import { FileNavigatorContribution } from './theia/navigator/navigator-contribution';
2626
import { FileNavigatorContribution as TheiaFileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
27+
import { KeymapsFrontendContribution } from './theia/keymaps/keymaps-frontend-contribution';
28+
import { KeymapsFrontendContribution as TheiaKeymapsFrontendContribution } from '@theia/keymaps/lib/browser/keymaps-frontend-contribution';
2729
import { ArduinoToolbarContribution } from './toolbar/arduino-toolbar-contribution';
2830
import { EditorContribution as TheiaEditorContribution } from '@theia/editor/lib/browser/editor-contribution';
2931
import { EditorContribution } from './theia/editor/editor-contribution';
@@ -278,6 +280,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
278280
rebind(TheiaOutlineViewContribution).to(OutlineViewContribution).inSingletonScope();
279281
rebind(TheiaProblemContribution).to(ProblemContribution).inSingletonScope();
280282
rebind(TheiaFileNavigatorContribution).to(FileNavigatorContribution).inSingletonScope();
283+
rebind(TheiaKeymapsFrontendContribution).to(KeymapsFrontendContribution).inSingletonScope();
281284
rebind(TheiaEditorContribution).to(EditorContribution).inSingletonScope();
282285
rebind(TheiaMonacoStatusBarContribution).to(MonacoStatusBarContribution).inSingletonScope();
283286
rebind(TheiaApplicationShell).to(ApplicationShell).inSingletonScope();

arduino-ide-extension/src/browser/contributions/settings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ export class Settings extends SketchContribution {
3333
}
3434

3535
registerMenus(registry: MenuModelRegistry): void {
36-
registry.registerMenuAction(ArduinoMenus.FILE__SETTINGS_GROUP, {
36+
registry.registerSubmenu(ArduinoMenus.FILE__SETTINGS_SUBMENU, 'Preferences...', { order: '1' });
37+
registry.registerMenuAction(ArduinoMenus.FILE__SETTINGS_SUBMENU, {
3738
commandId: Settings.Commands.OPEN.id,
38-
label: 'Preferences...',
39+
label: 'Settings...',
3940
order: '0'
4041
});
4142
}

arduino-ide-extension/src/browser/menu/arduino-menus.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export namespace ArduinoMenus {
2525
export const EXAMPLES__CURRENT_BOARD_GROUP = [...FILE__EXAMPLES_SUBMENU, '2_current_board'];
2626
export const EXAMPLES__USER_LIBS_GROUP = [...FILE__EXAMPLES_SUBMENU, '3_user_libs'];
2727

28+
// -- File / Preferences
29+
export const FILE__SETTINGS_SUBMENU = [...FILE__SETTINGS_GROUP, '0_preferences'];
30+
2831
// -- Edit
2932
// `Copy`, `Copy to Forum`, `Paste`, etc.
3033
// Note: `1_undo` is the first group from Theia, we start with `2`
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { injectable } from 'inversify';
2+
import { MenuModelRegistry } from '@theia/core';
3+
import { KeymapsFrontendContribution as TheiaKeymapsFrontendContribution, KeymapsCommands } from '@theia/keymaps/lib/browser/keymaps-frontend-contribution';
4+
import { ArduinoMenus } from '../../menu/arduino-menus';
5+
6+
7+
@injectable()
8+
export class KeymapsFrontendContribution extends TheiaKeymapsFrontendContribution {
9+
10+
constructor() {
11+
super();
12+
}
13+
14+
registerMenus(menus: MenuModelRegistry): void {
15+
16+
menus.registerMenuAction(ArduinoMenus.FILE__SETTINGS_SUBMENU, {
17+
commandId: KeymapsCommands.OPEN_KEYMAPS.id,
18+
order: 'a20'
19+
});
20+
21+
// menus.registerMenuAction(CommonMenus.FILE_SETTINGS_SUBMENU_OPEN, {
22+
// commandId: KeymapsCommands.OPEN_KEYMAPS.id,
23+
// order: 'a20'
24+
// });
25+
// menus.registerMenuAction(CommonMenus.SETTINGS_OPEN, {
26+
// commandId: KeymapsCommands.OPEN_KEYMAPS.id,
27+
// order: 'a20'
28+
// });
29+
}
30+
31+
// CAN WE GET RID OF registerToolbarItems?
32+
33+
// async registerToolbarItems(toolbar: TabBarToolbarRegistry): Promise<void> {
34+
// const widget = await this.widget;
35+
// const onDidChange = widget.onDidUpdate;
36+
// toolbar.registerItem({
37+
// id: KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR.id,
38+
// command: KeymapsCommands.OPEN_KEYMAPS_JSON_TOOLBAR.id,
39+
// tooltip: 'Open Keyboard Shortcuts in JSON',
40+
// priority: 0,
41+
// });
42+
// toolbar.registerItem({
43+
// id: KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH.id,
44+
// command: KeymapsCommands.CLEAR_KEYBINDINGS_SEARCH.id,
45+
// tooltip: 'Clear Keybindings Search Input',
46+
// priority: 1,
47+
// onDidChange,
48+
// });
49+
// }
50+
}

browser-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"@theia/editor": "next",
1010
"@theia/file-search": "next",
1111
"@theia/filesystem": "next",
12+
"@theia/keymaps": "next",
1213
"@theia/messages": "next",
1314
"@theia/monaco": "next",
1415
"@theia/navigator": "next",

electron-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@theia/electron": "next",
1212
"@theia/file-search": "next",
1313
"@theia/filesystem": "next",
14+
"@theia/keymaps": "next",
1415
"@theia/messages": "next",
1516
"@theia/monaco": "next",
1617
"@theia/navigator": "next",

0 commit comments

Comments
 (0)