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