classic Keep on Same Line feature

Get help using and writing Nisus Writer Pro macros.
Post Reply
Brooke6
Posts: 16
Joined: 2007-08-21 15:14:55

classic Keep on Same Line feature

Post by Brooke6 » 2007-08-21 15:30:16

In NWP, I badly miss the old Classic formatting style "Keep on Same Line."

For you macro wizards out there, is it possible to imagine a macro solution/workaround for this missing feature?

Thanks,
Brooke

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: classic Keep on Same Line feature

Post by Kino » 2008-09-21 07:06:36

This one-liner prevents wordwrap by inserting U+2060 (WORD JOINER).
I think it would not be a good thing to use this kind of Unicode characters for such a purpose, which, in my understanding, are intended to be used for formatting plain text. However, if such a functionality is indispensable, then nothing can prevent us. It's a personal computer, after all ;-)

Code: Select all

### Keep on the Same Line ###

# This macro prevents wordwrap by inserting U+2060 (WORD JOINER)
# after "-", "/" and " " (space) WITHIN selected text(s).

# If the actual font does not have U+2060 (n/a in many fonts),
# it will be supplied by another font automatically, possibly
# causing the modification of line spacing. To prevent it, set
# the line spacing to Fixed.

# To remove U+2060, use
#    Replace All '\x{2060}', '', 'E'
# or
#    Replace All '\x{2060}', '', 'Es' # In Selection

Replace All '(?<!\G)(?<=[-/\x20])(?=\p{Any})', '\x{2060}', 'Es'
     # (?<!\G): Not selection start
     # (?=\p{Any}): Not selection end

### end of macro ###

User avatar
Hamid
Posts: 734
Joined: 2007-01-17 03:25:42

Re: classic Keep on Same Line feature

Post by Hamid » 2008-09-21 07:34:39

Thank you! I made this feature request because very often, in Arabic, the last word of the paragraph flows on to the next page even when there is enough space to fit the word on the same line on the previous page. Adding a blank line after the paragraph caused the word to remain on the same line on the previous page.

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: classic Keep on Same Line feature

Post by Kino » 2008-09-21 08:00:44

Hamid wrote:I made this feature request because very often, in Arabic, the last word of the paragraph flows on to the next page even when there is enough space to fit the word on the same line on the previous page.
Perhaps the macro does not solve that problem, I'm afraid. It seems to me that the culprit is a bug or some negligence in Cocoa text system's calculation of character length when there are diacritical marks.

User avatar
Hamid
Posts: 734
Joined: 2007-01-17 03:25:42

Re: classic Keep on Same Line feature

Post by Hamid » 2008-09-21 08:21:45

The macro does help to refresh and correct the layout. When I run it, it corrects the layout. Then when I undo the action of the macro, the layout stays corrected.

Post Reply