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.3 2002/11/12 20:14:48 jonen |
16 |
|
# + php functions maybe prefixed by a '&'. fixed sigpart regex. |
17 |
|
# + forgot 'class' (php) after all. fixed regex. |
18 |
|
# + renamed regex_perl to regex_noparenthesis |
19 |
|
# + perl subs with an space after the first '{' weren't regognized. fixed regex. |
20 |
|
# |
21 |
|
# Revision 1.2 2002/11/08 02:37:25 jonen |
22 |
|
# + added cvs header |
23 |
|
# + added hook for refresh on "save-file" |
24 |
|
# suggested by Mark McAulay |
25 |
|
# |
26 |
|
# |
27 |
|
################################################## |
28 |
|
|
29 |
import glimmer |
import glimmer |
30 |
import string |
import string |
31 |
import re |
import re |
49 |
# class/function/sub/packages signatures |
# class/function/sub/packages signatures |
50 |
# in source code |
# in source code |
51 |
prefix_pattern = '^[|\s]*' |
prefix_pattern = '^[|\s]*' |
52 |
sigpart = '\s+([\w|:]+?)\s*' |
sigpart = '\s+([\w|:|&]+?)\s*' |
53 |
regex_universal=re.compile(prefix_pattern + '(?:\w+?)\*??' + sigpart + '\(.*?\)[\s|:|{]*$') |
regex_universal=re.compile(prefix_pattern + '(?:\w+?)\*??' + sigpart + '\(.*?\)[\s|:|{]*\s*$') |
54 |
regex_perl=re.compile(prefix_pattern + '(?:package|sub)' + sigpart + '[;|{]$') |
regex_noparenthesis=re.compile(prefix_pattern + '(?:package|sub|class)' + sigpart + '[;|{]\s*$') |
55 |
|
|
56 |
def get_functionNameFromLine(str): |
def get_functionNameFromLine(str): |
57 |
for regex in (regex_universal, regex_perl): |
for regex in (regex_universal, regex_noparenthesis): |
58 |
match=regex.search(str) |
match=regex.search(str) |
59 |
if match: |
if match: |
60 |
str = match.group(1) |
str = match.group(1) |
157 |
functionwindow.add(functionlist) |
functionwindow.add(functionlist) |
158 |
functionlist.show() |
functionlist.show() |
159 |
#functionlist.column_titles_show(1) |
#functionlist.column_titles_show(1) |
|
#functionlist.set_column_title(0, "Functions:") |
|
160 |
glimmer.add_paned_object(functionbox._o, "FunctionSelector", 0) |
glimmer.add_paned_object(functionbox._o, "FunctionSelector", 0) |
161 |
our_main() |
our_main() |
162 |
checkitem = GtkCheckMenuItem("Function Selector") |
checkitem = GtkCheckMenuItem("Function Selector") |
168 |
|
|
169 |
glimmer.register_signal_hook("change-file", callback_change) |
glimmer.register_signal_hook("change-file", callback_change) |
170 |
|
|
171 |
|
glimmer.register_signal_hook("save-file", callback_change) |
172 |
|
|
173 |
args = (checkitem, functionbox, ) |
args = (checkitem, functionbox, ) |
174 |
_gtk.gtk_signal_connect(closebutton._o, "clicked", close_function_selector, args) |
_gtk.gtk_signal_connect(closebutton._o, "clicked", close_function_selector, args) |
175 |
args = (None, ) |
args = (None, ) |