Skip to content

ATL-1118: Add keymaps customization support #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@theia/editor": "next",
"@theia/filesystem": "next",
"@theia/git": "next",
"@theia/keymaps": "next",
"@theia/markers": "next",
"@theia/monaco": "next",
"@theia/navigator": "next",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { ProblemContribution as TheiaProblemContribution } from '@theia/markers/
import { ProblemContribution } from './theia/markers/problem-contribution';
import { FileNavigatorContribution } from './theia/navigator/navigator-contribution';
import { FileNavigatorContribution as TheiaFileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
import { KeymapsFrontendContribution } from './theia/keymaps/keymaps-frontend-contribution';
import { KeymapsFrontendContribution as TheiaKeymapsFrontendContribution } from '@theia/keymaps/lib/browser/keymaps-frontend-contribution';
import { ArduinoToolbarContribution } from './toolbar/arduino-toolbar-contribution';
import { EditorContribution as TheiaEditorContribution } from '@theia/editor/lib/browser/editor-contribution';
import { EditorContribution } from './theia/editor/editor-contribution';
Expand Down Expand Up @@ -278,6 +280,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
rebind(TheiaOutlineViewContribution).to(OutlineViewContribution).inSingletonScope();
rebind(TheiaProblemContribution).to(ProblemContribution).inSingletonScope();
rebind(TheiaFileNavigatorContribution).to(FileNavigatorContribution).inSingletonScope();
rebind(TheiaKeymapsFrontendContribution).to(KeymapsFrontendContribution).inSingletonScope();
rebind(TheiaEditorContribution).to(EditorContribution).inSingletonScope();
rebind(TheiaMonacoStatusBarContribution).to(MonacoStatusBarContribution).inSingletonScope();
rebind(TheiaApplicationShell).to(ApplicationShell).inSingletonScope();
Expand Down
3 changes: 2 additions & 1 deletion arduino-ide-extension/src/browser/contributions/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ export class Settings extends SketchContribution {
}

registerMenus(registry: MenuModelRegistry): void {
registry.registerMenuAction(ArduinoMenus.FILE__SETTINGS_GROUP, {
registry.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_GROUP, {
commandId: Settings.Commands.OPEN.id,
label: 'Preferences...',
order: '0'
});
registry.registerSubmenu(ArduinoMenus.FILE__ADVANCED_SUBMENU, 'Advanced');
}

registerKeybindings(registry: KeybindingRegistry): void {
Expand Down
8 changes: 6 additions & 2 deletions arduino-ide-extension/src/browser/menu/arduino-menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ export namespace ArduinoMenus {
// -- File
export const FILE__SKETCH_GROUP = [...CommonMenus.FILE, '0_sketch'];
export const FILE__PRINT_GROUP = [...CommonMenus.FILE, '1_print'];
// XXX: on macOS, the settings group is not under `File`
export const FILE__SETTINGS_GROUP = [...(isOSX ? MAIN_MENU_BAR : CommonMenus.FILE), '2_settings'];
// XXX: on macOS, the "Preferences" and "Advanced" group is not under `File`
// The empty path ensures no top level menu is created for the preferences, even if they contains sub menus
export const FILE__PREFERENCES_GROUP = [...(isOSX ? [''] : CommonMenus.FILE), '2_preferences'];
export const FILE__ADVANCED_GROUP = [...(isOSX ? [''] : CommonMenus.FILE), '3_advanced'];
export const FILE__ADVANCED_SUBMENU = [...FILE__ADVANCED_GROUP, '0_advanced_sub'];

export const FILE__QUIT_GROUP = [...CommonMenus.FILE, '3_quit'];

// -- File / Open Recent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { injectable } from 'inversify';
import { MenuModelRegistry } from '@theia/core';
import { KeymapsFrontendContribution as TheiaKeymapsFrontendContribution, KeymapsCommands } from '@theia/keymaps/lib/browser/keymaps-frontend-contribution';
import { ArduinoMenus } from '../../menu/arduino-menus';

@injectable()
export class KeymapsFrontendContribution extends TheiaKeymapsFrontendContribution {

registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(ArduinoMenus.FILE__ADVANCED_SUBMENU, {
commandId: KeymapsCommands.OPEN_KEYMAPS.id,
label: 'Keyboard Shortcuts',
order: '1'
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ export class ElectronMainMenuFactory extends TheiaElectronMainMenuFactory {
const { submenu } = super.createOSXMenu();
const label = 'Arduino IDE';
if (!!submenu && !(submenu instanceof remote.Menu)) {
const [/* about */, /* settings */, ...rest] = submenu;
const [/* about */, /* preferences */, ...rest] = submenu;
const about = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.HELP__ABOUT_GROUP));
const settings = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.FILE__SETTINGS_GROUP));
const preferences = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.FILE__PREFERENCES_GROUP));
const advanced = this.fillMenuTemplate([], this.menuProvider.getMenu(ArduinoMenus.FILE__ADVANCED_GROUP));
return {
label,
submenu: [
...about,
{ type: 'separator' },
...settings,
...preferences,
...advanced,
{ type: 'separator' },
...rest
]
Expand Down
1 change: 1 addition & 0 deletions browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@theia/editor": "next",
"@theia/file-search": "next",
"@theia/filesystem": "next",
"@theia/keymaps": "next",
"@theia/messages": "next",
"@theia/monaco": "next",
"@theia/navigator": "next",
Expand Down
1 change: 1 addition & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@theia/electron": "next",
"@theia/file-search": "next",
"@theia/filesystem": "next",
"@theia/keymaps": "next",
"@theia/messages": "next",
"@theia/monaco": "next",
"@theia/navigator": "next",
Expand Down
Loading