PyDev Jython 스크립트에서 변경된 텍스트 알림을 등록하려면 어떻게해야합니까?편집기 텍스트가 바뀔 때마다 PyDev에서 자이 썬 스크립팅 트리거
필자는 PyDev 용 Jython 스크립트를 작성하여 편집기의 텍스트를 분석 한 다음 특정 상황에서 텍스트에 주석을 추가합니다. 사용자가 무언가를 입력 할 때마다 분석을 다시 실행해야합니다.
introduction to Jython scripting in PyDev을 통해 읽었으며 example scripts을 보았지만 모두 명령 키로 트리거 한 것 같습니다. 나는 PyEdit class을보고, IPyEditListener3's onInputChanged event에 등록해야하는 것처럼 보입니다.
아래 스크립트를 시도했지만 내 이벤트 처리기를 호출하지 않는 것 같습니다. 내가 놓친 게 무엇입니까?
if False:
from org.python.pydev.editor import PyEdit #@UnresolvedImport
cmd = 'command string'
editor = PyEdit
#-------------- REQUIRED LOCALS
#interface: String indicating which command will be executed
assert cmd is not None
#interface: PyEdit object: this is the actual editor that we will act upon
assert editor is not None
print 'command is:', cmd, ' file is:', editor.getEditorFile().getName()
if cmd == 'onCreateActions':
from org.python.pydev.editor import IPyEditListener #@UnresolvedImport
from org.python.pydev.editor import IPyEditListener3 #@UnresolvedImport
class PyEditListener(IPyEditListener, IPyEditListener3):
def onInputChanged(self,
edit,
oldInput,
newInput,
monitor):
print 'onInputChanged'
try:
editor.addPyeditListener(PyEditListener())
except Exception, ex:
print ex
print 'finished.'