Reply to topic  [ 4 posts ] 
Color attributes 2 
Author Message

Joined: 2009-09-04 13:11:25
Posts: 28
Hi again,

I have a few other questions.

1- I would like to know if it is possible to give a color attribute to a string of letters only when that string of letter is ending a word (for the letters "ble" in the word impossible).

2- Is it possible to give different color attributes to each letter of a string without using the "Insert attributed Text" command (for example, in the string "ble" I would like to make the letter b blue, the letter l red and the letter e green).

3- What should I read to get introduce to the basic concepts I need to understand to write more elaborate macros? Is the macro reference enough? The Nisus guide and the Nisus macro reference are well written, but they don't give enough examples to show a beginner how to write more complex macros by himself.

Thank you.


2009-09-08 05:48:07
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
1. You can do something like this.
Code:
Find All 'ble\b', 'E-i'
   # \b: word boundary
   # E: PowerFind Pro mode
   # -i: case sensitive
Menu ':Format:Text Color:Blue'

If you prefer the color object…
Code:
Find All 'ble\b', 'E-i'
$blue = Color.newWithHexTriplet 0x0000FF
Set Text Color $blue

2. How about this?
Code:
$red = Color.newWithHexTriplet 0xFF0000
$green = Color.newWithHexTriplet 0x00FF00
$blue = Color.newWithHexTriplet 0x0000FF

$doc = Document.active
Find All 'ble\b', 'E-i'
   # \b: word boundary
   # E: PowerFind Pro mode
   # -i: case sensitive

$sels = $doc.textSelections  # get current selections

# Find All in Selection 'b'  # This command is unnecessary
Set Text Color $blue

$doc.setSelections $sels  # restore selections

Find All in Selection 'l'
Set Text Color $red

$doc.setSelections $sels  # restore selections

Find All in Selection 'e'
Set Text Color $green

3. It would be much more helpful in mastering Nisus Macro to write, say, 100 macros than to read the Reference 100 times. And I think everyone starts with modifying existing macros so that they fits one's own needs. Also writing macros for inspecting Nisus Macro elements (object, command, property) would be very useful in understanding them. For example, the following shows text selection objects in plain text format.
Code:
Debug.setDestination 'new'
$doc = Document.active
Find All 'ble\b', 'E-i'
$sels = $doc.textSelections
Debug.log $sels


2009-09-09 08:57:57
Profile

Joined: 2009-09-04 13:11:25
Posts: 28
Thank you for your help!


2009-09-09 12:25:53
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
The macro reference doesn't have a lot of examples, but Kino's suggest to look at other macros is a good one. Don't forget about the macro repository, as well as Kino's own cache of copious macros.


2009-09-09 17:15:39
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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