Page 1 of 1

Insert Line Break

Posted: 2011-04-21 20:46:00
by wordsmith
The instruction 'Type Newline' and the escaped character '\n' will insert a new paragraph. I want to insert a line break (Shift+Enter), so how should I specify this please?

Re: Insert Line Break

Posted: 2011-04-22 02:45:23
by phspaelti
Type Text "\u2028"

Re: Insert Line Break

Posted: 2011-04-22 06:33:03
by wordsmith
Many thanks, phspaelti. Just what I needed. Does anyone know where I can find a list of these unicode numbers?

Immediately before inserting the line break I want to make sure that the text is not bold or italic. Is there a specific command for this, or to I have to test to see if it is bold or italic (or both) and then turn it (or them) off if the test returns 'true'?

Re: Insert Line Break

Posted: 2011-04-22 07:36:29
by Groucho
wordsmith was asking:
Does anyone know where I can find a list of these unicode numbers?
Hello, wordsmith. I hope these suggestion will be of help.

1. You can select any character in NWP and then select Edit>Convert>To Unicode Code Points.
or,
2. See this page.
or,
3. Use UnicodeChecker.
or,
4. Open the Special Characters pane (Edit>Special Characters…) from within any Cocoa application or the finder.

Greetings, Henry.

Re: Insert Line Break

Posted: 2011-04-22 07:54:18
by wordsmith
Thanks for that too, Groucho. I'm slowly finding my feet, having written Word macros for years but not being very familiar with Perl.

Re: Insert Line Break

Posted: 2011-04-22 15:47:03
by martin
wordsmith wrote:Does anyone know where I can find a list of these unicode numbers?
Groucho/Henry provided some nice resources, but I also want to mention that you can have a macro insert any text you can type, just by encasing it inside a string. For example, you could use the code:

Code: Select all

Type Type '

'
I don't think the forum will have the soft return come through, but hopefully get the idea- you can just type the soft return between the quote marks directly.
Immediately before inserting the line break I want to make sure that the text is not bold or italic. Is there a specific command for this, or to I have to test to see if it is bold or italic (or both) and then turn it (or them) off if the test returns 'true'?
It's not terribly convenient, but yes, you'll have to test whether bold/italics are on and then turn them off. Unless you happen to know what font you'd like to use.

For example, if you know ahead of time that you want your macro to always insert a newline in plain Times New Roman, you could use the code:

Code: Select all

Insert Text "\n"
Set Font Name "Times New Roman", true
That 2nd parameter (true), tells NWP to force the font face, in this case plain (not bold).

Alternatively, you could also apply the formatting to your macro string directly, like so:

Code: Select all

Insert Attributed Text "\n"
That's not going to register via the forum so well, but basically you may format your string inside the macro, and then just insert it attributes/formatting and all.

Re: Insert Line Break

Posted: 2011-04-22 17:33:18
by Kino
wordsmith wrote:Immediately before inserting the line break I want to make sure that the text is not bold or italic
Not very clear to me but, if you want to prevent manually applied bold or italic attribute of the preceding text from affecting the text following the soft return, the macro below will do the job.

Code: Select all

Menu ':Format:Remove Attributes Except Styles'
Type Text "\x{2028}"

Re: Insert Line Break

Posted: 2011-04-22 19:37:14
by wordsmith
These further comments from martin and kino deal with everything I need for my first useful macro.

kino’s Menu ':Format:Remove Attributes Except Styles' does the job for me, as it makes the macro usable with any document.

From martin’s post, knowing that I can insert what I need by typing it between the quote marks following TypeText is good (elsewhere in the macro I insert an en rule and that’s how I specify that character) but in this case as the soft return is invisible it would not be obvious from the macro code what is going on and it would be better if I added a comment to the code.

Thanks to everyone - will be be back soon no doubt!