Igor Pro Language Module for use in BBEdit

Attached is a Language Module plist for use in BBEdit.

Here's the background: BBEdit (http://www.barebones.com/products/bbedit/) is one of the premiere programming-oriented text editors for the Mac with lots of great features -- including the ability to identify the functions in a code file, collapse and expand those function blocks, and color-code the keywords (e.g. built-in operation and function names). The catch is that BBEdit needs a Language Module file to do this for any particular language. I was not able to find any for Igor's programming language, so I made one and thought that others who use both Igor and BBEdit might appreciate it.

To install, quit BBEdit if it is running put the file in Library/Application Support/BBEdit/Language Modules/ and then relaunch BBEdit. You may have to create the 'Language Modules' folder. Once installed you should find 'Igor Pro' included as one of the languages recognized by BBEdit. You should also go to the "Languages" preferences to provide the .ipf suffix mapping, to set '//' for the start of comments, and to set the colors you want to use in the color coding.

Let me know if you find this useful or if you have any suggestions for improvements.

IgorProCodelessLanguageModule.plist_.zip (5.84 KB)
rgilman wrote:
Attached is a Language Module plist for use in BBEdit.


Thanks! My test shows, this also works with TextWrangler.

It seems however not to detect a Static Function. Also, how can #pragma and # include lines be colored?

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
jjweimer wrote:


Thanks! My test shows, this also works with TextWrangler.

It seems however not to detect a Static Function. Also, how can #pragma and # include lines be colored?



Glad to hear it works with TextWrangler also.

I have attached an updated version (1.01) that detects Static Functions. It will now also color pragma and include as keywords (although it won't color the # in front of them).

I encourage you to open the file and take a look if you haven't already.

The coloring is just based on a long list of keywords taken from the pdf version of the manual. Perhaps someone on this list might know how to get the #'s properly coded so that they can be colored also.

The detection of the Functions is handle by a regular expression that could be tweaked further if needed.

Hope that helps.
rgilman wrote:

The coloring is just based on a long list of keywords taken from the pdf version of the manual. Perhaps someone on this list might know how to get the #'s properly coded so that they can be colored also.

You might find that writing a quick Igor script that includes calls to FunctionList() and OperationList() might make it easier to build a new file when Igor changes, since then you wouldn't have to manually look through the manual. I've used a similar method to build the syntax information file that is used for the code highlighting on the IgorExchange site.
Just an epsilon incremental improvement. I corrected a typo static was written staic....
and added a line which makes the strings to be colored. To be honest just copied from an example from BBedit (C++ codeless..) it appears to work. Attached is the modified version. Enjoy!
Bela

b_farago wrote:
Just an epsilon incremental improvement. I corrected a typo static was written staic....
and added a line which makes the strings to be colored. To be honest just copied from an example from BBedit (C++ codeless..) it appears to work. Attached is the modified version. Enjoy!
Bela



I was using this .plist with TextWrangler, but the shortcut menu at the top wasn't recognizing my functions, macros, or windows in the Igor procedure file. After much trial-and-error today, I've made some edits to the "Function Pattern" in the .plist, and I've attached it to this post.

What still isn't working, but would be really nice to have working, would be for TextWrangler to recognize to the end of the functions. If we can get this to work, then we can easily "code fold" the entire function. The attached .plist will fold any comments and empty lines between the function name and the first command in the function, but nothing more. If anyone else has code folding working in TextWrangler on .ipf files, please share!
b_farago wrote:
Just an epsilon incremental improvement. I corrected a typo static was written staic....
and added a line which makes the strings to be colored. To be honest just copied from an example from BBedit (C++ codeless..) it appears to work. Attached is the modified version. Enjoy!
Bela



I played around some more with the .plist. It turns out that b_farago's file should have worked, but because I add comments to the line after the 'End' command for functions, it wasn't recognizing these functions properly.

I am attaching the updated .plist, which now recognizes Macro and Window in addition to Function and recognizes that these extend until the End or EndMacro command (with or without comments on the same line). This allows code folding for the entire function/macro.


In addition, I've learned that in order to get other code folding features (for if statements, for instance) for .ipf files in TextWrangler (and presumably BBEdit as well), we need to make a "Compiled Language Module" rather than the "Codeless Language Module" that this .plist is. I might explore this route in my free time, but if anyone has done this and would like to share, even for a different programming language that I could use as an example, that would be most appreciated.
This is great stuff - just installed it (for anyone else attempting this, I created a new folder /Library/Application Support/TextWrangler/Language Modules/ and put the .plist file in there). Then restart TextWrangler and away you go!

I like the colour of the comments in this scheme being light grey by default - having comments in bright red like they are in Igor draws my eye away from the actual code.
notwhatucallanatural wrote:

I like the colour of the comments in this scheme being light grey by default - having comments in bright red like they are in Igor draws my eye away from the actual code.

The Igor syntax coloring colors are configurable (though on a per-session basis). Execute the following command for more information:
DisplayHelpTopic "Syntax Coloring"
mtaylor wrote:
does anyone know if this works in textmate?


Probably not. But try this attachment instead. I created it years ago and haven't touched it since, but it works for me.

Igor Pro.zip (7.34 KB)
aclight wrote:

The Igor syntax coloring colors are configurable (though on a per-session basis). Execute the following command for more information:
DisplayHelpTopic "Syntax Coloring"

Thanks for this tip. It doesn't update the colours in existing procedures for me though. It just changes the colour of the new lines I type.
Edit: It seems to work if I hide then re-show the procedure windows
I just tried this on TextWrangler v4.5.9 and it worked great. Thanks for this!

The Macintosh-only BBEdit text editor supports syntax coloring and function identification through language module property lists (.plist files).

I have attached a revised IgorPro9CodelessLanguageModule.plist as RevisedIgorPro9CodelessLanguageModule.plist.

This version improves the function parsing regular expression (kudus to Regex Buddy) and adds Igor Pro 9 functions and operations to the keyword lists.

Uncompress the .zip file to get the .plist file.

I have also attached the experiment I used to generate the file if you wish to have only Igor 8 functions and operations highlighted; just run the experiment in Igor 8 and save a new .plist file.

 

Put the file in ~/Library/Application Support/BBEdit/Language Modules/