NISUS Archives

January 2011

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:
Reply To:
Date:
Sat, 1 Jan 2011 23:38:28 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (56 lines)
Hello Nobumi,

On Jan 1, 2011, at 11:08 PM, Nobumi Iyanaga wrote:

> I wish to all of you a very Happy New Year!

Happy New Year to Nobumi, jem, Žorvaršur and all!

(Every year I forget to say this, it seems...)


> To return to what I wrote in the last year, I had a question that I forgot to ask you. In the macro you wrote, and I copied, there were these lines:
> 
> 	foreach $found in $founds
> 		if $found.text.documentContentType == 'body'  # it may be, for example, a table cell
> 			$range = Range.new $found.location + $sel.location, 0
> 			$start = TextSelection.new $sel.text, $range
> 			$paraStarts.appendValue $start
> 		end
> 	end
> 
> The two lines:
> 
> 	$range = Range.new $found.location + $sel.location, 0
> 	$start = TextSelection.new $sel.text, $range
> 
> above, can I understand that they are somehow equivalent of "SetSelect (x, y)" in Classic Nisus Writer macro...?

But those commands do not make an actual selection like SetSelect (x, y).

What to say? $found is one of the TextSelection objects got by

	$founds = $sel.subtext.findAll '^', 'E'

So, for example, the location of "<" in the diagram (?) below is 0 for the subtext but 23 for the main body text. Then, if we want to insert a line number in the main body, we have to adjust the location. For that, the macro creates a new TextSelection object ($start) by adding the offset ($sel) to $found.location.

0123456789012345678901234567890123456789
$doc.text..............<subtext>........          |
.......................012345678........

>> 	foreach $sel in $sels
>> 		$sel.range = $sel.range.unionRange $sel.text.rangeOfParagraphAtIndex($sel.location)
> 
> I find these two commands, "$range.unionRange", and "$text.rangeOfParagraphAtIndex" really very clever. NWP macro language is astonishingly well equipped with many intelligent and useful commands. But it would take long time to master them all...!

You don't need mastering them now. Just read through the Macro Reference and just retain the *existence* of those commands. You will consult it again when you really need them.

In this particular case, there is an easier way.

	Menu ':Edit:Select:Select Paragraph' 

which will transform all partial selections into those of whole paragraphs.


Kino

ATOM RSS1 RSS2