Reply to topic  [ 6 posts ] 
How to select text without color? 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
From a text with some parts marked with a color attribute, how can I select the rest, without a color attribute. (How can I select black text?)


2012-02-25 03:47:34
Profile
User avatar

Joined: 2007-01-17 03:25:42
Posts: 729
If the colour attribute is the same and not a part of a defined style, select all the text with that colour attribute (from the Statusbar color tag).
Then from the Edit menu apply Select:Inverse Selection.


2012-02-25 04:38:39
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
Yes. But if there are many colors and let's say you don't want to find out how many and which ones. If all you want is "black" text. How about that?


2012-02-25 06:01:08
Profile
User avatar

Joined: 2007-01-17 03:25:42
Posts: 729
Try Kino's Select by Color macro:
viewtopic.php?f=18&t=4151


2012-02-25 06:21:30
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
It looks indeed as if the commands necessaryfor doing a macro capable of selecting black text are being used in this other macro by Kino. Thank you.


2012-02-25 12:11:30
Profile

Joined: 2012-12-19 05:02:52
Posts: 226
Hamid wrote:


Here is another much better macro by Kino that does exactly what the OP asked for. I'm not sure whether it belongs to the macros that originally come with NWP. I hope it is not redundant. Therefore I post it here. It's called "SelectSameOrOtherColor".


### Select Same or Different Color ###

# Select all text portions having or not having the same color as that of the insertion point.

# If the insertion point is at the very end of a text object, the macro uses Typing Attributes, which may not coincide with what the user expects.

Require Pro Version 1.2
$doc = Document.active
$sel = TextSelection.active
if $sel == undefined
exit
elsif $sel.location == $sel.text.length
$attr = $sel.displayTypingAttributes
else
$attr = $sel.text.displayAttributesAtIndex $sel.location
end
$activeColor = $attr.textColor
$sameColor = $otherColors = Array.new

foreach $text in $doc.allTexts
if $text.length
$i = 0
while $i < $text.length
$attr = $text.displayAttributesAtIndex $i
$range = $text.rangeOfDisplayAttributesAtIndex $i
$sel = TextSelection.new $text, $range
if $attr.textColor == $activeColor
$sameColor.appendValue $sel
else
$otherColors.appendValue $sel
end
$i = $range.bound
end
end
end

$same = 'Same Color'
$other = 'Other Colors'
$color = Prompt 'Select text portions in...', '', $same, $other
if $color == $same
$doc.setSelections $sameColor
else
$doc.setSelections $otherColors
end

### end of macro ###


2012-12-21 21:50:10
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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