Reply to topic  [ 3 posts ] 
Compare Documents macro: suggestion to preload Find dialog 
Author Message

Joined: 2006-03-12 12:32:47
Posts: 138
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.


2017-09-07 17:18:48
Profile

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


Attachment:
File comment: Macro file
AddBookmaktoTextsHavingBackgroundColors_20170911_nwm.zip [4.83 KiB]
Downloaded 21 times


Note that you can change the highlighting color of “Bookmarked” texts in NWP’s Preferences > Appearance > Customized colors > Marked Text > Bookmarked (autoname).


2017-09-10 10:18:53
Profile

Joined: 2006-03-12 12:32:47
Posts: 138
Excellent idea, Kino-san! Thanks!


2017-09-10 14:33:56
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software