parent
b1512f9150
commit
077417a363
|
@ -39,7 +39,7 @@ ERROR_TIMEOUT = -1
|
|||
#DARK_BACKGROUND = False
|
||||
DARK_BACKGROUND = True
|
||||
|
||||
class Application:
|
||||
class Application(object):
|
||||
def __init__(self, stdscr, buffers=[], jump_to_line=None, init_mode=None):
|
||||
# initalize curses primitives
|
||||
self.stdscr = stdscr
|
||||
|
@ -212,7 +212,7 @@ class Application:
|
|||
"invalid slot: %r (%r)" % (n, len(self.bufferlist.slots))
|
||||
self.bufferlist.remove_slot(n)
|
||||
if self.active_slot > slotname:
|
||||
self.active_slot = max(0, self.active_slot - 1)
|
||||
self.active_slot = max(0, self.active_slot - 1) #XYZ
|
||||
def single_slot(self):
|
||||
while len(self.bufferlist.slots) > 1:
|
||||
if self.active_slot == 0:
|
||||
|
@ -256,7 +256,7 @@ class Application:
|
|||
# window handling
|
||||
def toggle_window(self):
|
||||
assert 0 <= self.active_slot and self.active_slot < len(self.bufferlist.slots)
|
||||
self.active_slot = (self.active_slot + 1) % len(self.bufferlist.slots)
|
||||
self.active_slot = (self.active_slot + 1) % len(self.bufferlist.slots) #XYZ
|
||||
def window(self):
|
||||
return self.bufferlist.slots[self.active_slot].window
|
||||
def active_window(self):
|
||||
|
@ -451,6 +451,11 @@ class Application:
|
|||
self.draw_status_bar(i)
|
||||
|
||||
def draw_slot(self, i):
|
||||
#assert len(self.bufferlist.slots) == 1, "only one"
|
||||
assert self.active_slot < len(self.bufferlist.slots), "only two"
|
||||
assert i < len(self.bufferlist.slots), "only three"
|
||||
#assert i == 0, "only four"
|
||||
|
||||
slot = self.bufferlist.slots[i]
|
||||
if slot.window is None:
|
||||
return
|
||||
|
@ -488,8 +493,8 @@ class Application:
|
|||
|
||||
fqlist = token.fqlist()
|
||||
c = w.mode.default_color
|
||||
for i in range(0, len(fqlist)):
|
||||
name = '.'.join(fqlist[i:])
|
||||
for j in range(0, len(fqlist)):
|
||||
name = '.'.join(fqlist[j:])
|
||||
if name in w.mode.colors:
|
||||
c = w.mode.colors[name]
|
||||
break
|
||||
|
@ -511,7 +516,6 @@ class Application:
|
|||
else:
|
||||
x += slot.width
|
||||
count += 1
|
||||
self.win.addch(slot.offset, 0, 'N', curses.A_REVERSE)
|
||||
|
||||
if self.margins_visible:
|
||||
for (limit, shade) in self.margins:
|
||||
|
@ -523,14 +527,9 @@ class Application:
|
|||
char = self.win.inch(j + slot.offset, limit) & 255
|
||||
attr = color.build('default', shade, 'bold')
|
||||
self.win.addch(j + slot.offset, limit, char, attr)
|
||||
self.win.addch(slot.offset, 0, 'O', curses.A_REVERSE)
|
||||
assert self.mini_active is False and self.active_slot == i, \
|
||||
'%r %d (%d)' % (self.mini_active, self.active_slot, i)
|
||||
|
||||
if self.mini_active is False and self.active_slot == i:
|
||||
self.win.addch(slot.offset, 0, 'P', curses.A_REVERSE)
|
||||
if False and w.active_point is not None and w.point_is_visible(w.active_point):
|
||||
raise Exception, "no way man"
|
||||
pa = w.physical_point(w.active_point)
|
||||
va = pa.offset(0, -w.visible_offset())
|
||||
if len(lines[va.y]):
|
||||
|
@ -540,21 +539,17 @@ class Application:
|
|||
self.win.addch(va.y + slot.offset, va.x, a, curses.A_REVERSE)
|
||||
else:
|
||||
assert px is not None and py is not None
|
||||
self.win.addch(slot.offset, 0, 'Q', curses.A_REVERSE)
|
||||
|
||||
if cy >= len(lines):
|
||||
assert False
|
||||
self.set_error('in main1: cursor error; %d >= %d' % (cy, len(lines)))
|
||||
return
|
||||
elif cx == len(lines[cy]):
|
||||
c = ' '
|
||||
elif px > len(lines[cy]):
|
||||
assert False
|
||||
self.set_error('why? %r %r' % (cx, len(lines[cy])))
|
||||
return
|
||||
else:
|
||||
c = lines[cy][cx]
|
||||
c = 'X'
|
||||
self.win.addch(slot.offset + py , px, c, curses.A_REVERSE)
|
||||
|
||||
def draw_status_bar(self, slotname):
|
||||
|
|
|
@ -234,8 +234,8 @@ class Buffer(object):
|
|||
|
||||
# insertion into buffer
|
||||
def insert_lines(self, p, lines, act=ACT_NORM, force=False):
|
||||
if lines == ['(']:
|
||||
raise Exception, "damn"
|
||||
#if lines == ['(']:
|
||||
# raise Exception, "damn"
|
||||
llen = len(lines)
|
||||
assert llen > 0
|
||||
if not force:
|
||||
|
|
|
@ -67,13 +67,16 @@ class BufferList:
|
|||
|
||||
# manipulate slots
|
||||
def add_slot(self):
|
||||
assert len(self.slots) == 0, "fuck"
|
||||
self.slots.append(Slot(self.height, self.width, 0))
|
||||
self.fit_slots()
|
||||
return len(self.slots) - 1
|
||||
def empty_slot(self, i):
|
||||
assert len(self.slots) == 0, "fuck"
|
||||
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||
return self.slots[i].is_empty()
|
||||
def unset_slot(self, i):
|
||||
assert len(self.slots) == 1, "fuck"
|
||||
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||
old_w = self.slots[i].unset()
|
||||
if old_w is not None:
|
||||
|
@ -84,6 +87,7 @@ class BufferList:
|
|||
old_b.remove_window(old_w)
|
||||
|
||||
def set_slot(self, i, b):
|
||||
assert len(self.slots) == 1, "fuck"
|
||||
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||
assert b in self.buffers, "buffer %s does not exist" % (b.name())
|
||||
slot = self.slots[i]
|
||||
|
@ -99,6 +103,7 @@ class BufferList:
|
|||
slot.set(w)
|
||||
|
||||
def remove_slot(self, i):
|
||||
assert False, "fuck"
|
||||
assert i > -1 and i < len(self.slots), "slot %d does not exist" % i
|
||||
self.unset_slot(i)
|
||||
del self.slots[i]
|
||||
|
|
|
@ -56,7 +56,6 @@ pre-populates the MQs with any pre-existing data. For group questions, the
|
|||
DataIntegrator determines how many instances of the question should be displayed
|
||||
and what id_users are be associated with each instance.
|
||||
|
||||
|
||||
=item new($bnode)
|
||||
|
||||
Constructor
|
||||
|
|
|
@ -172,6 +172,8 @@ class Highlighter:
|
|||
else:
|
||||
ctoken = None
|
||||
while not done:
|
||||
if y >= len(self.tokens):
|
||||
break
|
||||
if i < len(self.tokens[y]):
|
||||
# figure out if this token is in our range. notice that
|
||||
# delete_token() will take care of the need to recursively
|
||||
|
|
62
lex2_perl.py
62
lex2_perl.py
|
@ -181,18 +181,6 @@ class PerlGrammar(Grammar):
|
|||
name=r'deref',
|
||||
pattern=r"[@%\$&\*](?={)",
|
||||
),
|
||||
RegionRule(
|
||||
name=r'quoted',
|
||||
start=r'q[rqwx]? *(?P<delim>[^ #])',
|
||||
grammar=Grammar(),
|
||||
end=r'%(delim)s',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'quoted',
|
||||
start=r'q[rqwx]?#',
|
||||
grammar=Grammar(),
|
||||
end=r'#',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'quoted',
|
||||
start=r'q[rqwx]? *\(',
|
||||
|
@ -217,6 +205,18 @@ class PerlGrammar(Grammar):
|
|||
grammar=Grammar(),
|
||||
end=r'\]',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'quoted',
|
||||
start=r'q[rqwx]? *(?P<delim>[^ #])',
|
||||
grammar=Grammar(),
|
||||
end=r'%(delim)s',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'quoted',
|
||||
start=r'q[rqwx]?#',
|
||||
grammar=Grammar(),
|
||||
end=r'#',
|
||||
),
|
||||
|
||||
# match regexes
|
||||
RegionRule(
|
||||
|
@ -312,25 +312,25 @@ class PerlGrammar(Grammar):
|
|||
pattern=r"(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*(?=->)",
|
||||
),
|
||||
|
||||
# nested regions
|
||||
RegionRule(
|
||||
name=r'paren',
|
||||
start=r'\(',
|
||||
grammar=None,
|
||||
end=r'\)',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'brace',
|
||||
start=r'{',
|
||||
grammar=None,
|
||||
end=r'}',
|
||||
),
|
||||
RegionRule(
|
||||
name=r'bracket',
|
||||
start=r'\[',
|
||||
grammar=None,
|
||||
end=r'\]',
|
||||
),
|
||||
# # nested regions
|
||||
# RegionRule(
|
||||
# name=r'paren',
|
||||
# start=r'\(',
|
||||
# grammar=None,
|
||||
# end=r'\)',
|
||||
# ),
|
||||
# RegionRule(
|
||||
# name=r'brace',
|
||||
# start=r'{',
|
||||
# grammar=None,
|
||||
# end=r'}',
|
||||
# ),
|
||||
# RegionRule(
|
||||
# name=r'bracket',
|
||||
# start=r'\[',
|
||||
# grammar=None,
|
||||
# end=r'\]',
|
||||
# ),
|
||||
|
||||
# some basic stuff
|
||||
PatternRule(
|
||||
|
|
|
@ -9,7 +9,8 @@ class Python(mode2.Fundamental):
|
|||
def __init__(self, w):
|
||||
mode2.Fundamental.__init__(self, w)
|
||||
|
||||
self.tag_matching = True
|
||||
#self.tag_matching = True
|
||||
self.tag_matching = False
|
||||
self.grammar = lex2_python.PythonGrammar()
|
||||
self.lexer = lex2.Lexer(self.name(), self.grammar)
|
||||
|
||||
|
@ -18,9 +19,9 @@ class Python(mode2.Fundamental):
|
|||
self.add_action_and_bindings(PythonUpdateTags(), ('C-c t',))
|
||||
self.add_action_and_bindings(PythonTagComplete(), ('C-c k',))
|
||||
|
||||
self.add_bindings('close-paren', (')',))
|
||||
self.add_bindings('close-brace', ('}',))
|
||||
self.add_bindings('close-bracket', (']',))
|
||||
#self.add_bindings('close-paren', (')',))
|
||||
#self.add_bindings('close-brace', ('}',))
|
||||
#self.add_bindings('close-bracket', (']',))
|
||||
|
||||
self.default_color = color.build('default', 'default')
|
||||
|
||||
|
|
Loading…
Reference in New Issue