Igor Pro Language Module for use in BBEdit

rgilman
Posts: 2
Joined: 2008-07-06
Location: United States

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.

AttachmentSize
IgorProCodelessLanguageModule.plist_.zip5.84 KB

jjweimer
jjweimer's picture
Posts: 1008
Joined: 2007-08-14
Location: United States

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


rgilman
Posts: 2
Joined: 2008-07-06
Location: United States

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.

AttachmentSize
IgorProCodelessLanguageModule.plist_.zip5.83 KB

Posts: 608
Joined: 2007-03-01
Location: United States

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.


b_farago
Posts: 1
Joined: 2008-01-04
Location: France

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

AttachmentSize
IgorProCodelessLanguageModule.plist_.zip5.88 KB

Goure
Posts: 13
Joined: 2011-03-09
Location: United States

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!

AttachmentSize
IgorProCodelessLanguageModule.plist_.zip6.01 KB

Goure
Posts: 13
Joined: 2011-03-09
Location: United States

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.

AttachmentSize
IgorProCodelessLanguageModule.plist_.zip5.99 KB

notwhatucallanatural
Posts: 49
Joined: 2010-03-18
Location: United Kingdom

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.


Posts: 608
Joined: 2007-03-01
Location: United States

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
mtaylor's picture
Posts: 92
Joined: 2010-04-13
Location: United States

does anyone know if this works in textmate?


741
Posts: 205
Joined: 2009-03-22
Location: Belgium

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.

AttachmentSize
Igor Pro.zip7.34 KB

[ last edited April 17, 2012 - 08:11 ]
mtaylor
mtaylor's picture
Posts: 92
Joined: 2010-04-13
Location: United States

It works great! Thanks!


notwhatucallanatural
Posts: 49
Joined: 2010-03-18
Location: United Kingdom

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


[ last edited April 18, 2012 - 06:40 ]
Bones
Posts: 8
Joined: 2009-05-26
Location: Australia

I just tried this on TextWrangler v4.5.9 and it worked great. Thanks for this!


Back to top