Re: Scripting XCode: determine current source document and text selection
Re: Scripting XCode: determine current source document and text selection
- Subject: Re: Scripting XCode: determine current source document and text selection
- From: Daniel Jalkut <email@hidden>
- Date: Mon, 5 Feb 2007 14:12:55 -0500
Xcode doesn't expose its text model as well as we might hope, but it
supports its own custom format of shell scripts that expose powerful
"selection" based facilities. See for example my blog entry:
http://www.red-sweater.com/blog/269/xcode-pasteboard-accumulator
You can provide shell-script based scripts to operate on the user's
current selection, and even replace it.
Daniel
On Jan 29, 2007, at 11:32 PM, Takaaki Naganoya wrote:
It is hard work to get selected text on Xcode.
Xcode does not work as we expected.
So, I selected the *dirty* way.
It works. But I'm not satisfied with....
<AppleScript>
tell application "Xcode"
set a to selection
if a is equal to missing value then return --no document window
try
set b to class of a
set c to properties of a
return --insertion point
on error
-- do nothing!!!
--selection cause error here
--Insertion point (no selection ) does not cause error
end try
activate
end tell
--execute command
tell application "System Events"
keystroke "c" using {command down}
end tell
set selText to the clipboard
</AppleScript>
--
Takaaki Naganoya
Piyomaru Software
http://piyo.piyocast.com
email@hidden
On 2007/01/29, at 3:26, Volker Schumacher wrote:
Dear AppleScripters,
I am trying to automate XCode via AppleScript. But I'm new to
AppleScript, and have problems to figure out some basic things.
I need to access my current text selection, and also the name and
the path of the currently edited open source document.
I found out that I can get the path via
set thePath to associated file name of window 1
so I could also determine the document name by truncating the path
if it is not available directly.
I managed to get the name and path information form text documents
within the currently open project document (set theDoc to text
document 1), but I don't know how to find out which one is
currently displayed in the text editor. I also have no idea how
to get the current text selection.
Thanks! Volker
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
mark.nu
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40red-sweater.com
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden