Skip to content

Commit 6de67b5

Browse files
committed
Add keymaps customization support
1 parent f6e623c commit 6de67b5

File tree

10 files changed

+1071
-884
lines changed

10 files changed

+1071
-884
lines changed

arduino-ide-extension/package.json

+1
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

+4-1
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();
@@ -424,6 +427,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
424427
bind(SettingsWidget).toSelf().inSingletonScope();
425428
bind(SettingsDialog).toSelf().inSingletonScope();
426429
bind(SettingsDialogProps).toConstantValue({
427-
title: 'Preferences'
430+
title: 'Settings'
428431
});
429432
});

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

+3-2
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__PREFERENCES_SUBMENU, 'Preferences');
37+
registry.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_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

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ export namespace ArduinoMenus {
88
// -- File
99
export const FILE__SKETCH_GROUP = [...CommonMenus.FILE, '0_sketch'];
1010
export const FILE__PRINT_GROUP = [...CommonMenus.FILE, '1_print'];
11-
// XXX: on macOS, the settings group is not under `File`
12-
export const FILE__SETTINGS_GROUP = [...(isOSX ? MAIN_MENU_BAR : CommonMenus.FILE), '2_settings'];
11+
// XXX: on macOS, the preferences group is not under `File`
12+
// The empty path ensures no top level menu is created for the preferences, even if they contains sub menus
13+
export const FILE__PREFERENCES_GROUP = [...(isOSX ? [''] : CommonMenus.FILE), '2_preferences'];
14+
export const FILE__PREFERENCES_SUBMENU = [...FILE__PREFERENCES_GROUP, '0_preferences_sub'];
15+
1316
export const FILE__QUIT_GROUP = [...CommonMenus.FILE, '3_quit'];
1417

1518
// -- File / Open Recent

arduino-ide-extension/src/browser/settings.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
254254
}
255255
return <Tabs>
256256
<TabList>
257-
<Tab>Settings</Tab>
257+
<Tab>General</Tab>
258258
<Tab>Network</Tab>
259259
</TabList>
260260
<TabPanel>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
@injectable()
7+
export class KeymapsFrontendContribution extends TheiaKeymapsFrontendContribution {
8+
9+
registerMenus(menus: MenuModelRegistry): void {
10+
menus.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_SUBMENU, {
11+
commandId: KeymapsCommands.OPEN_KEYMAPS.id,
12+
label: 'Keyboard Shortcuts',
13+
order: '1'
14+
});
15+
}
16+
}

arduino-ide-extension/src/electron-browser/theia/core/electron-main-menu-factory.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ export class ElectronMainMenuFactory extends TheiaElectronMainMenuFactory {
2626
const { submenu } = super.createOSXMenu();
2727
const label = 'Arduino IDE';
2828
if (!!submenu && !(submenu instanceof remote.Menu)) {
29-
const [/* about */, /* settings */, ...rest] = submenu;
29+
const [/* about */, /* preferences */, ...rest] = submenu;
3030
const about = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.HELP__ABOUT_GROUP));
31-
const settings = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.FILE__SETTINGS_GROUP));
31+
const preferences = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.FILE__PREFERENCES_GROUP));
3232
return {
3333
label,
3434
submenu: [
3535
...about,
3636
{ type: 'separator' },
37-
...settings,
37+
...preferences,
3838
{ type: 'separator' },
3939
...rest
4040
]

browser-app/package.json

+1
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

+1
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)