Skip to content

Commit b1fa180

Browse files
committed
ATL-372: .ino file associations
1 parent 9867122 commit b1fa180

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

+31
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,40 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
2323
// See: https://github.com/electron-userland/electron-builder/issues/2468
2424
// Regression in Theia: https://github.com/eclipse-theia/theia/issues/8701
2525
app.on('ready', () => app.setName(config.applicationName));
26+
27+
// Add file associations to the app
28+
this.attachFileAssociations();
29+
2630
return super.start(config);
2731
}
2832

33+
attachFileAssociations() {
34+
35+
// OSX: register open-file event
36+
if (process.platform === 'darwin') {
37+
app.on('open-file', (event, uri) => {
38+
event.preventDefault();
39+
// TODO: check if the URI is a .ino file
40+
// should I call openSketchFiles(uri) ?
41+
});
42+
}
43+
44+
// WIN: read file(s) uri from executable args
45+
if (process.platform === 'win32') {
46+
if (app.isPackaged) {
47+
// workaround for missing executable argument when app is packaged
48+
process.argv.unshift('packaged');
49+
}
50+
// parameters is an array containing any files/folders that your OS will pass to your application
51+
const uri = process.argv.slice(2) || null;
52+
if (uri) {
53+
// TODO: filter out only the first .ino file in the array
54+
// should I call openSketchFiles(uri) ?
55+
}
56+
}
57+
58+
}
59+
2960
/**
3061
* Use this rather than creating `BrowserWindow` instances from scratch, since some security parameters need to be set, this method will do it.
3162
*

electron/build/template-package.json

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
"directories": {
5454
"buildResources": "resources"
5555
},
56+
"fileAssociations": [
57+
{
58+
"ext": ["ino"],
59+
"role": "Editor"
60+
}
61+
],
5662
"files": [
5763
"src-gen",
5864
"lib",

0 commit comments

Comments
 (0)