Re: [Pydev-code] Re: Jython scripting
Brought to you by:
fabioz
From: Don T. <nos...@gm...> - 2006-04-25 22:39:29
|
Fabio Zadrozny wrote: > 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/python/pydev/core/docutils/PySelection.java?rev=1.7&view=markup > <http://cvs.sourceforge.net/viewcvs.py/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PySelection.java?rev=1.7&view=markup>) > 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 = PySelection(editor) > Hi Fabio: As far as I can see there are no methods in PySelection that allow you to put text back into the editor, is this correct? I know that I can do what I want with an IDocument using the replace method, I just wondered if I am missing something in the PySelection. Thanks, Don. |