From 81b84b24e1f0e1a827847007d92a383c030a897b Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 17 Jul 2007 11:14:21 +0000 Subject: [PATCH] dynamically-parsed nested regions seem to work!!!! holy shit!!! --HG-- branch : pmacs2 --- application.py | 16 +------ code_examples/Reporting2.pm | 4 +- lex3.py | 86 ++++++++++++++++++++++++++----------- mode2.py | 12 ++++++ mode_perl.py | 5 ++- 5 files changed, 79 insertions(+), 44 deletions(-) diff --git a/application.py b/application.py index 1a15b13..e148554 100755 --- a/application.py +++ b/application.py @@ -579,18 +579,6 @@ class Application(object): x += slot.width count += 1 - def _get_token_color(self, w, token): - fqlist = token.fqlist() - c = w.mode.default_color - for j in range(0, len(fqlist)): - name = '.'.join(fqlist[j:]) - if name in w.mode.colors: - c = w.mode.colors[name] - break - if DARK_BACKGROUND: - c |= curses.A_BOLD - return c - def _draw_slot_lit(self, i): slot = self.bufferlist.slots[i] w = slot.window @@ -617,12 +605,10 @@ class Application(object): x_offset = max(token.x - x, 0) assert x_offset <= slot.width, '%d <= %d' % (x_offset, slot.width) - c = self._get_token_color(w, token) - #s = token.string[s_offset:] s = tstring[s_offset:] token_done = x_offset + len(s) <= slot.width token_wrap = x_offset + len(s) > slot.width - self.win.addstr(slot.offset + count, x_offset, s[:slot.width - x_offset], c) + self.win.addstr(slot.offset + count, x_offset, s[:slot.width - x_offset], token.color) if token_wrap: self.win.addch(slot.offset + count, slot.width, '\\', redattr) diff --git a/code_examples/Reporting2.pm b/code_examples/Reporting2.pm index b0a22a5..18ad6a0 100644 --- a/code_examples/Reporting2.pm +++ b/code_examples/Reporting2.pm @@ -7,11 +7,13 @@ sub foo { unless 9 && 3; } -#@@:heredoc:mode_sql.SqlGrammar +#@@:heredoc:mode_sql.Sql my $s = <[.a-zA-Z0-9_]+):(?P[.a-zA-Z0-9_]+) *$'), + OverridePatternRule(r'comment', r'#@@:(?P[.a-zA-Z0-9_]+):(?P[.a-zA-Z0-9_]+) *$'), PatternRule(r'comment', r'#.*$'), RegionRule(r'string', r'"', StringGrammar, r'"'), RegionRule(r'string', r"'", Grammar, r"'"), @@ -165,6 +165,7 @@ class Perl(mode2.Fundamental): opentags = {'(': ')', '[': ']', '{': '}'} closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} + def __init__(self, w): mode2.Fundamental.__init__(self, w) @@ -212,7 +213,7 @@ class Perl(mode2.Fundamental): 'use': color.build('cyan', 'default'), 'require': color.build('cyan', 'default'), 'method': color.build('cyan', 'default'), - + # heredoc/evaldoc 'heredoc.start': color.build('green', 'default'), 'heredoc.null': color.build('green', 'default'),