Cabbage Logo
Back to Cabbage Site

Did someone say camelCase?

This one might not be too popular, but I’ve decided to make all Cabbage widget identifiers camelCase. Longer identifier names are not very readable in lowercase.

mouseoverkeycolour("red"), keypressbaseoctave(0)

is much easier to read as:

mouseOverKeyColour("red") keypressBaseOctave(0)

This won’t break any existing plugins because they are all tied to the version of Cabbage they were exported with. But if you try to update an older instrument you may have issues. But fear not, Cabbage has you covered and will inform you if any of your identifiers are the wrong case. Cabbage will even convert your code for you if you like.

I’m inclined to leave widget names lowercase. Most are single words anyway, and I think that gives them a unique appearance in comparison to identifiers.

I haven’t pushed this change through yet. But I have my finger on the trigger :laughing:

I agree, it is a lot easier to read the camelcase ones.

I’ve updated all of Iain’s examples and whatever files were in the Misc folder, so I’m about ready to push this through. I’m attached the python script I wrote to do the batch processing, in case case anyone else would like to batch convert a load of csd files in a single move. I’m happy to do this for people if they like. Just send me a zip with all your .csd files :wink:

convertToCamelCase.py (16.4 KB)

Looks like I’m late to this party too… while I do prefer the readability of camelCase… not being a user of the internal editor, and having my code scattered across a billion files will surely make my life interesting!

Hopefully the python script does the trick. Thanks!

Just don’t forget to back up your files first! It will run recursively on all folders contained with the one passed to it. It replaces the text in-file, it doesn’t write them to a new file, so watch out!

1 Like

Wow that was just about the smoothest conversion I have ever seen. Just ran it from the file menu and it instantly fixed all identifiers. Very nice :metal:

Actually one thing I noticed. The presets are not filling the preset combobox anymore.

;Preset manager
combobox bounds(22, 14, 128, 20), populate("*.snaps"), channelType("string"), colour(27, 32, 38, 255) fontColour(178, 178, 178, 255) value("")
filebutton bounds(156, 14, 20, 20), text("", ""), channel("SaveButton"), populate("*.snaps", "test"), mode("named snapshot"), value(0), colour:0(27, 32, 38, 0) fontColour:0(178, 178, 178, 255)
filebutton bounds(180, 14, 20, 20), text("", ""), channel("RemoveButton"), populate("*.snaps", "test"), mode("remove preset") value(0) colour:0(0, 0, 0, 0) fontColour:0(178, 178, 178, 255)

Edit: Also changed all text-widget colours, but that’s no biggie.

Thank for checking this stuff out. I need all the reports I can get to make sure it’s working Ok.

Actually, I now notice what happens with the text. All text widgets gets their colour changed to grey, and I can’t seem to change them to any other colour

You mean all widgets that have text? Buttons, sliders, comboboxes, etc?

Buttons, optionbuttons and labels are what I’m using in my project. They were several colours, but all have changed to grey, except the buttons, they are white (but originally another colour)

Thank you, I have forgotten to update a part of the code base :roll_eyes:

Should be a new build ready in Azure in half an hour of so.

2 Likes

Thanks for the quick fix Rory.

The handy ‘convert to camelCase’ feature misses out these two:
tablebackgroundColour
valueTextBox
In the menu you’ve called it ‘covert identifiers to camelCase’. Makes it sound illegal.

True. It sounds like a coded call to arms :rofl:

All covert identifiers to camelCase, I repeat, all covert identifiers to camelCase!

p.s. I think I actually caught those and already pushed to git. At least it looks that way from my local source…

I guess that should be tableBackgroundColour?

tableBackgroundColour right. I think the detector was only catching the ‘C’.

I take it this is all backwards compatible. The parser seemed pretty tolerant in the past.

If you try to run uppercased code in older versions of Cabbage you might have some issues. Apropos, do you think it might be worth adding a second call to arms for covert lowercase identifiers? That might be useful for people who may need to switch between versions? I know it’s a bit of a pain, but I think it’s worth it. Back in the day the long identifier were only a single token, or max 2. But with many longer identifiers added over the years, its got to a stage where the code is pretty awful to read.

[edit] I added a ‘coNvert to lower case’ menu command now. That should reduce the hardship of moving between versions.

Maybe in 6 months camelCase can be broadly accepted. It would be great if it could batch convert a folder of csds, maybe not possible though.

I can look at adding a batch process menu command, but in the meantime, the Python script I posted earlier in this thread will do that for you. As always with these things, make a backup first. :grimacing:

1 Like