Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if False:
- from org.python.pydev.editor import PyEdit #@UnresolvedImport
- cmd = 'command string'
- editor = PyEdit
- systemGlobals = {}
- if cmd == 'onCreateActions':
- assert editor is not None
- MySurroundAction = systemGlobals.get('MySurroundAction')
- if MySurroundAction is None:
- Action = editor.getActionClass() #from org.eclipse.jface.action import Action #@UnresolvedImport
- class MySurroundAction(Action):
- def __init__(self, editor):
- self.editor = editor
- def run(self):
- editor = self.editor
- sel = editor.createPySelection()
- txt = sel.getSelectedText()
- doc = sel.getDoc()
- sel = sel.getTextSelection()
- doc.replace(sel.getOffset(), sel.getLength(), 'my_func(%s)' % (txt,))
- systemGlobals['MySurroundAction'] = MySurroundAction
- # Change these constants if the default does not suit your needs
- ACTIVATION_STRING = 'x'
- WAIT_FOR_ENTER = False
- # Register the extension as an ActionListener.
- editor.addOfflineActionListener(ACTIVATION_STRING, MySurroundAction(editor), 'Surround with function', WAIT_FOR_ENTER)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement