Compare Documents macro: suggestion to preload Find dialog

Get help using and writing Nisus Writer Pro macros.
Post Reply
Bob Stern
Posts: 170
Joined: 2006-03-12 12:32:47

Compare Documents macro: suggestion to preload Find dialog

Post by Bob Stern »

I have a suggestion for improving the excellent Compare Documents macro that's preinstalled with NWP (originally written by Kino).

Append the following two steps to the macro:
Find '(AnyText)(Or)(AnyText)', 'euW!'
Menu 'Find:Show Find…'

This opens a Find dialog pre-loaded with criteria to find any text colored pink or green by the Compare Documents macro. This makes it easier to find all changed text.
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Compare Documents macro: suggestion to preload Find dia

Post by Kino »

Thank you very much for the excellent suggestion. Yes, it would be hard to find all changed texts when the target document is large. To make the task easier, using the attribute sensitive search would be a nice idea. However, personally, I’d like to use the Find panel for something else.

So I wrote a macro (not tested sufficiently, sorry) which adds bookmarks to all texts having some background colour (i. e. not white background colour).

Code: Select all

### Add Bookmak to Texts Having Background Colors ###

Require Pro Version '2.1'

$doc = Document.active
if $doc == @undefined
	exit 'No open document. Exiting...'
end

$white = Color.white
$withBGC = Array.new

foreach $text in $doc.allTexts
	if $text.length
		$i = 0
		while $i < $text.length
			$bgc = $text.displayAttributesAtIndex($i).textBackgroundColor
			$range = $text.rangeOfDisplayAttributesAtIndex($i)
			if $bgc != $white
				$sel = TextSelection.new($text, $range)
				$withBGC.appendValue($sel)
			end
			$i = $range.bound
		end
	end
end

if ! $withBGC.count
	exit 'No text having background colors found. Exiting...'
end

Push Target Selection $withBGC
	Add Bookmark
Pop Target Selection

Set Navigator Mode 'Bookmarks by Location'
Set Navigator Shown @true

### end of macro ###
AddBookmaktoTextsHavingBackgroundColors_20170911_nwm.zip
Macro file
(4.83 KiB) Downloaded 1050 times
Note that you can change the highlighting color of “Bookmarked” texts in NWP’s Preferences > Appearance > Customized colors > Marked Text > Bookmarked (autoname).
Bob Stern
Posts: 170
Joined: 2006-03-12 12:32:47

Re: Compare Documents macro: suggestion to preload Find dia

Post by Bob Stern »

Excellent idea, Kino-san! Thanks!
Post Reply