[Pydev-code] Re: Jython scripting
Brought to you by:
fabioz
From: Fabio Z. <fa...@gm...> - 2006-04-04 01:36:45
|
Hi Don, I'm forwarding it to the pydev-code list, as I think it might be useful to others... A general question about Jython scripting. > > Before 1.0.4 was released I had imagined that I might be able to write a > script that could receive a selection from the editor, reformat it and > return it to the editor to be pasted over the original selection. I was > thinking of doing some comment reformatting on demand. > > As far as I can tell the current scripting API does not support this > sort of thing. Is that right? Actually, you can do it, but you have to know a bit from the Eclipse API too... A 'simple' way of doing it would be requesting the editor document (something like editor.getDocument()) and play with it. It is an IDocument, and you can get whatever you want from it and change it as much as you like= . Also, maybe taking a look at PySelection ( http://cvs.sourceforge.net/viewcvs.py/pydev/org.python.pydev.core/src/org/p= ython/pydev/core/docutils/PySelection.java?rev=3D1.7&view=3Dmarkup ) might be worth it... It provides a nicer interface for getting info from a document/selection. You can instantiate it in jython with: from org.python.pydev.core.docutils import PySelection sel =3D PySelection(editor) Cheers, Fabio |