Files
gnatstudio/examples/python/separate.py
Emmanuel Briot f1a516e1da New example, idea from F131-024
git-svn-id: svn+ssh://svn.eu/Dev/importfromcvs/trunk@95438 936e1b1b-40f2-da11-902a-00137254ae57
2006-02-20 14:57:20 +00:00

31 lines
878 B
Python

## This example shows how to add a contextual menu to jump straight to
## the implementation of a separate Ada subprogram. This is implemented
## through a custom contextual menu
import GPS
def on_goto_separate (context):
loc = context.entity().body (2)
buffer = GPS.EditorBuffer.get (loc.file())
buffer.current_view().goto \
(GPS.EditorLocation (buffer, loc.line(), loc.column()))
def separate_filter (context):
if isinstance (context, GPS.EntityContext) and context.entity():
try:
context.entity().body (2)
return True
except:
return False
else:
return False
def separate_label (context):
return "Goto separate body of " + context.entity().name()
GPS.Contextual ("Jump to separate body").create \
(on_activate=on_goto_separate,
filter=separate_filter,
label=separate_label,
ref="Go to body")