Yes , it would need to be deselected when not needed, as it would look like a Xmas tree, which is what I think would show which goes with which.
Or another way of showing the pairs, is to be able to select a way to have each pair a greater indent from the left margin ( and the text within them )
I sometimes do this anyway, so that I can see each section, you would have to be able to return to normal .....
void loop ()
{
if ( cost > x )
{ serialPrint ( cost ); if ( cost > 2x )
{ digitalWrite ( ledPin, HIGH );
}
}
}
I know some people like (not sure why, maybe they get used to this using green-terminal displays with few rows of text)
function( ) {
}
But I like:
void loop ()
{
if ( cost > x )
{
serialPrint ( cost );
if ( cost > 2x )
digitalWrite ( ledPin, HIGH );
}
}
Just because it is pretty nice to visually match curly braces as you want, your example for me seem extremelly confusing at first glance. The only problem is if the function is very long, you lose the "tab" position reference. At least in Visual Studio (I guess those guys do lots of usability test) the matching brace gets highlighted and when you type "}" the indentation is fixed.
Most (all?) IDEs have some form of match ({[ function. Normally just place the cursor on one and it highlights the matching one. Sometimes you ^B (for example) to move the cursor to its match.
However it's done it's a very useful feature.
EDIT: We all have a preferred method when it comes to {}, it's not the job of an IDE to enforce that, or even help probably. If you use TABs properly the indentation is easy to follow. An editor that handles block in/outdenting makes life a lot easier in this regard.
Then no, braces are not required. They are however highly recommended as leaving them out can lead to subtle bugs later. For example you add a line of code.
if ( cost > 2x )
x++;
digitalWrite ( ledPin, HIGH );
Now of course, despite the indenting, digitalWrite() gets called regardless of the "if" result. This can be difficult to spot because your brain "reads the indenting" and skips over the fact that the two lines are not in a code block.
I usually don't use them in that case, it is visually pleasant for me. I am pretty strict with my code style. If there is a multiline else below I add the braces to make the code look balanced.
Of course what graynomad says is true, C can drive to convoluted stuff like the define thing, but I am 'porting' my C# style when I use arduino IDE and not viceversa.
A good IDE allows you to tune the formatter to how you like it.
In most of the error examples in the above discussion the formatter will give visual clues that something is wrong.
I use eclipse and formatter works fine for me. The only annoying thing is that you have to select your formatting settings with each and every workspace.
Best regards
Jantje
I've always used this, and like it visually because the closing braces line up with the opening "if". Saves lines, too.
I also like
if (bool exp) code;
because it saves lines (you see more on the screen at once... too much white space can be as bad as too little.)
And finally, for similar reasons, I will also use
if (b exp) code;
else code;
or even sometimes
if (b exp) code; else code;
Sometimes I'll vary it with
if (b exp)
longer-line-of-code;
else code;
if it looks more balanced (and of course, just to annoy people like Jante
And to generalise, I delight in using
for (;;) code;
and
while (bool exp)
code;
when it suits.
As an odd inconsistency (but also found in K&R) is the use of braces when declaring functions:
int myFunction(int avar)
{
/* implementation in here */
}
Although it strikes me as stylistically a bit inconsistent, I've also decided I kind of like bringing the opening brace onto the next line for function declarations, rather than at the end of the line, as in a control block.
In short: Good enough for Dennis, good enough for me.
pico:
if it looks more balanced (and of course, just to annoy people like Jante
Pico
Not sure what makes you think I would be annoyed by this. When I get code from a third party I dump it into my editor who reformats it for me.
Anyway it makes me happy you want to do something extra just for me
Jantje:
Not sure what makes you think I would be annoyed by this.
Just teasing, my friend.
(I have had some Pascalians scandalised by some of my coding habits over the years. You are obviously familiar with Pascal -- I thought perhaps you might be just a little bit miffed at my complete lack of respect for unnecessary braces!)
(I have had some Pascalians scandalised by some of my coding habits over the years. You are obviously familiar with Pascal -- I thought perhaps you might be just a little bit miffed at my complete lack of respect for unnecessary braces!)
Yes I have done pascal; fortran; (visual) basic (for application); c ; c++; perl script ; bash ; shell; java; and others.
I have seen to much code (and have become to old) to get hung up on the formatting style. My advice: take the formatting style you like and let the formatter do the translation.
There is 1 exception to this rule though. That is when you start being a team member and having version control. But I won't go into that though.
Nor will I let myself be dragged in a naming convention war (which is way out f topic).
Jantje:
Yes I have done pascal; fortran; (visual) basic (for application); c ; c++; perl script ; bash ; shell; java; and others.
I have seen to much code (and have become to old) to get hung up on the formatting style. My advice: take the formatting style you like and let the formatter do the translation.
There is 1 exception to this rule though. That is when you start being a team member and having version control. But I won't go into that though.
Nor will I let myself be dragged in a naming convention war (which is way out f topic).
I think formatting prefs is getting too in depth for this new IDE. I'm really targeting the new to intermediate developer. If you are a hard core user who wants to fully customize your development experience you should probably switch to a standard IDE like Eclipse.
Attached is the latest screenshot. You can now open, edit, and save a sketch as well as compile and download it to a Diecimila (it's hard coded to the particular board I happen to have on my desk). I've put the first code drop into a new repo on git hub here. Note that it's probably still not compilable by anyone but me, but you can poke around if you feel like it.
In addition to the download feature it now has a standard font bundled in it (Ubuntu Monospace). The sidebar you see on the right is where the help text will go. This is html loaded locally, but it is using Swing's text support which is a small subset of CSS 2. Still, it should be enough for nicely formatted help text.
Again the look and feel can be ignored for now. I want to focus on layout and features first, then worry about having a good color scheme, fonts, icons, etc.
So far the feature list is:
create/open/save/download a sketch with minimum configuration
intelligently save prefs for font size, window position, loaded tabs, USB port, etc.
improve the layout, text editor, and tab system
improve keybindings and other platform specific UX
What else should we have?
I really hate the current way you choose serial ports. Is there any way to know what device is connected to a serial port? Can't we detect if the arduino is an Uno vs Leo vs Decimila instead of having to ask the user? I also hate having to use the /dev/usb blah blah names. On mac each port is listed twice and the bluetooth devices are listed, which is nonsense.
Is there a better way to interact with examples? What about common code snippets for novice users to use?
code visualization? List the pins you are using? Show a photo of your arduino board indicating the pins you are using.
Re the help. Can you have a hot key (F2?) to bring up the help for a function? Either based on where the mouse/cursor is or maybe you have to highlight the function.
Word boundaries. Currently the IDE uses inappropriate characters as word boundaries, for example
int in_Byte = Serial1.read();
If I double click on in_Byte because I want to copy it I only get "in" or "Byte", depending on where I click. In a programming language this should be considered a single word.
So either allow the setup of word boundary chars or just exclude some common ones like _.
This also applies to ^arrowing, if I ^ left arrow I want the cursor to skip the entire in_Byte, currently it's 3 key strokes to get over the var name.
Graynomad:
Re the help. Can you have a hot key (F2?) to bring up the help for a function? Either based on where the mouse/cursor is or maybe you have to highlight the function.
Word boundaries. Currently the IDE uses inappropriate characters as word boundaries, for example
int in_Byte = Serial1.read();
If I double click on in_Byte because I want to copy it I only get "in" or "Byte", depending on where I click. In a programming language this should be considered a single word.
So either allow the setup of word boundary chars or just exclude some common ones like _.
This also applies to ^arrowing, if I ^ left arrow I want the cursor to skip the entire in_Byte, currently it's 3 key strokes to get over the var name.
Rob
Current ide select whole var when I double click vars with "aaa_aaa" and CTRL+Shift+F opens the reference
I really hate the current way you choose serial ports. Is there any way to know what device is connected to a serial port? Can't we detect if the arduino is an Uno vs Leo vs Decimila instead of having to ask the user? I also hate having to use the /dev/usb blah blah names.
This depends on whether java can access usb and/or registry-related system calls. You can theoretically get the usb device information associated with a serial port, and figure out whether they are likely to be Arduinos, and if so which type of arduino. (although, I wouldn't rely on this entirely, since it's common practice to use somewhat random usb/serial converter chips/cables/etc as a cost-saving scheme.)
There's an example (for windows, where things are worse) at GitHub - WestfW/ArduScan: ArduScan is a windows program that passively scans the COM ports on a system looking for ones that are likely to be Arduinos
The double-listing on Mac's is Apple's fault; can you really guarantee that /dev/tty.usbserial-xxx and /dev/cu.usbserial-xxxx are the same piece of hardware?
Could you answer my earlier question about Swing vs local editing styles? I'm genuinely curious...
You're missing the existing keyword-based highlighting of Arduino Functions (digitalWrite(), etc)), and I disapprove of the reduction of information in the compiler interaction part of the display. "we" have been trying to get more information there (RAM usage in addition to flash usage, in particular.)
Listing pin usage would be interesting. Sort of baby-steps to actual simulation at some point...