Re: Setting the selection of a document via AppleScript
Re: Setting the selection of a document via AppleScript
- Subject: Re: Setting the selection of a document via AppleScript
- From: Scott Tooker <email@hidden>
- Date: Thu, 16 Jun 2005 14:11:52 -0700
On Jun 15, 2005, at 8:49 PM, Timothy J. Wood wrote:
I'm working on updating OmniObjectMeter to work with Xcode 2.1.
One of the things we need to be able to do is to open a file and
select a particular _line_ (i.e., I don't know the character range
off hand).
Rather than take the old approach of having a bundle that gets
loaded into Xcode and that uses shady API, I'd rather use
AppleScript to do the work. I'm not sure if this is possible
though. I can do:
tell application "Xcode"
open file "Extra:private:tmp:foo.m"
set MyDoc to text document "foo.m"
selection of MyDoc
end tell
--> text 5 thru 8 of text document "foo.m"
If I then try to evaluate the expression 'text 5 thru 8 of text
document "foo.m"', I get an error.
If I try 'select text 5 thru 8 of text document "foo.m"', I get
an error. All the other variants I have tried give pretty much
useless errors (par for the course with AppleScript).
What I'd like to do is:
select line 1 of text document "foo.m"
Naturally, that leads to another error :)
Also acceptable would be a URL form that specified the path and
line or character range to select :)
Any hints?
You can set the character range using the following syntax:
set selection of text document 1 to {2, 5}
(where 2 and 5 are the starting and ending character positions of the
selection)
You can set the selection to an insertion point using the following
syntax:
set selection of text document 1 to insertion point 5 of text document 1
(where insertion point n falls before character n)
As far as selecting a line goes, you should be be able to use the
following:
set selection of text document 1 to
paragraph 20 of contents of text document 1
Scott
-tim
_______________________________________________
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
_______________________________________________
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