Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Current crsor position in TextEdit?

Dear all,

How can I find out the current cursor position in TextEdit? It's bound to be possible somehow, but I don't seem to be able to find it in the TextEdit dictionary.

I imagine there are also ways of getting the current highlighted text and its position, so if you happen to know that, please let me know!

Regards, Max

--------------
I've tried this, with various synonyms for cursor:

tell application "TextEdit"

set x to the number of the paragraph of the cursor of the front document


end tell

Mac OS X (10.4.2)

Posted on Jan 29, 2006 11:48 AM

Reply
Question marked as Best reply

Posted on Jan 29, 2006 3:25 PM

Hi Maximillian


Have a look at TextEdit's AppleScript dictionary.

There is no mention of "cursor", of "insertion point", or of "selection" (which is a fairly standard means of referring to a highlighted object), or of "position".

Richly scriptable text editors are there for the taking: Tex-Edit Plus, BBEdit... TextEdit is not one of them.

What is it you want to do?

H
2 replies
Question marked as Best reply

Jan 29, 2006 3:25 PM in response to Maximillian Murphy

Hi Maximillian


Have a look at TextEdit's AppleScript dictionary.

There is no mention of "cursor", of "insertion point", or of "selection" (which is a fairly standard means of referring to a highlighted object), or of "position".

Richly scriptable text editors are there for the taking: Tex-Edit Plus, BBEdit... TextEdit is not one of them.

What is it you want to do?

H

Jan 29, 2006 4:18 PM in response to HD

Tut tut - that sounds like apple setting a bad example :^) !!

What do I want to do? lots of things but here are two of them:

+ root
|
- first node of my ascii tree
| - child
| | | discussion about
| | | child
| | +- grandchild
| +- nother child
+-

now, when I'm typing the "discussion about child", every time I hit return I have to insert the spaces and vertical lines belonging to the ascii tree before carrying on. This is called manual labour and is a bad idea.

no.2 is harder to show here, but you can find it linked off my (rather scrappy) homepage at www.de-minimis.com. basically imagine that you're drawing a big ascii-art text document. If you want to copy and paste an area of the document, you usually want to work on a rectangle of characters rather than a stream of characters, so I've got to change that. I'm a little less hopeful about even a highly scriptable texteditor being able to highlight arbitrary weird shapes, so I wouldn't be surprised if I had to end up changing a little bit of the editor code itself, so open source is good! On the other hand if it's going to be really painful to automate theer's no point in trying to save labour. I hope adding applescript hooks into a program is easy?

Thanks for the refs. I've heard good things about tex-edit so I think I'll start with that. BBedit sounds big and expensive.

Current crsor position in TextEdit?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.