perl context junk

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-05-13 15:21:07 +00:00
parent baede0a71c
commit 635b2678d8
1 changed files with 13 additions and 22 deletions

View File

@ -246,7 +246,6 @@ class PerlViewWordPerldoc(Method):
w.application.set_error('displaying documentation for %r' % word)
def _execute(self, w, **vargs):
token = w.get_token()
#word = w.get_word(wl=string.letters + string.digits + '_:')
word = token.string
# make sure that the name is (mostly) valid
@ -520,12 +519,8 @@ class PerlFunctionCompleter(completer.Completer):
class PerlContext(context.Context):
def _regen_stack(self, y):
if y > 0:
if self.namelines[y - 1][1]:
return list(self.namelines[y - 1][1])
else:
#xyz
return []
if y > 0 and self.namelines[y - 1][1]:
return list(self.namelines[y - 1][1])
else:
return []
@ -533,9 +528,11 @@ class PerlContext(context.Context):
blen = len(self.mode.window.buffer.lines)
highlights = self.mode.window.get_highlighter()
i = y1
#starting = False
starting = bool(stack)
starting = curr and not bool(stack)
while i < y2:
if not starting and not stack:
curr = None
g = highlights.tokens[i]
if (not stack and len(g) > 2 and g[0].name == 'perl_keyword' and
g[0].string == 'sub' and g[2].name == 'sub'):
@ -545,20 +542,14 @@ class PerlContext(context.Context):
if i == y2 - 1 and curr != self.namelines[i][0] and y2 < blen:
y2 += 1
#if curr:
# self.namelines[i] = (curr, tuple(stack))
m = self.mode
for t in g:
if t.name in m.opentokens and t.string in m.opentags:
if t.name == 'delimiter' and t.string == '{':
stack.append(t.string)
if(t.string == '{'):
starting = False
elif t.name in m.closetokens and t.string in m.closetags:
#assert stack and stack[-1] == m.closetags[t.string]:
starting = False
elif t.name == 'delimiter' and t.string == '}':
stack.pop(-1)
if not starting and not stack:
curr = None
if curr:
self.namelines[i] = (curr, tuple(stack))
i += 1
@ -673,8 +664,8 @@ class Perl(mode.Fundamental):
completers = {
'perlfunction': PerlFunctionCompleter(),
}
#format = "%(flag)s %(bname)-18s (%(mname)s) %(cursor)s/%(mark)s %(perc)s [%(func)s]"
format = "%(flag)s %(bname)-18s (%(mname)s) %(cursor)s/%(mark)s %(perc)s"
format = "%(flag)s %(bname)-18s (%(mname)s) %(cursor)s/%(mark)s %(perc)s [%(func)s]"
#format = "%(flag)s %(bname)-18s (%(mname)s) %(cursor)s/%(mark)s %(perc)s"
def get_status_names(self):
w = self.window
c = w.logical_cursor()
@ -685,7 +676,7 @@ class Perl(mode.Fundamental):
'perc': self._get_perc(),
'cursor': '(%d,%d)' % (c.y + 1, c.x + 1),
'mark': self._get_mark(),
#'func': self.get_line_function(c.y),
'func': self.get_line_function(c.y),
}
return names
def __init__(self, w):
@ -703,7 +694,7 @@ class Perl(mode.Fundamental):
self.add_bindings('close-paren', (')'))
self.add_bindings('close-bracket', (']'))
self.add_bindings('close-brace', ('}'))
#self.context = PerlContext(self)
self.context = PerlContext(self)
self.functions = None
self.funclines = None