Can someone conform this TeXShop applescript behavior?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Can someone conform this TeXShop applescript behavior?

Ramón Figueroa-Centeno
Aloha,

When entering the following I always get the cursor at the end of the file.

tell application "TeXShop"
        set doc_name to the name of the front document
        set the the offset of the selection of document doc_name to -1
end tell

Is this the way it is supposed to be, a negative offset points to the end of the file? If so I could find it useful!

Thanks,

Ramón
Reply | Threaded
Open this post in threaded view
|

Re: Can someone conform this TeXShop applescript behavior?

Herbert Schulz

On Jun 5, 2010, at 9:29 PM, Ramón Figueroa-Centeno wrote:

>
> Aloha,
>
> When entering the following I always get the cursor at the end of the file.
>
> tell application "TeXShop"
> set doc_name to the name of the front document
> set the the offset of the selection of document doc_name to -1
> end tell
>
> Is this the way it is supposed to be, a negative offset points to the end of
> the file? If so I could find it useful!
>
> Thanks,
>
> Ramón

Howdy,

Haven't tested it but is and offset of -2 one character before the end of the file?

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)



----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
List Archive: http://tug.org/pipermail/macostex-archives/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex

Reply | Threaded
Open this post in threaded view
|

Re: Can someone conform this TeXShop applescript behavior?

Ramón Figueroa-Centeno
Thanks,

So this little snippet will select the whole document:

tell application "TeXShop"
        set the offset of the selection of the front document to -1
        set myoffset to the offset of the selection of the front document
        set the offset of the selection of the front document to 0
        set the length of the selection of the front document to myoffset
end tell

Ramón
Reply | Threaded
Open this post in threaded view
|

Re: Can someone conform this TeXShop applescript behavior?

Ramón Figueroa-Centeno
Aloha,

I wrote too soon, that snippet works from the script editor just fine, but when I tried it in a standalone Applescript application I got " Can’t set «class LOC » of «class SELE» of document 1 to -1."

Thus this is not a safe way to select the whole document and I would have to say that the fact that the snippet it sent before was due to a bug in TeXShop's set offset applescript command.

Ramón
Reply | Threaded
Open this post in threaded view
|

Re: Can someone conform this TeXShop applescript behavior?

Ramón Figueroa-Centeno
Aloha,

This is a safe way of selecting the whole document

tell application "TeXShop"
        set whole_document to (the text of the front document) as string
        set myoffset to count characters of whole_document
        set the offset of the selection of the front document to 0
        set the length of the selection of the front document to myoffset
end tell

Ramón