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