Page 1 of 1

Compare Documents macro: suggestion to preload Find dialog

Posted: 2017-09-07 17:18:48
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.

Re: Compare Documents macro: suggestion to preload Find dia

Posted: 2017-09-10 10:18:53
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 94 times
Note that you can change the highlighting color of “Bookmarked” texts in NWP’s Preferences > Appearance > Customized colors > Marked Text > Bookmarked (autoname).

Re: Compare Documents macro: suggestion to preload Find dia

Posted: 2017-09-10 14:33:56
by Bob Stern
Excellent idea, Kino-san! Thanks!