8000 Renamed the application to Arduino IDE by kittaakos · Pull Request #1 · arduino/arduino-ide · GitHub
[go: up one dir, main page]

Skip to content

Renamed the application to Arduino IDE #1

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 11 commits into from
Feb 11, 2021
Prev Previous commit
Next Next commit
ATL-885: Refined the 'Close' behavior.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta committed Feb 10, 2021
commit b34491269524eff0985fb624823c400f583c218a
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import { WorkspaceFrontendContribution, ArduinoFileMenuContribution } from './th
import { Contribution } from './contributions/contribution';
import { NewSketch } from './contributions/new-sketch';
import { OpenSketch } from './contributions/open-sketch';
import { CloseSketch } from './contributions/close-sketch';
import { Close } from './contributions/close';
import { SaveAsSketch } from './contributions/save-as-sketch';
import { SaveSketch } from './contributions/save-sketch';
import { VerifySketch } from './contributions/verify-sketch';
Expand Down Expand Up @@ -326,7 +326,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {

Contribution.configure(bind, NewSketch);
Contribution.configure(bind, OpenSketch);
Contribution.configure(bind, CloseSketch);
Contribution.configure(bind, Close);
Contribution.configure(bind, SaveSketch);
Contribution.configure(bind, SaveAsSketch);
Contribution.configure(bind, VerifySketch);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
import { inject, injectable } from 'inversify';
import { toArray } from '@phosphor/algorithm';
import { remote } from 'electron';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
import { ApplicationShell } from '@theia/core/lib/browser/shell/application-shell';
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
import { ArduinoMenus } from '../menu/arduino-menus';
import { SketchContribution, Command, CommandRegistry, MenuModelRegistry, KeybindingRegistry, URI } from './contribution';
import { SaveAsSketch } from './save-as-sketch';
import { EditorManager } from '@theia/editor/lib/browser';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { SketchContribution, Command, CommandRegistry, MenuModelRegistry, KeybindingRegistry, URI } from './contribution';

/**
* Closes the `current` closeable editor, or any closeable current widget from the main area, or the current sketch window.
*/
@injectable()
export class CloseSketch extends SketchContribution {
export class Close extends SketchContribution {

@inject(EditorManager)
protected readonly editorManager: EditorManager;

protected shell: ApplicationShell;

onStart(app: FrontendApplication): void {
this.shell = app.shell;
}

registerCommands(registry: CommandRegistry): void {
registry.registerCommand(CloseSketch.Commands.CLOSE_SKETCH, {
registry.registerCommand(Close.Commands.CLOSE, {
execute: async () => {

// Close current editor if closeable.
const { currentEditor } = this.editorManager;
if (currentEditor && currentEditor.title.closable) {
currentEditor.close();
return;
}

// Close current widget from the main area if possible.
const { currentWidget } = this.shell;
if (currentWidget) {
const currentWidgetInMain = toArray(this.shell.mainPanel.widgets()).find(widget => widget === currentWidget);
if (currentWidgetInMain && currentWidgetInMain.title.closable) {
return currentWidgetInMain.close();
}
}

// Close the sketch (window).
const sketch = await this.sketchServiceClient.currentSketch();
if (!sketch) {
return;
Expand Down Expand Up @@ -48,15 +78,15 @@ export class CloseSketch extends SketchContribution {

registerMenus(registry: MenuModelRegistry): void {
registry.registerMenuAction(ArduinoMenus.FILE__SKETCH_GROUP, {
commandId: CloseSketch.Commands.CLOSE_SKETCH.id,
commandId: Close.Commands.CLOSE.id,
label: 'Close',
order: '5'
});
}

registerKeybindings(registry: KeybindingRegistry): void {
registry.registerKeybinding({
command: CloseSketch.Commands.CLOSE_SKETCH.id,
command: Close.Commands.CLOSE.id,
keybinding: 'CtrlCmd+W'
});
}
Expand All @@ -80,10 +110,10 @@ export class CloseSketch extends SketchContribution {

}

export namespace CloseSketch {
export namespace Close {
export namespace Commands {
export const CLOSE_SKETCH: Command = {
id: 'arduino-close-sketch'
export const CLOSE: Command = {
id: 'arduino-close'
};
}
}
0