On May 28, 2010, at 6:52 AM, Gyozo Gaspar wrote:
> I am dealing with the output of an xml parser (xerces) and it gives me
> a character array and positions inside that array (it does not care
> with lines). Having an applescript or some other solution that can
> move the cursor to a given character position would efficiently and
> elegantly solve my problem. I am ready to implement this, but I am new
> to BBEdit. What should I look for?
tell application "BBEdit"
tell window 1
-- get the selection of the top window's active document
set oldOffset to characterOffset of selection
-- prompt for the new offset, providing the current offset as
the default
display dialog "Move cursor to:" default answer oldOffset
-- get the result; if it can't be represented as a number, use
the old offset
try
set newOffset to text returned of result as number
on error
set newOffset to oldOffset - 1
end try
-- the tricky part: set the selection
select insertion point after character (newOffset)
end tell
end tell
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.