NISUS Archives

May 2013

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Date:
Sun, 12 May 2013 09:36:12 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Hello Philip and Hello All,

After a long time, I managed to implement the macro for which Philip gave me the essential ideas.

On Apr 22, 2013, at 5:15 PM, Philip Spaelti <[log in to unmask]> wrote:

> Hello Nobumi,
> 
> I am sure one could do something more elegant, but here is a macro that gives the basic idea. Unfortunately Nisus current macro implementation of working with styles etc. is a bit roundabout, so this ends up a bit more complicated than I would like:
> 
> $sel = TextSelection.active
> $text = $sel.text
> $attr = $text.displayAttributesAtIndex $sel.location
> $color = $attr.textColor
> $findExpr = ".+"
> Push Target Text $findExpr
> Set Text Color $color
> Find and Replace $findExpr,'\0','!Eau'
> Edit:Find:Show Find…
> 
> So if you select a bit of text and run this you should have ".+" in the find box with the color from the selection. Note however that you could just as easily write a macro that wouldn't bother with the find box at all, and just directly create a formatted find expression. Also you could look at some of Kino's macros that show how to select all bits with the same style.
> 
> And of course the easiest for selecting bits with the same color is to use the pop-up in the status bar at the bottom of the window.

Here is the macro which works for me:

$sel = TextSelection.active
$text = $sel.text
$attr = $text.displayAttributesAtIndex $sel.location
$color = $attr.textColor
$findExpr = ".+"
Cast to String $findExpr # I added this
Push Target Text $findExpr
Set Text Color $color
Find and Replace $findExpr,'\0','!Eau'
Edit:Find:Show Find…
Format:Paragraph Style:Remove Paragraph Styles # I added this
Format:Language:Remove Language Attribute # I added this

On the other hand, I wrote another macro to perform a wild card search with a specific hilight color attribute, using the same pattern:

$sel = TextSelection.active
$text = $sel.text
$attr = $text.displayAttributesAtIndex $sel.location
$color = $attr.textHighlightColor #changed this line
$findExpr = ".+"
Cast to String $findExpr
Push Target Text $findExpr
Set Highlight Color $color #changed this line
Find and Replace $findExpr,'\0','!Eau'
Edit:Find:Show Find…
Format:Paragraph Style:Remove Paragraph Styles
Format:Language:Remove Language Attribute

These macros are very useful for me.

Thank you very much again, Philip.

Best regqrds,

Nobumi Iyqnqgq
Tokyo,
Jqpqn

ATOM RSS1 RSS2