parent
6e7a6d7cb0
commit
909f017b3f
|
@ -615,9 +615,7 @@ class PathListBuffer(DirBuffer):
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
class AboutBuffer(DataBuffer):
|
ABOUT_DATA = '''
|
||||||
btype = 'about'
|
|
||||||
data = '''
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
************ ********** ****** ****** **** ******** *********
|
************ ********** ****** ****** **** ******** *********
|
||||||
|
@ -636,6 +634,8 @@ class AboutBuffer(DataBuffer):
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
'''
|
'''
|
||||||
|
class AboutBuffer(DataBuffer):
|
||||||
|
btype = 'about'
|
||||||
modename = 'about'
|
modename = 'about'
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
DataBuffer.__init__(self, '*About*', self.data)
|
DataBuffer.__init__(self, '*About*', ABOUT_DATA)
|
||||||
|
|
|
@ -219,11 +219,29 @@ class Python(mode.Fundamental):
|
||||||
self.functions = None
|
self.functions = None
|
||||||
def build_function_map(self):
|
def build_function_map(self):
|
||||||
b = self.window.buffer
|
b = self.window.buffer
|
||||||
|
scope_stack = []
|
||||||
self.functions = {}
|
self.functions = {}
|
||||||
for i in range(0, len(b.lines)):
|
for i in range(0, len(b.lines)):
|
||||||
m = regex.python_function.match(b.lines[i])
|
if regex.whitespace.match(b.lines[i]):
|
||||||
|
continue
|
||||||
|
m = regex.python_indent.match(b.lines[i])
|
||||||
|
assert m
|
||||||
|
lvl = len(m.group(1))
|
||||||
|
while scope_stack:
|
||||||
|
if lvl <= scope_stack[-1][0]:
|
||||||
|
scope_stack.pop(-1)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
m = regex.python_scope.match(b.lines[i])
|
||||||
if m:
|
if m:
|
||||||
self.functions[m.group(1)] = i
|
(ws, typ, name) = m.groups()
|
||||||
|
lvl = len(ws)
|
||||||
|
if scope_stack:
|
||||||
|
prefix = '.'.join([x[1] for x in scope_stack])
|
||||||
|
self.functions['%s.%s' % (prefix, name)] = i
|
||||||
|
else:
|
||||||
|
self.functions[name] = i
|
||||||
|
scope_stack.append((len(ws), name))
|
||||||
def get_functions(self):
|
def get_functions(self):
|
||||||
if self.functions is None:
|
if self.functions is None:
|
||||||
self.build_function_map()
|
self.build_function_map()
|
||||||
|
|
3
regex.py
3
regex.py
|
@ -32,4 +32,5 @@ perl_function = re.compile(r"^ *sub ([A-Za-z_][A-Za-z0-9_]*)")
|
||||||
python_base = re.compile(r"^[^ ]")
|
python_base = re.compile(r"^[^ ]")
|
||||||
python_dict_cleanup = re.compile(r"^( *)((?:[^'\":]|'(?:\.|[^\'])*'|\"(?:\.|[^\'])*)+?)( *)(:)( *)([^ ].*)$")
|
python_dict_cleanup = re.compile(r"^( *)((?:[^'\":]|'(?:\.|[^\'])*'|\"(?:\.|[^\'])*)+?)( *)(:)( *)([^ ].*)$")
|
||||||
python_assign_cleanup = re.compile(r"^( *)([^ ]+)( *)(=)( *)([^ ].*)$")
|
python_assign_cleanup = re.compile(r"^( *)([^ ]+)( *)(=)( *)([^ ].*)$")
|
||||||
python_function = re.compile('^ *def ([A-Za-z_][A-Za-z0-9_]*)')
|
python_scope = re.compile('^( *)(class|def) ([A-Za-z_][A-Za-z0-9_]*)')
|
||||||
|
python_indent = re.compile('^( *)')
|
||||||
|
|
Loading…
Reference in New Issue