arduino.tmbundle icon indicating copy to clipboard operation
arduino.tmbundle copied to clipboard

Bundle should include Arduino examples

Open nasser opened this issue 14 years ago • 4 comments

Maybe as templates or as a command that opens a new window filled with the right code

nasser avatar Dec 18 '10 06:12 nasser

Would you implement the examples as TextMate snippets? I can look into starting this if you want to give me an idea of the direction you had intended to take.

doomspork avatar Jul 26 '11 02:07 doomspork

My idea was to implement them as TextMate templates. There already is one in File > New From Template > Arduino > Basic Sketch. The menu structure I was imagining was something like

Basic Sketch
---
Basics ...
Digital ...
Analog ...

So, Basic Sketch, a separator, then a reproduction of the Arduino Examples menu. However, I do not know how much control we have over the template menu and if separators or submenus are even possible. This could be a problem as Arduino has many examples, and without submenus the template menu could get long.

The code behind a template that reproduces an Arduino example is the following

if [[ ! -f "$TM_NEW_FILE" ]]; then
   cat "/Applications/Arduino.app/Contents/Resources/Java/examples/1.Basics/Blink/Blink.pde" > "$TM_NEW_FILE"
fi

TextMate's template system is static in that each menu item must be read from a .tmTemplate directory. To avoid having to create and maintain a separate .tmTemplate directories for each example, there should be a script as part of the Arduino bundle that generates them automatically by scanning the Arduino examples folder.

That's the overall plan I had for the examples. What do you think? Is it reasonable? Want to take a crack at it?

nasser avatar Jul 26 '11 06:07 nasser

It was my understanding that TextMate and Bundles were moving away from using templates? I'll have to go back and find the blog post but I recall reading something about that not to long ago. If that's not the case I'll gladly look into how that could be accomplished.

doomspork avatar Jul 26 '11 14:07 doomspork

Interesting. If thats the case, then we shouldn't be embracing something that's being phased out. Let me know if you can find that post.

If it is the case that templates are on their way out, examples could be implemented as commands that display their output in a new window.

nasser avatar Jul 26 '11 15:07 nasser