-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Added an optional user modifiable default sketch file when creating a new project. #1559
Conversation
This needs to be documented somewhere for user discoverability. As a further change, we could add a settings parameter that points to a path of the template sketch in a folder marked for templates. This would make managing of templates easier. |
Excellent point @nmzaheer. I would suggest the "Advanced Usage" document as the appropriate place for such information: https://github.com/arduino/arduino-ide/blob/main/docs/advanced-usage.md However, that would not be necessary if your other suggestion was implemented:
In this case, I think the existence of the setting and the accompanying description would be sufficient to make the feature discoverable to the user. |
So are you suggesting that this change should not be merged and rather we work a bit more to add it to the Settings ? |
Could it be an iterative update. Such as in the first iteration, it is not in the UI but only in the documentation and in a second iteration, the UI is available in an advanced settings? I'm really not a UI/web guy. I'm mainly from the C/C# world and I don't feel comfortable making change to the UI. |
No question we need them together.
You do not have to. Checking your changeset, I am positive you can do it. Here are a few pointers:
diff --git a/arduino-ide-extension/src/browser/arduino-preferences.ts b/arduino-ide-extension/src/browser/arduino-preferences.ts
index 5fef5907..9e9b3f9d 100644
--- a/arduino-ide-extension/src/browser/arduino-preferences.ts
+++ b/arduino-ide-extension/src/browser/arduino-preferences.ts
@@ -241,6 +241,14 @@ export const ArduinoConfigSchema: PreferenceSchema = {
),
default: false,
},
+ 'arduino.sketch.inoBlueprint': {
+ type: 'string',
+ description: nls.localize(
+ 'arduino/preferences/sketch/inoBlueprint',
+ 'Absolute filesystem path to the default `.ino` blueprint file. If specified, the content of the blueprint file will be used for every new sketch created by the IDE. The sketches will be generated with the default Arduino content if not specified. Unaccessible blueprint files are ignored. A restart of the IDE is needed for this setting to take effect.'
+ ),
+ default: undefined,
+ },
'arduino.checkForUpdates': {
type: 'boolean',
description: nls.localize(
@@ -278,6 +286,7 @@ export interface ArduinoConfiguration {
'arduino.auth.registerUri': string;
'arduino.survey.notification': boolean;
'arduino.cli.daemon.debug': boolean;
+ 'arduino.sketch.inoBlueprint': string;
'arduino.checkForUpdates': boolean;
}
arduino-ide/arduino-ide-extension/src/node/arduino-daemon-impl.ts Lines 174 to 194 in 99b1094
Keep up the great work, and let me know if you have any questions. |
We should probably consider the default content for the remote sketches: arduino-ide/arduino-ide-extension/src/browser/create/create-api.ts Lines 521 to 533 in 93291b6
|
@nbourre, do you plan to make the requested changes? We want to release a new patch version of IDE2 soon and include this feature. |
@kittaakos I would like to take a look at this. How do I contribute without creating a new PR? Should I open a PR in @nbourre repo and if that is merged then it would be reflected in this PR ? On a side note, I think we need to start tagging issues to milestones i.e. 2.01, 2.02, etc. for contributors to know what i being prioritized by the development team. |
@kittaakos What is the ETA for the next release? I'm quite tight in my time today. I might be able to do it this weekend. @nmzaheer I will try to work on it this weekend, but if you have time and are fluent with this framework, feel free to do a PR on my repo. |
Thank you for the quick reply. I plan to merge everything by latest next Tuesday (25.10). If your schedule is tight, I am happy to add support for the You're very close to the final solution, and I think you can do it. 💪 But no pressure, of course. |
Hi guys, Link to my last commit : 6444edc I'm having trouble to make the modification work. By @kittaakos, here are the task and what I've done so far :
But I don't see the settings in the preferences. What am I missing? The commands I've done : yarn
yarn rebuild:browser
yarn rebuild:electron
yarn start Do you guys have a cue to improve the build speed? Building the apps takes an eternity compared to C-style apps. Thanks |
Ok, I got it. The default folder is going to be in the advanced |
@kittaakos I think I have accomplished all the requirements for the next release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I got it. The default folder is going to be in the advanced
Preferences
not the one accessible by the menu.
There is no default folder. Users either give an absolute path to the default .ino
content file or the default will be used from the code. But IDE2 won't try to pick up any files from #directories.user/default/default.ino
.
Please check your template, you have added undesired whitespaces. See here.
I simplified the code. Here is my proposal: nbourre/arduino-ide@main...kittaakos:arduino-ide:default-ino-review
Feel free to use it.
// put your setup code here, to run once: | ||
|
||
} | ||
|
||
void loop() { | ||
// put your main code here, to run repeatedly: | ||
|
||
}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are undesired whitespaces in the template.
@kittaakos, except for the description which I'm not sure what's wrong. I've applied the requested changes. |
The indentation of the code was incorrect, but you have fixed it. Thank you! All looks good except the default template. If the new void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
} Expected: void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Please reference my proposed template here. If you fix the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's working great. Thank you so much for your contribution, @nbourre 👍
I have also verified on Windows from the build. ✨ |
This seems to have been made more complicated that needed by adding a new setting. It is too late now, but what was the problem with the original proposal to use a sketch named default,ino if it existed rather than adding a new setting ? Come to that you could simply have used the same mechanism as the classic IDE and used the BareMinimum example as the new sketch template Anyone who felt the need for a different default sketch, as I did, would simply edit the BareMinimum example to suit themselves |
Hi @UKHeliBob
I don't see any problem with the feature being slightly complex to set up. This is something only a small portion of advanced users will do, and something they will do only once. The important thing is to provide the capability, and to provide that capability in a manner that can meet all user's needs, not in streamlining the feature as would be more of a consideration for some operation that is being done repeatedly or by beginners.
Because some users might create a sketch of this name without any intention of it being adopted by the IDE as the base sketch. Because some users might prefer to store the sketch in some other location or under a different name.
The reimplementation of each feature in Arduino IDE 2.x is a chance to reconsider the old one and improve on it where areas for improvement are identified. This was one with significant areas for improvement, and those who collaborated here on the feature took the time and effort to make it better! With the old system, your custom new sketch was lost at every IDE update. With some operating systems, packages, security configurations, it is impossible to edit files inside the Arduino IDE installation package. Some users may have different requirements for the new sketch than they do for the sketch accessed via File > Examples > 01.Basics > BareMinimum example sketch. |
That is exactly the point. If the BareMinimum sketch were used as the new sketch template then advanced users could simply modify it to meet their needs as they do now My Windows setup prevents me from modifying the example sketches and saving them again using the IDE, but being an "advanced user" that was easily circumvented I cannot comment on the comparative difficulty of implementing the change either way because I am not familiar with the programming environment I assume that the new mechanism will appear in a nightly build soon, if it has not done so already and I look forward to trying it out |
The whole point of IDE 2 is that it will have breaking changes compared to IDE 1. However, the goal is not to alienate the entire userbase by creating a user experience which is vastly different from IDE 1 since that is the targeted audience. As pointed out by @per1234 , the Bare minimum sketch gets overwritten with every update of Arduino IDE 2 which does not ensure a good UX since the user will have to keep changing contents with every update. And I am assuming till features and 🐛stabilize, the team would be looking at having release every month or so. So, I feel having a setting to a default sketch would be a good UX rather than editing the BareMinimum sketch. On a side note, maybe the team could also discuss having a menu item under File with New Sketch from Template as an option. However, we will have to set up some sort of data collection to understand how many use that option and if it deserves such high visibility under the File menu |
Motivation
Sometimes programmers use the same boilerplate code for their project. This PR allows the creation of a default sketch.
Change description
If a
default/default.ino
file is present in the Arduino Sketch folder, the app will read the content of thedefault.ino
file to create the new project. If the file is non-existent, the default hard-coded sketch is used.Other information
I created a
loadDefault()
method in thesketches-service-impl.ts
file.Reviewer checklist