Insert Line Break

Get help using and writing Nisus Writer Pro macros.
Post Reply
wordsmith
Posts: 4
Joined: 2011-04-21 20:35:50

Insert Line Break

Post 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?
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Insert Line Break

Post by phspaelti »

Type Text "\u2028"
philip
wordsmith
Posts: 4
Joined: 2011-04-21 20:35:50

Re: Insert Line Break

Post 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'?
Groucho
Posts: 497
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Insert Line Break

Post 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.
wordsmith
Posts: 4
Joined: 2011-04-21 20:35:50

Re: Insert Line Break

Post 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.
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Insert Line Break

Post 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.
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Insert Line Break

Post 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}"
wordsmith
Posts: 4
Joined: 2011-04-21 20:35:50

Re: Insert Line Break

Post 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!
Post Reply