NISUS Archives

December 2010

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:
Sun, 26 Dec 2010 18:19:57 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (38 lines)
Hello Nobumi,

On Dec 26, 2010, at 5:17 PM, Nobumi Iyanaga wrote:

>> Same with selectedSubstrings command. This is why $selectedTexts.count in your macro returns 1 when just an insertion point exists in the frontmost document window.
> 
> This is still difficult to understand. If the index of array is zero-based, I would understand better, if "$selectedTexts.count" returned 0 (that is one selection), instead of 1...??

Ah, but what count does is just to return the number of values in an array and values may be empty strings.

And, personally, I would be very much confused if textSelections and selectedSubstrings returned different values because, in my understanding, selectedSubstrings is a kind of shorthand which is equivalent to...

$doc = Document.active
$sels = $doc.textSelections
$substrings = Array.new
foreach $sel in $sels
	$substrings.appendValue $sel.substring
end

exit $substrings


> And what is the normal way to verify if there is/are selection(s) in a document?

How about this? I don't think there is a standard way for that, though.

$sel = TextSelection.active
if $sel == undefined
	exit 'No open document or the focus in a non-text object (floating image or something else?)'
elsif $sel.length
	exit 'One or more characters (or in-line images) selected'
else
	exit 'Just a caret (zero-width selection)'
end


Kino

ATOM RSS1 RSS2