nisus.com
https://www.nisus.com/forum/

How to select text without color?
https://www.nisus.com/forum/viewtopic.php?f=17&t=4837
Page 1 of 1

Author:  js [ 2012-02-25 03:47:34 ]
Post subject:  How to select text without color?

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?)

Author:  Hamid [ 2012-02-25 04:38:39 ]
Post subject:  Re: How to select text without color?

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.

Author:  js [ 2012-02-25 06:01:08 ]
Post subject:  Re: How to select text without color?

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?

Author:  Hamid [ 2012-02-25 06:21:30 ]
Post subject:  Re: How to select text without color?

Try Kino's Select by Color macro:
viewtopic.php?f=18&t=4151

Author:  js [ 2012-02-25 12:11:30 ]
Post subject:  Re: How to select text without color?

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.

Author:  Þorvarður [ 2012-12-21 21:50:10 ]
Post subject:  Re: How to select text without color?

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 ###

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/