parent
0967b3ff63
commit
dfa5ff88f3
|
@ -1,5 +1,6 @@
|
|||
import commands, os.path, re, string, sys, traceback
|
||||
import color, completer, context, default, mode, method, regex, tab, method.introspect
|
||||
import color, completer, context, default, mode, method, regex, tab
|
||||
import method.introspect
|
||||
from point import Point
|
||||
from render import RenderString
|
||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||
|
@ -132,7 +133,8 @@ class PythonTabber(tab.StackTabber):
|
|||
self._pop()
|
||||
currlvl = self.get_curr_level()
|
||||
self.popped = True
|
||||
# ok, having done all that, we can now process each token on the line
|
||||
# ok, having done all that, we can now process each token
|
||||
# on the line
|
||||
for i in range(0, len(tokens)):
|
||||
currlvl = self._handle_token(currlvl, y, i)
|
||||
# so let's store the level for this line, as well as some debugging
|
||||
|
@ -174,31 +176,32 @@ class PythonTabber(tab.StackTabber):
|
|||
else:
|
||||
self._pop()
|
||||
elif fqname == 'python_keyword':
|
||||
if token.string in self.endlevel_names and self.is_leftmost_token(y, i):
|
||||
s = token.string
|
||||
if s in self.endlevel_names and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least once
|
||||
self._pop()
|
||||
self.popped = True
|
||||
elif token.string in self.startlevel_names and self.is_leftmost_token(y, i):
|
||||
elif s in self.startlevel_names and self.is_leftmost_token(y, i):
|
||||
# we know we will indent exactly once
|
||||
self._append(token.string, currlvl + w, y)
|
||||
elif token.string in ('elif', 'else') and self.is_leftmost_token(y, i):
|
||||
self._append(s, currlvl + w, y)
|
||||
elif s in ('elif', 'else') and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least to the first if/elif
|
||||
if not self.popped and not self.last_popped and self._peek_until('if', 'elif'):
|
||||
self._pop_until('if', 'elif')
|
||||
currlvl = self.get_curr_level()
|
||||
self._append(token.string, currlvl + w, y)
|
||||
elif token.string == 'except' and self.is_leftmost_token(y, i):
|
||||
self._append(s, currlvl + w, y)
|
||||
elif s == 'except' and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least to the first try
|
||||
if not self.popped and not self.last_popped:
|
||||
self._pop_until('try')
|
||||
currlvl = self.get_curr_level()
|
||||
self._append(token.string, currlvl + w, y)
|
||||
elif token.string == 'finally' and self.is_leftmost_token(y, i):
|
||||
self._append(s, currlvl + w, y)
|
||||
elif s == 'finally' and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least to the first try/except
|
||||
if not self.popped and not self.last_popped:
|
||||
self._pop_until('try', 'except')
|
||||
currlvl = self.get_curr_level()
|
||||
self._append(token.string, currlvl + w, y)
|
||||
self._append(s, currlvl + w, y)
|
||||
return currlvl
|
||||
|
||||
class PythonCheckSyntax(method.Method):
|
||||
|
@ -285,9 +288,10 @@ class PythonDictCleanup(method.Method):
|
|||
value = groups_by_line[i][5]
|
||||
key_pad = ' ' * (key_w - len(key))
|
||||
if sep == '=':
|
||||
data += indent_pad + key + key_pad + ' ' + sep + ' ' + value + '\n'
|
||||
data += indent_pad + key + key_pad + ' ' + sep + ' '
|
||||
else:
|
||||
data += indent_pad + key + sep + ' ' + key_pad + value + '\n'
|
||||
data += indent_pad + key + sep + ' ' + key_pad
|
||||
data += value + '\n'
|
||||
|
||||
# remove the old text and add the new
|
||||
start_p = Point(0, start)
|
||||
|
@ -581,7 +585,8 @@ class Python(mode.Fundamental):
|
|||
}
|
||||
actions = [PythonInitNames, PythonListNames, PythonGotoName, PythonHelp,
|
||||
PythonGotoFunction, PythonGotoClass, PythonCheckSyntax,
|
||||
PythonDictCleanup, PythonSemanticComplete, PythonBrmFindReferences,
|
||||
PythonDictCleanup, PythonSemanticComplete,
|
||||
PythonBrmFindReferences,
|
||||
PythonInsertTripleSquotes, PythonInsertTripleDquotes]
|
||||
completers = {
|
||||
"pythonname": PythonNameCompleter(None),
|
||||
|
@ -589,14 +594,14 @@ class Python(mode.Fundamental):
|
|||
"pythonclass": PythonClassCompleter(None),
|
||||
}
|
||||
|
||||
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s] %(vc-info)s"
|
||||
#format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s] %(vc-info)s"
|
||||
format = "%(flag)s %(bname)s (%(mname)s) %(indent)s %(cursor)s %(perc)s [%(name)s] %(vc-info)s"
|
||||
header_size = 3
|
||||
|
||||
def get_status_names(self):
|
||||
names = mode.Fundamental.get_status_names(self)
|
||||
c = self.window.logical_cursor()
|
||||
names['name'] = self.context.get_line_name(c.y)
|
||||
#names['first'] = self.window.first.xy()
|
||||
return names
|
||||
|
||||
# xyz
|
||||
|
|
Loading…
Reference in New Issue