parent
74ab76836c
commit
2f685cb23a
|
@ -304,10 +304,10 @@ class Application(object):
|
|||
# understand. i encourage someone else to write something better.
|
||||
numcols = max(self.bufferlist.slots[n].width // (maxlen + 2), 1)
|
||||
numrows = clen - ((clen // numcols) * (numcols - 1))
|
||||
for i in range(0, numrows):
|
||||
for i in xrange(0, numrows):
|
||||
names = []
|
||||
index = i * numcols
|
||||
for j in range(0, numcols):
|
||||
for j in xrange(0, numcols):
|
||||
if index + j < clen:
|
||||
names.append('%-*s' % (maxlen, candidates[index + j]))
|
||||
else:
|
||||
|
@ -382,7 +382,7 @@ class Application(object):
|
|||
blist.remove_buffer(b)
|
||||
b.close()
|
||||
active_slot = blist.slots[self.active_slot]
|
||||
for i in range(0, len(blist.slots)):
|
||||
for i in xrange(0, len(blist.slots)):
|
||||
if blist.slots[i].is_empty():
|
||||
if blist.hidden_buffers:
|
||||
blist.set_slot(i, blist.hidden_buffers[0])
|
||||
|
@ -837,7 +837,7 @@ class Application(object):
|
|||
# sub-drawing methods
|
||||
def draw_slots(self):
|
||||
self.win.erase()
|
||||
for i in range(0, len(self.bufferlist.slots)):
|
||||
for i in xrange(0, len(self.bufferlist.slots)):
|
||||
#slot = self.bufferlist.slots[i]
|
||||
self.draw_slot(i)
|
||||
self.draw_status_bar(i)
|
||||
|
@ -854,7 +854,7 @@ class Application(object):
|
|||
|
||||
def highlight_chars(self, sy, sx1, sx2, fg='default', bg='default'):
|
||||
assert sx2 < self.x, "%d < %d" % (sx2, self.x)
|
||||
for x in range(sx1, sx2):
|
||||
for x in xrange(sx1, sx2):
|
||||
self.highlight_char(sy, x, fg, bg)
|
||||
|
||||
def highlight_simple_range(self, slot, y1, x1, x2, fg, bg):
|
||||
|
@ -936,7 +936,7 @@ class Application(object):
|
|||
if w.mode.header:
|
||||
rstrs = w.mode.get_header()
|
||||
assert len(rstrs) >= w.mode.header
|
||||
for j in range(0, w.mode.header):
|
||||
for j in xrange(0, w.mode.header):
|
||||
k = 0
|
||||
for rstr in rstrs[j]:
|
||||
rstr.draw(self.win, slot.y_offset + j, slot.x_offset + k, slot.width)
|
||||
|
@ -971,7 +971,7 @@ class Application(object):
|
|||
shade = util.get_margin_color(w, 'blue')
|
||||
limit = util.get_margin_limit(w, 80)
|
||||
if limit < self.x:
|
||||
for j in range(0, slot.height):
|
||||
for j in xrange(0, slot.height):
|
||||
char = chr(self.win.inch(j + slot.y_offset, limit) & 255)
|
||||
attr = color.build('default', shade, 'bold')
|
||||
self.addstr(j + slot.y_offset, limit + w.mode.lmargin, char, attr)
|
||||
|
@ -996,7 +996,7 @@ class Application(object):
|
|||
rlines = w.render_line_lit(y, swidth)
|
||||
else:
|
||||
rlines = w.render_line_raw(y, swidth)
|
||||
for j in range(k, len(rlines)):
|
||||
for j in xrange(k, len(rlines)):
|
||||
y2 = slot.y_offset + count
|
||||
if lm:
|
||||
lcont = j > 0
|
||||
|
@ -1031,7 +1031,7 @@ class Application(object):
|
|||
attr = color.build('default', 'default')
|
||||
if self.error_string:
|
||||
attr = color.build('default', 'default')
|
||||
for i in range(0, len(lines)):
|
||||
for i in xrange(0, len(lines)):
|
||||
line = lines[i]
|
||||
try:
|
||||
self.addstr(self.y - len(lines) + i, 0, line, attr)
|
||||
|
@ -1041,7 +1041,7 @@ class Application(object):
|
|||
return
|
||||
pattr = color.build('cyan', 'default', 'bold')
|
||||
plines = self.get_minibuffer_x_lines(self.mini_prompt)
|
||||
for i in range(0, len(plines)):
|
||||
for i in xrange(0, len(plines)):
|
||||
pline = plines[i]
|
||||
try:
|
||||
self.addstr(self.y - len(lines) + i, 0, pline, pattr)
|
||||
|
|
|
@ -284,7 +284,7 @@ class Buffer(object):
|
|||
assert p1 <= p2, "p1.x (%d) > p2.x (%d)" % (p1.x, p2.x)
|
||||
lines = []
|
||||
x = p1.x
|
||||
for i in range(p1.y, p2.y):
|
||||
for i in xrange(p1.y, p2.y):
|
||||
lines.append(self.lines[i][x:])
|
||||
x = 0
|
||||
lines.append(self.lines[p2.y][x:p2.x])
|
||||
|
@ -325,7 +325,7 @@ class Buffer(object):
|
|||
self.lines.insert(p.y + 1, [])
|
||||
self.lines[p.y + 1] = lines[-1] + self.lines[p.y][p.x:]
|
||||
self.lines[p.y] = self.lines[p.y][:p.x] + lines[0]
|
||||
for i in range(1, llen - 1):
|
||||
for i in xrange(1, llen - 1):
|
||||
self.lines.insert(p.y + i, lines[i])
|
||||
else:
|
||||
self.lines[p.y] = self.lines[p.y][:p.x] + lines[-1] + self.lines[p.y][p.x:]
|
||||
|
@ -376,7 +376,7 @@ class Buffer(object):
|
|||
return m.end()
|
||||
def detect_indent_level(self, y1, y2):
|
||||
x = None
|
||||
for y in range(y1, y2):
|
||||
for y in xrange(y1, y2):
|
||||
if self.is_whitespace(y):
|
||||
continue
|
||||
c = self.count_leading_whitespace(y)
|
||||
|
|
|
@ -25,7 +25,7 @@ class ColorHighlighter(Highlighter):
|
|||
def delete_token(self, y, i):
|
||||
del self.tokens[y][i]
|
||||
def relex(self, lines, y1, x1, y2, x2, token=None):
|
||||
for y in range(y1, y2 + 1):
|
||||
for y in xrange(y1, y2 + 1):
|
||||
self.highlight_line(y, lines[y])
|
||||
|
||||
def highlight_line(self, y, line):
|
||||
|
@ -52,7 +52,7 @@ class ColorHighlighter(Highlighter):
|
|||
if self.tokens:
|
||||
return
|
||||
self.tokens = [None] * len(lines)
|
||||
for y in range(0, len(lines)):
|
||||
for y in xrange(0, len(lines)):
|
||||
self.highlight_line(y, lines[y])
|
||||
|
||||
class ColorDataBuffer(DataBuffer):
|
||||
|
|
|
@ -58,7 +58,7 @@ class DirBuffer(Buffer):
|
|||
continue
|
||||
path = self._make_path(name)
|
||||
fields = dirutil.path_fields(path, name)
|
||||
for i in range(0, 5):
|
||||
for i in xrange(0, 5):
|
||||
try:
|
||||
maxlens[i] = max(maxlens[i], len(fields[i]))
|
||||
except:
|
||||
|
|
|
@ -107,7 +107,7 @@ class PipeBuffer(Buffer):
|
|||
self.lines.insert(p.y + 1, [])
|
||||
self.lines[p.y + 1] = lines[-1] + self.lines[p.y][p.x:]
|
||||
self.lines[p.y] = self.lines[p.y][:p.x] + lines[0]
|
||||
for i in range(1, llen - 1):
|
||||
for i in xrange(1, llen - 1):
|
||||
self.lines.insert(p.y + i, lines[i])
|
||||
else:
|
||||
self.lines[p.y] = self.lines[p.y][:p.x] + lines[-1] + self.lines[p.y][p.x:]
|
||||
|
|
|
@ -43,12 +43,12 @@ class BufferList(object):
|
|||
def fit_slots(self):
|
||||
total = self.height - len(self.slots) + 1 - self.mini_height
|
||||
heights = [total / len(self.slots)] * len(self.slots)
|
||||
for i in range(0, total % len(self.slots)):
|
||||
for i in xrange(0, total % len(self.slots)):
|
||||
heights[i] += 1
|
||||
offsets = [0]
|
||||
for i in range(1, len(self.slots)):
|
||||
for i in xrange(1, len(self.slots)):
|
||||
offsets.insert(i, offsets[i - 1] + heights[i - 1] + 1)
|
||||
for i in range(0, len(self.slots)):
|
||||
for i in xrange(0, len(self.slots)):
|
||||
self.slots[i].resize(heights[i], self.width, offsets[i])
|
||||
def resize_mini(self, n):
|
||||
self.mini_height = n
|
||||
|
@ -128,13 +128,13 @@ class BufferList(object):
|
|||
return b
|
||||
return None
|
||||
def close_buffer(self, b):
|
||||
for i in range(0, len(self.slots)):
|
||||
for i in xrange(0, len(self.slots)):
|
||||
slot = self.slots[i]
|
||||
if slot.window is not None and slot.window.buffer is b:
|
||||
self.unset_slot(i)
|
||||
def remove_buffer(self, b):
|
||||
assert b in self.buffers, "buffer %s does not exist" % (b.name())
|
||||
for i in range(0, len(self.slots)):
|
||||
for i in xrange(0, len(self.slots)):
|
||||
slot = self.slots[i]
|
||||
if slot.window is not None and slot.window.buffer is b:
|
||||
self.unset_slot(i)
|
||||
|
|
10
color.py
10
color.py
|
@ -32,9 +32,9 @@ def add_color(name, value, abbrev):
|
|||
# assign every RGB triple (0-5) to one of six basic colors (red, yellow, green,
|
||||
# cyan, blue, magenta) based on some semi-arbitrary rules i came up with.
|
||||
def iter256():
|
||||
for r in range(0, 6):
|
||||
for g in range(0, 6):
|
||||
for b in range(0, 6):
|
||||
for r in xrange(0, 6):
|
||||
for g in xrange(0, 6):
|
||||
for b in xrange(0, 6):
|
||||
#if r >= 3 and g >= 3 and b >= 3: name = 'white'
|
||||
#elif r >= g and g > b: name = 'yellow'
|
||||
if r >= g and g > b: name = 'yellow'
|
||||
|
@ -90,13 +90,13 @@ def init():
|
|||
rev_ascii_map['default'] = 'd'
|
||||
|
||||
# add in hex aliases to 256 colors; used by color-data buffers
|
||||
for i in range(0, 256):
|
||||
for i in xrange(0, 256):
|
||||
name = 'f%02x' % i
|
||||
abbrev = 'f%02x' % i
|
||||
add_color(name, i, abbrev)
|
||||
|
||||
# create the 24 flavors of grey in 256 colors
|
||||
for i in range(0, 24):
|
||||
for i in xrange(0, 24):
|
||||
name2 = 'grey%d' % i
|
||||
abbrev2 = 'G%d' % i
|
||||
if curses.COLORS == 256:
|
||||
|
|
|
@ -19,12 +19,13 @@ class Context(object):
|
|||
return
|
||||
elif delta > 0:
|
||||
self.namelines.extend([(None, None)] * delta)
|
||||
for i in reversed(range(p.y + 1, len(self.mode.window.buffer.lines))):
|
||||
l = len(self.mode.window.buffer.lines)
|
||||
for i in reversed(xrange(p.y + 1, l)):
|
||||
self.namelines[i] = self.namelines[i - delta]
|
||||
for i in range(p.y, p.y + delta):
|
||||
for i in xrange(p.y, p.y + delta):
|
||||
self.namelines[i] = (None, None)
|
||||
else:
|
||||
for i in range(p.y + 1, len(self.mode.window.buffer.lines)):
|
||||
for i in xrange(p.y + 1, len(self.mode.window.buffer.lines)):
|
||||
self.namelines[i + delta] = self.namelines[i]
|
||||
|
||||
def _init_name_map(self):
|
||||
|
@ -56,7 +57,7 @@ class Context(object):
|
|||
return stack
|
||||
|
||||
def rebuild_name_map(self, y1, y2):
|
||||
for y in range(y1, y2):
|
||||
for y in xrange(y1, y2):
|
||||
(name, info) = self.namelines[y]
|
||||
self._del_name(y, name)
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ def path_fields(path, name):
|
|||
for bundle in ((stat.S_IRUSR, stat.S_IWUSR, stat.S_IXUSR),
|
||||
(stat.S_IRGRP, stat.S_IWGRP, stat.S_IXGRP),
|
||||
(stat.S_IROTH, stat.S_IWOTH, stat.S_IXOTH)):
|
||||
for j in range(0, 3):
|
||||
for j in xrange(0, 3):
|
||||
if info.st_mode & bundle[j]:
|
||||
perm[i] = symbols[j]
|
||||
else:
|
||||
|
|
26
highlight.py
26
highlight.py
|
@ -12,10 +12,10 @@ color_names = [
|
|||
color_dict ={}
|
||||
|
||||
def setup():
|
||||
color_list.extend(['\033[3%dm' % x for x in range(0, 8)])
|
||||
color_list.extend(['\033[3%d;1m' % x for x in range(0, 8)])
|
||||
color_list.extend(['\033[3%dm' % x for x in xrange(0, 8)])
|
||||
color_list.extend(['\033[3%d;1m' % x for x in xrange(0, 8)])
|
||||
color_list.extend(['\033[0m'])
|
||||
for i in range(0, len(color_list)):
|
||||
for i in xrange(0, len(color_list)):
|
||||
color_dict[color_names[i]] = color_list[i]
|
||||
setup()
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Highlighter(object):
|
|||
|
||||
def dump(self, fmt='(%3s, %2s) | %s'):
|
||||
print fmt % ('y', 'x', 'string')
|
||||
for i in range(0, len(self.tokens)):
|
||||
for i in xrange(0, len(self.tokens)):
|
||||
group = self.tokens[i]
|
||||
print 'LINE %d' % i
|
||||
for token in group:
|
||||
|
@ -37,7 +37,7 @@ class Highlighter(object):
|
|||
for token in group:
|
||||
color_name = None
|
||||
name_parts = token.name.split('.')
|
||||
for i in range(0, len(name_parts)):
|
||||
for i in xrange(0, len(name_parts)):
|
||||
if '.'.join(name_parts[i:]) in token_colors:
|
||||
color_name = token_colors['.'.join(name_parts[i:])]
|
||||
break
|
||||
|
@ -104,7 +104,7 @@ class Highlighter(object):
|
|||
except StopIteration:
|
||||
# ok, so this means that ALL the rest of the tokens didn't
|
||||
# show up, because we're done. so delete them and exit
|
||||
for j in range(y, len(lines)):
|
||||
for j in xrange(y, len(lines)):
|
||||
del self.tokens[j][i:]
|
||||
i = 0
|
||||
break
|
||||
|
@ -188,9 +188,9 @@ class Highlighter(object):
|
|||
|
||||
# ok, so now we need to "adjust" the (x,y) coordinates of all the tokens
|
||||
# after the change. first we will copy over the pre-deletion tokens.
|
||||
newtokens = [[] for _ in range(0, len(self.tokens) - y2 + y1)]
|
||||
newtokens = [[] for _ in xrange(0, len(self.tokens) - y2 + y1)]
|
||||
|
||||
for y in range(0, y1):
|
||||
for y in xrange(0, y1):
|
||||
for token in self.tokens[y]:
|
||||
newtokens[y].append(token)
|
||||
|
||||
|
@ -205,7 +205,7 @@ class Highlighter(object):
|
|||
newtokens[y1].append(token)
|
||||
|
||||
# finally, we will copy over the tokens from subsequent lines
|
||||
for y in range(y2 + 1, len(self.tokens)):
|
||||
for y in xrange(y2 + 1, len(self.tokens)):
|
||||
for token in self.tokens[y]:
|
||||
token.y = token.y - y2 + y1
|
||||
newtokens[y - y2 + y1].append(token)
|
||||
|
@ -242,11 +242,11 @@ class Highlighter(object):
|
|||
|
||||
# construct a new token data structure, with the right number of lines
|
||||
newtokens = []
|
||||
for i in range(0, len(self.tokens) + ydelta):
|
||||
for i in xrange(0, len(self.tokens) + ydelta):
|
||||
newtokens.append([])
|
||||
|
||||
# copy the tokens that show up before the changed line
|
||||
for y in range(0, y1):
|
||||
for y in xrange(0, y1):
|
||||
newtokens[y] = self.tokens[y]
|
||||
|
||||
# process the tokens that show up on the changed line
|
||||
|
@ -276,7 +276,7 @@ class Highlighter(object):
|
|||
|
||||
# add in the new data
|
||||
newtokens[y1].append(Token('new', '', y1, x1, newlines[0]))
|
||||
for i in range(1, len(newlines)):
|
||||
for i in xrange(1, len(newlines)):
|
||||
yi = y1 + i
|
||||
newtokens[yi].append(Token('new', '', yi, 0, newlines[i]))
|
||||
|
||||
|
@ -285,7 +285,7 @@ class Highlighter(object):
|
|||
newtokens[y2].append(t)
|
||||
|
||||
# for each subsequent line, fix it's tokens' y coordinates
|
||||
for y in range(y1 + 1, len(self.tokens)):
|
||||
for y in xrange(y1 + 1, len(self.tokens)):
|
||||
for t in self.tokens[y]:
|
||||
t.y += ydelta
|
||||
newtokens[t.y].append(t)
|
||||
|
|
|
@ -85,7 +85,7 @@ def setup():
|
|||
MAP[27][key] = "M-%s" % (MAP[key])
|
||||
|
||||
# add meta character stuff
|
||||
for i in range(33, 126):
|
||||
for i in xrange(33, 126):
|
||||
if i == 79 or i == 91:
|
||||
# these keys are used in other sequences
|
||||
continue
|
||||
|
@ -105,7 +105,7 @@ def disable_control_chars():
|
|||
|
||||
# remove as many signal handlers as we can; we want to leave C-d and C-z
|
||||
# probably
|
||||
for pos in range(0,len(attr[6])):
|
||||
for pos in xrange(0, len(attr[6])):
|
||||
if pos == termios.VEOF or pos == termios.VSUSP:
|
||||
continue
|
||||
attr[6][pos] = '\x00'
|
||||
|
|
|
@ -515,7 +515,7 @@ class TabBuffer(Method):
|
|||
def _execute(self, w, **vargs):
|
||||
y = w.logical_cursor().y
|
||||
it = InsertTab()
|
||||
for i in range(0, len(w.buffer.lines)):
|
||||
for i in xrange(0, len(w.buffer.lines)):
|
||||
w.goto_line(i + 1)
|
||||
it.execute(w)
|
||||
w.goto_line(y + 1)
|
||||
|
@ -548,7 +548,7 @@ class CommentRegion(Method):
|
|||
c = w.mode.commentc or '#'
|
||||
lvl = w.buffer.detect_indent_level(p1.y, p2.y) or 0
|
||||
|
||||
for y in range(p1.y, p2.y):
|
||||
for y in xrange(p1.y, p2.y):
|
||||
if len(w.buffer.lines[y]) < lvl:
|
||||
pad = lvl - len(w.buffer.lines[y])
|
||||
x = lvl - pad
|
||||
|
@ -574,7 +574,7 @@ class UncommentRegion(Method):
|
|||
commentc = w.mode.commentc or '#'
|
||||
commentre = re.compile('^( *)(%s)' % commentc)
|
||||
|
||||
for y in range(p1.y, p2.y):
|
||||
for y in xrange(p1.y, p2.y):
|
||||
line = w.buffer.lines[y]
|
||||
m = commentre.match(line)
|
||||
if not m:
|
||||
|
@ -839,7 +839,7 @@ class UnindentBlock(Method):
|
|||
w.input_line = "Empty kill region"
|
||||
return
|
||||
lines = w.buffer.lines[p1.y:p2.y]
|
||||
for i in range(0, len(lines)):
|
||||
for i in xrange(0, len(lines)):
|
||||
if lines[i].startswith(' '):
|
||||
lines[i] = lines[i][lvl:]
|
||||
w.buffer.delete(Point(0, p1.y), Point(0, p2.y))
|
||||
|
@ -859,7 +859,7 @@ class IndentBlock(Method):
|
|||
return
|
||||
lines = w.buffer.lines[p1.y:p2.y]
|
||||
tstr = ' ' * w.mode.tabwidth
|
||||
for i in range(0, len(lines)):
|
||||
for i in xrange(0, len(lines)):
|
||||
lines[i] = tstr + lines[i]
|
||||
w.buffer.delete(Point(0, p1.y), Point(0, p2.y))
|
||||
w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n')
|
||||
|
|
|
@ -13,7 +13,7 @@ class DumpContext(Method):
|
|||
def _execute(self, w, **vargs):
|
||||
lines = []
|
||||
if w.mode.context:
|
||||
for i in range(0, len(w.mode.context.namelines)):
|
||||
for i in xrange(0, len(w.mode.context.namelines)):
|
||||
lines.append("LINE %d: %r" % (i + 1, repr(w.mode.context.namelines[i])))
|
||||
else:
|
||||
lines.append("no context")
|
||||
|
@ -52,7 +52,7 @@ class DumpTokens(Method):
|
|||
lines = []
|
||||
if w.mode.name in w.buffer.highlights:
|
||||
tokens = w.buffer.highlights[w.mode.name].tokens
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
lines.append("LINE %d" % (i + 1))
|
||||
group = tokens[i]
|
||||
for token in group:
|
||||
|
|
|
@ -27,7 +27,7 @@ class VcBlame(Method):
|
|||
gsizes = [0] * self.num_fields
|
||||
for line in pipe.stdout:
|
||||
d = self._filter(line)
|
||||
for i in range(0, self.num_fields):
|
||||
for i in xrange(0, self.num_fields):
|
||||
gsizes[i] = max(gsizes[i], len(d['fields'][i]))
|
||||
groups.append(d)
|
||||
status = pipe.wait() >> 8
|
||||
|
|
|
@ -13,7 +13,7 @@ def proc(asttup):
|
|||
elif node[0] in token.tok_name:
|
||||
pairs.append((token.tok_name[node[0]], node[1]))
|
||||
else:
|
||||
for i in range(0, len(node) - 1):
|
||||
for i in xrange(0, len(node) - 1):
|
||||
queue.insert(i, node[i + 1])
|
||||
return pairs
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from lex import Grammar, PatternRule
|
|||
|
||||
class ColortestGrammar(Grammar):
|
||||
rules = []
|
||||
for i in range(0, 256):
|
||||
for i in xrange(0, 256):
|
||||
c = '%02x' % i
|
||||
rules.append(PatternRule('z' + c, c))
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class ConsoleTab(Method):
|
|||
|
||||
curr_t = None
|
||||
curr_i = None
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
t = tokens[i]
|
||||
if t.x < x and t.end_x() >= x:
|
||||
curr_i = i
|
||||
|
|
|
@ -41,12 +41,12 @@ class HexBackward(Method):
|
|||
class HexForwardWord(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
hf = w.application.methods['hex-forward']
|
||||
for i in range(0, w.buffer.wordsize * 2):
|
||||
for i in xrange(0, w.buffer.wordsize * 2):
|
||||
hf.execute(w, **vargs)
|
||||
class HexBackwardWord(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
hb = w.application.methods['hex-backward']
|
||||
for i in range(0, w.buffer.wordsize * 2):
|
||||
for i in xrange(0, w.buffer.wordsize * 2):
|
||||
hb.execute(w, **vargs)
|
||||
|
||||
class HexStartOfLine(Method):
|
||||
|
|
|
@ -33,7 +33,7 @@ class Pipe(Fundamental):
|
|||
continue
|
||||
del self.bindings[key]
|
||||
|
||||
for i in range(0, 128):
|
||||
for i in xrange(0, 128):
|
||||
if i in (22, 24, 27):
|
||||
continue
|
||||
sym = keyinput.MAP.get(i, chr(i))
|
||||
|
|
|
@ -136,7 +136,7 @@ class PythonTabber(tab.StackTabber):
|
|||
self.popped = True
|
||||
# ok, having done all that, we can now process each token
|
||||
# on the line
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
currlvl = self._handle_token(currlvl, y, i)
|
||||
# so let's store the level for this line, as well as some debugging
|
||||
self.lines[y] = currlvl
|
||||
|
@ -318,7 +318,7 @@ class PythonInsertTripleSquotes(Method):
|
|||
_q = "'''"
|
||||
def _execute(self, w, **vargs):
|
||||
w.insert_string_at_cursor('%s%s' % (self._q, self._q))
|
||||
for i in range(0, 3):
|
||||
for i in xrange(0, 3):
|
||||
w.backward()
|
||||
|
||||
class PythonInsertTripleDquotes(PythonInsertTripleSquotes):
|
||||
|
@ -510,7 +510,7 @@ class PythonContext(context.Context):
|
|||
if last is not None:
|
||||
curr = '.'.join([x[1] for x in stack])
|
||||
if curr:
|
||||
for k in range(last, i):
|
||||
for k in xrange(last, i):
|
||||
self.namelines[k] = (curr, None)
|
||||
last = None
|
||||
|
||||
|
@ -525,7 +525,7 @@ class PythonContext(context.Context):
|
|||
curr = '.'.join([x[1] for x in stack])
|
||||
self.names[curr] = i
|
||||
|
||||
for k in range(1, len(stack)):
|
||||
for k in xrange(1, len(stack)):
|
||||
curr = '.'.join(x[1] for x in stack[k:])
|
||||
if curr not in abbrev:
|
||||
abbrev[curr] = i
|
||||
|
@ -549,7 +549,7 @@ class PythonContext(context.Context):
|
|||
n = len(self.namelines[y2][0].split('.'))
|
||||
curr = '.'.join([x[1] for x in stack[:n]])
|
||||
if curr:
|
||||
for k in range(last, y2):
|
||||
for k in xrange(last, y2):
|
||||
self.namelines[k] = (curr, None)
|
||||
|
||||
# white is for delimiters, operators, numbers
|
||||
|
|
|
@ -75,7 +75,7 @@ class ShellTab(Method):
|
|||
|
||||
curr_t = None
|
||||
curr_i = None
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
t = tokens[i]
|
||||
if t.x < x and t.end_x() >= x:
|
||||
curr_i = i
|
||||
|
|
4
parse.py
4
parse.py
|
@ -113,12 +113,12 @@ class Repeat(Rule):
|
|||
self.maximum = maximum
|
||||
def match(self, tokens):
|
||||
n = 0
|
||||
for _ in range(0, self.minimum):
|
||||
for _ in xrange(0, self.minimum):
|
||||
result = self.rule.match(tokens[n:])
|
||||
if not result:
|
||||
return []
|
||||
n += result[0]
|
||||
for _ in range(self.minimum, self.maximum):
|
||||
for _ in xrange(self.minimum, self.maximum):
|
||||
result = self.rule.match(tokens[n:])
|
||||
if not result:
|
||||
return [n]
|
||||
|
|
|
@ -46,7 +46,7 @@ def find(r, w, move=False, direction='next', start=None, end=None):
|
|||
c = w.logical_cursor()
|
||||
newc = None
|
||||
ranges = find_ranges(r, w, start, end)
|
||||
indices = range(0, len(ranges))
|
||||
indices = list(xrange(0, len(ranges)))
|
||||
(x, y) = c.xy()
|
||||
if move:
|
||||
offset = 1
|
||||
|
|
20
tab.py
20
tab.py
|
@ -35,14 +35,14 @@ class Tabber(object):
|
|||
def get_next_left_token(self, y, i):
|
||||
tokens = self.get_tokens(y)
|
||||
assert i >= 0 and i < len(tokens)
|
||||
for j in range(1, i):
|
||||
for j in xrange(1, i):
|
||||
if not self.token_is_whitespace(y, i - j):
|
||||
return tokens[i - j]
|
||||
return None
|
||||
def get_next_right_token(self, y, i):
|
||||
tokens = self.get_tokens(y)
|
||||
assert i >= 0 and i < len(tokens)
|
||||
for j in range(i + 1, len(tokens)):
|
||||
for j in xrange(i + 1, len(tokens)):
|
||||
if not self.token_is_whitespace(y, j):
|
||||
return tokens[j]
|
||||
return None
|
||||
|
@ -55,27 +55,27 @@ class Tabber(object):
|
|||
|
||||
def get_leftmost_token(self, y):
|
||||
tokens = self.get_tokens(y)
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
if not self.token_is_whitespace(y, i):
|
||||
return tokens[i]
|
||||
return None
|
||||
def get_rightmost_token(self, y):
|
||||
tokens = self.get_tokens(y)
|
||||
i = len(tokens) - 1
|
||||
for j in range(0, len(tokens)):
|
||||
for j in xrange(0, len(tokens)):
|
||||
if not self.token_is_whitespace(y, i - j):
|
||||
return tokens[i - j]
|
||||
return None
|
||||
|
||||
def get_nonws_tokens(self, y):
|
||||
tokens = self.get_tokens(y)
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
if not self.token_is_whitespace(y, i):
|
||||
yield tokens[i]
|
||||
raise StopIteration
|
||||
def get_nons_tokens(self, y):
|
||||
tokens = self.get_tokens(y)
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
if not self.token_is_space(y, i):
|
||||
yield tokens[i]
|
||||
raise StopIteration
|
||||
|
@ -133,7 +133,7 @@ class StackTabber(Tabber):
|
|||
while y <= target:
|
||||
currlvl = self.get_curr_level()
|
||||
tokens = self.get_tokens(y)
|
||||
for i in range(0, len(tokens)):
|
||||
for i in xrange(0, len(tokens)):
|
||||
currlvl = self._handle_token(currlvl, y, i)
|
||||
self.lines[y] = currlvl
|
||||
self.record[y] = tuple(self.markers)
|
||||
|
@ -189,7 +189,7 @@ class StackTabber(Tabber):
|
|||
else:
|
||||
return None
|
||||
def _peek_until(self, *names):
|
||||
for i in range(1, len(self.markers) + 1):
|
||||
for i in xrange(1, len(self.markers) + 1):
|
||||
x = self.markers[-i]
|
||||
if x.name in names:
|
||||
return x
|
||||
|
@ -325,7 +325,7 @@ class StackTabber2(Tabber):
|
|||
else:
|
||||
return None
|
||||
def _peek_until(self, *names):
|
||||
for i in range(1, len(self.stack) + 1):
|
||||
for i in xrange(1, len(self.stack) + 1):
|
||||
x = self.stack[-i]
|
||||
if x.name in names:
|
||||
return x
|
||||
|
@ -342,7 +342,7 @@ class StackTabber2(Tabber):
|
|||
while end > 0 and self._is_ignored(tokens[end]):
|
||||
end -= 1
|
||||
|
||||
for i in range(0, end + 1 - start):
|
||||
for i in xrange(0, end + 1 - start):
|
||||
t = tokens[start + i]
|
||||
if self._is_ignored(t):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue