Reply to topic  [ 3 posts ] 
Find colored text 
Author Message

Joined: 2011-03-23 07:39:53
Posts: 1
I've looked through the manual but can't find it. Is there a way to find a words or characters having colored text?
Any help appreciated.

2011-03-23 07:42:53

Joined: 2008-05-17 04:02:32
Posts: 400
If you want to find and select all texts in the same colour (manually applied, not defined in a style), put the insertion point somewhere in a text in that colour and choose ‘Select All’ from the pull-down menu (click on a coloured circle) in the status bar at the bottom of the document window.
SelectAllColor.png [ 20.07 KiB | Viewed 2433 times ]

If you want to find and select all texts in different colours, I think the macro below will do the job.
 Require Pro Version 1.3
$doc =
if $doc == undefined

$black = Color.newWithRGBA 0, 0, 0, 1
$white = Color.newWithRGBA 1, 1, 1, 1
$colors =
$samples =
$TC = Cast to String '[text] '
$BG = Cast to String '[back] '
$HL = Cast to String '[highlight] '
$sep = Cast to String '/'
$showSamples = Cast to String 'Show Samples'
$language = Language.systemLanguage

foreach $text in $doc.allTexts
   $textRanges =
   if $text.tables.count # then, exclude special texts enclosing tables
      $tableRanges =
      foreach $table in $text.tables
         $tableRanges.appendValue $table.enclosingTextRange
      $i = 0
      foreach $tableRange in $tableRanges
         $range = Range.newWithLocationAndBound $i, $tableRange.location
         $textRanges.appendValue $range
         $i = $tableRange.bound
      $range = Range.newWithLocationAndBound $i, $text.length
      $range = 0, $text.length
   $textRanges.appendValue $range
   foreach $textRange in $textRanges
      $i = $textRange.location
      while $i < $textRange.bound
         $attr = $text.displayAttributesAtIndex $i
         $range = $text.rangeOfDisplayAttributesAtIndex $i
         $sel = $text, $range
         if $attr.textColor != $black
            $key = $TC & $attr.textColor.hexTriplet
            $key &= $sep & $attr.textColor.opacity
            if $colors{$key} == undefined
               $colors{$key} =
               $sample = $key
               Push Target Text $sample
                  Set Text Color $attr.textColor
               Pop Target Text
               $samples.appendValue $sample
            $colors{$key}.appendValue $sel
         if $attr.textBackgroundColor != $white
            $key = $BG & $attr.textBackgroundColor.hexTriplet
            $key &= $sep & $attr.textBackgroundColor.opacity
            if $colors{$key} == undefined
               $colors{$key} =
               $sample = $key
               Push Target Text $sample
                  Set Background Color $attr.textBackgroundColor
               Pop Target Text
               $samples.appendValue $sample
            $colors{$key}.appendValue $sel
         if Defined $attr.textHighlightColor
            $key = $HL & $attr.textHighlightColor.hexTriplet
            $key &= $sep & $attr.textHighlightColor.opacity
            if $colors{$key} == undefined
               $colors{$key} =
               $sample = $key
               Push Target Text $sample
                  Set Highlight Color $attr.textHighlightColor
               Pop Target Text
               $samples.appendValue $sample
            $colors{$key}.appendValue $sel
         $i = $range.bound

if ! $colors.keys.count
   exit 'No color found, exiting...'

$keys = $colors.keys
$keys.sort 'li', $language
$keys.appendValue $showSamples

$keys = Prompt Checkboxes '', '', '', $keys
if ! $keys.count
   exit # nothing checked

if $keys.lastValue == $showSamples
   $showSamples = true

if $keys.count
   $sels =
   foreach $key in $keys
      $sels.appendValuesFromArray $colors{$key}
   $doc.setSelections $sels

if $showSamples == true
   $LF = Cast to String "\n"
   $samples.sort 'li', $language
   $samples = $samples.join $LF
   Document.newWithText $samples
Attachment: [4.95 KiB]
Downloaded 235 times

In either case, if you need looking at each one of selected texts, adding Bookmarks to them (Insert:Bookmarks:Add Bookmark) and visiting them one by one from Navigator (View:Show Navigator and switch to Bookmarks from Table of Content) would be handy.

2011-03-23 08:17:23
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Kino's macro and tip about the color tag's "select all" menu are a good way to go. Another option is to use attribute sensitive search:

1. Open the Find and Replace dialog.
2. By the "find what" field, click the gear icon to insert a PowerFind bubble for Wild Card > AnyText.
3. Select that bubble and use the formatting menus (eg: Format > Text Color > Red).
(Applying formatting to the bubble should automatically turn on the "attribute sensitive" option just below)
4. Use the Find Next / Find All buttons as you normally would.

2011-03-23 12:07:05
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests

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