Re: setting insertion point at a line
Re: setting insertion point at a line
- Subject: Re: setting insertion point at a line
- From: Matt Neuburg <email@hidden>
- Date: Thu, 25 May 2006 08:45:16 -0700
- Thread-topic: setting insertion point at a line
On Wed, 24 May 2006 23:45:14 -0700, Phil Aaronson <email@hidden> said:
>Hi All,
>
>I've been trying to write an Applescript to open a project, open a
>file in the project and set the cursor to a particular line. The
>closest I've been able to come is to set the insertion point by
>character, but not by line:
>
>tell application "Xcode"
> open theProject
> activate
> open file theFile
> activate
> set selection of text document 1 to insertion point 1 of text
>document 1
>end tell
>
>I'd appreciate any pointers. Applescript and I aren't exactly the
>best of friends :)
This may be a silly way to do it, but it does work:
display dialog "What line?" default answer "1"
set n to text returned of result as integer
tell application "Xcode"
tell text document 1
set s to (get text of it)
set len to length of text from paragraph 1 to paragraph n of s
set selection to insertion point (len + 1)
end tell
end tell
That puts the insertion point at the end of the requested line. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden