Igor Pro Language Module for use in BBEdit
rgilman
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.
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
July 6, 2008 at 08:39 pm - Permalink
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.
July 7, 2008 at 12:38 pm - Permalink
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.
July 7, 2008 at 03:23 pm - Permalink
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
December 17, 2009 at 04:59 am - Permalink
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!
February 15, 2012 at 11:42 pm - Permalink
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.
February 16, 2012 at 12:01 pm - Permalink
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.
April 17, 2012 at 05:43 am - Permalink
The Igor syntax coloring colors are configurable (though on a per-session basis). Execute the following command for more information:
April 17, 2012 at 06:35 am - Permalink
April 17, 2012 at 08:14 am - Permalink
Probably not. But try this attachment instead. I created it years ago and haven't touched it since, but it works for me.
April 17, 2012 at 09:11 am - Permalink
April 17, 2012 at 09:27 am - Permalink
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
April 18, 2012 at 07:40 am - Permalink
July 6, 2014 at 09:20 pm - Permalink
In reply to by 741
@741 I would like to use your tm lang for integration to https://github.com/github/linguist so that we can finally get syntax highlighting on github.
Would you mind if I take that file to github and could you pick one of the supported open source licenses like MIT or BSD3 for example.
June 13, 2019 at 02:09 pm - Permalink
I have pushed the file with my changes to github. There is not much left, though.
I also converted the file to yaml. The format is a one-to-one representation of the xml syntax but better readable.
Maybe some folks on the apple end that use textmate can check the syntax highlighting before I try a PR on linguist.
June 24, 2019 at 12:02 pm - Permalink
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/
January 20, 2021 at 04:59 pm - Permalink