Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding the closest word!

35 views
Skip to first unread message

Atmapuri

unread,
Jun 6, 2008, 10:03:11 AM6/6/08
to
Hi!

In which way could I obtain the word closest to the
cursor in the currently open file in the editor?

I guess I would at least need cursor position
and access to the text buffer of the currently edited
file.

I can see in Castalia that this is possible.

Thanks!
Atmapuri

Gerrit Beuze

unread,
Jun 6, 2008, 10:39:32 AM6/6/08
to
> In which way could I obtain the word closest to the
> cursor in the currently open file in the editor?

There's nothing build in the ToolsAPI that does this.

Use IOTAEditView to get the cursor position,
and the corresponding charpos
Use TEditorReader to read the code at that position
(probably the entire line)
Write a procedure that does what you need.

Gerrit Beuze
ModelMaker Tools


Lex Y. Li

unread,
Jun 6, 2008, 11:28:33 PM6/6/08
to
Atmapuri wrote:
> I can see in Castalia that this is possible.

According to CodeRush's author Mark and Castalia's author Jacob, you
cannot do many fancy things with OTA in fact. Both CodeRush and Castalia
use a lot of low level hacking tricks to inject into Delphi IDE to
realize so many wonderful features.

Gerrit Beuze

unread,
Jun 7, 2008, 7:01:31 AM6/7/08
to
> According to CodeRush's author Mark and Castalia's author Jacob, you cannot do many fancy things with OTA in fact. Both CodeRush
> and Castalia use a lot of low level hacking tricks to inject into Delphi IDE to realize so many wonderful features.

You can do a lot without none or very little hacking...
ModelMaker Code Explorer adds a lot of features without any low level
hacks.

Gerrit Beuze
ModelMaker Tools

Boost your productivity in the Delphi IDE with ModelMaker Code Explorer:
http://www.modelmakertools.com/code-explorer/index.html


Erik Berry

unread,
Jun 8, 2008, 8:04:30 PM6/8/08
to
Atmapuri wrote:
> In which way could I obtain the word closest to the
> cursor in the currently open file in the editor?

You could try IOTAEditPosition.RipText with the flags like
rfIncludeAlphaChars. There is also a search interface to find whole words
(see IOTASearchOptions.WordBoundary). You may need to do some caret
positioning before using either method.

Erik

Atmapuri

unread,
Jun 9, 2008, 6:00:39 AM6/9/08
to
Hi!

> You could try IOTAEditPosition.RipText with the flags like
> rfIncludeAlphaChars. There is also a search interface to find whole words
> (see IOTASearchOptions.WordBoundary). You may need to do some caret
> positioning before using either method.

I also posted a QC in your corner :)

http://qc.codegear.com/wc/qcmain.aspx?d=63061

Thanks!
Atmapuri

0 new messages