Procedure file tip: tab compatibility with monospaced font
s.r.chinn
for - endfor
loops. This results from having the tab width in physical increments (e.g. inches) rather than character widths. One solution that seems to work is first to find the monospaced fixed character width-to-height ratio (0.55 for Consolas), and multiply by the character height (font size). Divide this result by 72 to get the character width in inches, decide on a tab width of 'n' characters, and set the resulting value in the Procedure window Document Settings. For example using Consolas-10, and 4-character tab, the tab width is 0.305 inches. These Procedures settings should be saved (Capture Procedure Preferences...) if you want to apply them to future Procedure windows. Results have been tested only with Igor Pro 6.37 on Windows 7. (Previous error corrected : Multiply by 72 -> Divide by 72)
Btw. I use Anonymous Pro [1] for coding.
[1]: http://www.marksimonson.com/fonts/view/anonymous-pro
May 25, 2016 at 11:46 am - Permalink
May 25, 2016 at 07:35 pm - Permalink
May 26, 2016 at 07:32 am - Permalink
July 2, 2016 at 05:05 am - Permalink
I finally have found a solution for the problem of comment alignment inside procedure windows that works nicely for me. Inspired by the Prettify code snipped from Tony, I wrote a procedure which aligns the comments of all selected lines by inserting tab characters with the press of a button (two actually).
You can find the code here: https://www.wavemetrics.com/code-snippet/align-comments
The only limitations (I am aware of) currently are: The settings for the used font and the tab width for procedure windows is currently hard-coded as constants. so you have to dial them in for your environment. I did not find a way to get this information programmatically. A panel would be thinkable, but this would still be a hassle. Also, one needs to select whole lines for this to work. Otherwise the comment of the first line is misplaced. Is there a way of modify the selection of procedure windows programatically?
It would be great if somebody had an idea how to improve upon these things. I also would be interested to hear if this works for Mac people as well.
June 23, 2020 at 07:26 am - Permalink
@chozo: Would one off GetDefaultFont, GetDefaultFontSize, GetDefaultFontStyle, FontSizeHeight, FontSizeStringWidth help?
June 25, 2020 at 07:03 am - Permalink
Thomas, thank you for your tips. Unfortunately, it turned out that there is no way to grab this information for procedure windows. Please see also the discussion below the code snippet. GetDefaultFont() etc. works only for graphs or the whole experiment. And FontSizeStringWidth() gives out a tab width of one character length, and not the real tab width setting. So for the time being there is no way around dialing in these values manually (either in the file or via a GUI).
By the way, the problem with the selection of the first line could be solved.
June 25, 2020 at 09:10 pm - Permalink