1 |
# FunctionSelector v0.04 script for glimmer |
################################################## |
2 |
# last edit by Andreas Motl<andreas.motl@ilo.de> |
# $Id$ |
3 |
# and Sebastian Utz<su@tunemedia.de> 2002-11-01 |
# small plugin for glimmer |
4 |
# |
# |
5 |
#ToDo: |
# Authors: |
6 |
|
# Andreas Motl<andreas.motl@ilo.de> |
7 |
|
# Sebastian Utz<su@tunemedia.de> |
8 |
|
# |
9 |
|
# ToDo: |
10 |
# - Bug: FunctionList doesn't refresh on new opened files by its own |
# - Bug: FunctionList doesn't refresh on new opened files by its own |
11 |
# - tune regex for more languages |
# - tune regex for more languages |
12 |
# |
# |
13 |
|
# Changelog: |
14 |
|
# $Log$ |
15 |
|
# Revision 1.4 2002/11/12 22:22:25 jonen |
16 |
|
# + added support for concurrent pygtk installations |
17 |
|
# |
18 |
|
# Revision 1.3 2002/11/12 20:14:48 jonen |
19 |
|
# + php functions maybe prefixed by a '&'. fixed sigpart regex. |
20 |
|
# + forgot 'class' (php) after all. fixed regex. |
21 |
|
# + renamed regex_perl to regex_noparenthesis |
22 |
|
# + perl subs with an space after the first '{' weren't regognized. fixed regex. |
23 |
|
# |
24 |
|
# Revision 1.2 2002/11/08 02:37:25 jonen |
25 |
|
# + added cvs header |
26 |
|
# + added hook for refresh on "save-file" |
27 |
|
# suggested by Mark McAulay |
28 |
|
# |
29 |
|
# |
30 |
|
################################################## |
31 |
|
|
32 |
import glimmer |
import glimmer |
33 |
import string |
import string |
34 |
import re |
import re |
36 |
import os |
import os |
37 |
sys.argv=[] |
sys.argv=[] |
38 |
sys.argv.append("null") |
sys.argv.append("null") |
39 |
|
try: |
40 |
|
import pygtk |
41 |
|
pygtk.require("1.2") |
42 |
|
except: |
43 |
|
pass |
44 |
from gtk import * |
from gtk import * |
45 |
import _gtk |
import _gtk |
46 |
import _gnome |
import _gnome |
57 |
# class/function/sub/packages signatures |
# class/function/sub/packages signatures |
58 |
# in source code |
# in source code |
59 |
prefix_pattern = '^[|\s]*' |
prefix_pattern = '^[|\s]*' |
60 |
sigpart = '\s+([\w|:]+?)\s*' |
sigpart = '\s+([\w|:|&]+?)\s*' |
61 |
regex_universal=re.compile(prefix_pattern + '(?:\w+?)\*??' + sigpart + '\(.*?\)[\s|:|{]*$') |
regex_universal=re.compile(prefix_pattern + '(?:\w+?)\*??' + sigpart + '\(.*?\)[\s|:|{]*\s*$') |
62 |
regex_perl=re.compile(prefix_pattern + '(?:package|sub)' + sigpart + '[;|{]$') |
regex_noparenthesis=re.compile(prefix_pattern + '(?:package|sub|class)' + sigpart + '[;|{]\s*$') |
63 |
|
|
64 |
def get_functionNameFromLine(str): |
def get_functionNameFromLine(str): |
65 |
for regex in (regex_universal, regex_perl): |
for regex in (regex_universal, regex_noparenthesis): |
66 |
match=regex.search(str) |
match=regex.search(str) |
67 |
if match: |
if match: |
68 |
str = match.group(1) |
str = match.group(1) |
165 |
functionwindow.add(functionlist) |
functionwindow.add(functionlist) |
166 |
functionlist.show() |
functionlist.show() |
167 |
#functionlist.column_titles_show(1) |
#functionlist.column_titles_show(1) |
|
#functionlist.set_column_title(0, "Functions:") |
|
168 |
glimmer.add_paned_object(functionbox._o, "FunctionSelector", 0) |
glimmer.add_paned_object(functionbox._o, "FunctionSelector", 0) |
169 |
our_main() |
our_main() |
170 |
checkitem = GtkCheckMenuItem("Function Selector") |
checkitem = GtkCheckMenuItem("Function Selector") |
176 |
|
|
177 |
glimmer.register_signal_hook("change-file", callback_change) |
glimmer.register_signal_hook("change-file", callback_change) |
178 |
|
|
179 |
|
glimmer.register_signal_hook("save-file", callback_change) |
180 |
|
|
181 |
args = (checkitem, functionbox, ) |
args = (checkitem, functionbox, ) |
182 |
_gtk.gtk_signal_connect(closebutton._o, "clicked", close_function_selector, args) |
_gtk.gtk_signal_connect(closebutton._o, "clicked", close_function_selector, args) |
183 |
args = (None, ) |
args = (None, ) |