Open in external.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2020-07-18 18:00:26 +02:00
parent 42d5a08c3b
commit 89faa9d45c
3 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
import { injectable } from 'inversify';
import { remote } from 'electron';
import { ArduinoMenus } from '../menu/arduino-menus';
import { SketchContribution, Command, CommandRegistry, MenuModelRegistry, KeybindingRegistry, URI } from './contribution';
@injectable()
export class OpenSketchExternal extends SketchContribution {
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(OpenSketchExternal.Commands.OPEN_EXTERNAL, {
execute: () => this.openExternal()
});
}
registerMenus(registry: MenuModelRegistry): void {
registry.registerMenuAction(ArduinoMenus.SKETCH__UTILS_GROUP, {
commandId: OpenSketchExternal.Commands.OPEN_EXTERNAL.id,
label: 'Show Sketch Folder',
order: '0'
});
}
registerKeybindings(registry: KeybindingRegistry): void {
registry.registerKeybinding({
command: OpenSketchExternal.Commands.OPEN_EXTERNAL.id,
keybinding: 'CtrlCmd+Alt+K'
});
}
protected async openExternal(): Promise<void> {
const sketch = await this.currentSketch();
if (sketch) {
const uri = new URI(sketch.uri).resolve(`${sketch.name}.ino`).toString();
const exists = this.fileSystem.exists(uri);
if (exists) {
const fsPath = await this.fileSystem.getFsPath(uri);
if (fsPath) {
remote.shell.showItemInFolder(fsPath);
}
}
}
}
}
export namespace OpenSketchExternal {
export namespace Commands {
export const OPEN_EXTERNAL: Command = {
id: 'arduino-open-sketch-external'
};
}
}