I am happy to discover that tabs in a text box work, which helps me line things up, but if I insert a tab after roughly the 100th character in a line, then the tab results in the “appearance” of a carriage return prior to the tab, even if the text box is more than big enough for more than 100 characters. To illustrate, enter “q&Tab” 13 times in a Set Variable to Text box. This is strange, since text boxes properly handle formatting large paragraphs of text. It’s only when you insert a tab after about 100 characters that things get messed up. Assuming that “q&Tab” takes 8 characters each, the limit of characters per line is under 8*13=101. Which is likely not a coincidence, the limit is 100.
Going to sleep very soon, but trying to do my best:
What is “Tabs in a text box”?
Are you speaking of a KM text field, or of a text field in a text editor (like BBEdit, TextMate), or of a text box in a word processor (like MS-Word, Pages, …) ??
Create an action, such as “Set Variable to Text” which is the one I named. Then click in the text box in that action where you enter the text you want to assign to some variable. Then press the Q key, followed by pressing Tab, then repeat those two keys 13 times each. You will discover the bug. Sorry if it wasn’t clear. For me, after 13 times, the action appears to include a Carriage Return, long before the right hand side of the action’s window. Try it.
Yep, this might be a generic OS issue with the default tab stops of NSTextView. For example see also here.
I don’t know if @peternlewis can fix this. Here is another related discussion:
Thanks. Maybe Peter can confirm the cause and/or solution. Usually I email him directly when I find a bug but this time I decided to try the forums. Using tabs is helpful in aligning initialization data for my macros, but being limited to only a few columns makes it messier than using spaces.
BTW, the 12-tabs limit really seems to be only a display limitation. Try to paste or type your variable into an app that does not have the 12-tabs limit by default (e.g. BBEdit, Pages, Word) und it will be displayed correctly:
Here an example with 24 tabs:
Result in BBEdit:
Or here, directly in the post editor:
q q q q q q q q q q q q q q q q q q q q q q q q
If you prefer a correct display already in the variable definition field, you could always enable Show Ruler (in Keyboard Maestro > Edit > Format > Text) and manually add tab stops:
However the result —in terms of variable content— should be the same.
I've never seen the Show Ruler option before in Keyboard Maestro. Thanks! That would help me a lot. My first ten minutes with this feature has exposed a problem. It doesn't work at all if you have less than 4 lines of text, because you can't see the text box if it has fewer than 4 lines of text. In your case you have only one visible line but somehow you stretched the box vertically, probably by inserting about 6 lines of text then deleting them. To illustrate, here's what I see with three lines of text:
then here's what I see when I show the ruler: (it's even worse when there's fewer than 3 lines of text)
which means you can't see the text, and you can't even reselect the box by clicking on it, once you've clicked anywhere else. However I found a workaround. If you click in the Set Variable field, then press Tab, you can reactivate the text box, even though you can't see the text, and turn off the ruler. So in the end I'm happy, but it's a shame that you can't work with the Ruler and a few lines of text at the same time. So even this fix contains a bug.
But considering my original question, your post is brilliant.
(P.S. I was aware that the Carriage Return was not really there, which is why my first sentence said "it results in the "appearance" of a carriage return")
(P.S. It goes without saying that Keyboard Maestro is a spectacular product, and I still haven't uncovered all its riches despite using it for hours per day.)
I agree that it is a GUI bug that we can’t use the ruler in a 1-line text field. But —IIRC— the ruler is a new KM8 feature, and when KM8 came out there have been some more UI glitches like this which all have been fixed by @peternlewis in the meantime (e.g. this one). So I’m confident that he’ll also fix this one.
(If he doesn’t respond to the mention of his name tag here, it may be worth to report it by mail.)
This is clever!
More precisely, I have to hit Tab three times. The first Tab press produces a UI glitch of its own:
(This happens also when there is no ruler in the text field. Probably it is the selection of the variable pop-up.)
The second Tab selects the Insert Token menu, the third one finally goes to the text field.
I stand corrected: This is because I have “All controls” selected in the Keyboard prefs:
Yes, it is the generic tab stops the system uses for text fields. I don’t have any plans to address this. If you want more space or more tab stops or to have rulers or such things, for the foreseeable future you will need to use an external editor.
That’s fine. But there is another problem with the Ruler. It randomly disappears. Once a day I notice that it disappears from my actions. I haven’t figured out how to force this to happen. If I do, I’ll let you know.