parent
b134fed9e9
commit
f6c0e57e11
8
lex.py
8
lex.py
|
@ -128,8 +128,9 @@ class NocasePatternRule(PatternRule):
|
||||||
reflags = re.IGNORECASE
|
reflags = re.IGNORECASE
|
||||||
|
|
||||||
class FakeWindow(object):
|
class FakeWindow(object):
|
||||||
def __init__(self, app):
|
def __init__(self, app, b):
|
||||||
self.application = app
|
self.application = app
|
||||||
|
self.buffer = b
|
||||||
class OverrideError(Exception):
|
class OverrideError(Exception):
|
||||||
pass
|
pass
|
||||||
class OverridePatternRule(PatternRule):
|
class OverridePatternRule(PatternRule):
|
||||||
|
@ -139,13 +140,16 @@ class OverridePatternRule(PatternRule):
|
||||||
if lexer.action == 'lex':
|
if lexer.action == 'lex':
|
||||||
a = lexer.mode.window.application
|
a = lexer.mode.window.application
|
||||||
try:
|
try:
|
||||||
|
b = lexer.mode.window.buffer
|
||||||
modecls = a.modes[d['mode']]
|
modecls = a.modes[d['mode']]
|
||||||
mode = modecls(FakeWindow(lexer.mode.window.application))
|
mode = modecls(FakeWindow(lexer.mode.window.application, b))
|
||||||
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
|
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
|
||||||
lexer.mode.gstack['%s' % d['token']] = mode
|
lexer.mode.gstack['%s' % d['token']] = mode
|
||||||
else:
|
else:
|
||||||
raise OverrideError("argh: %r" % mode)
|
raise OverrideError("argh: %r" % mode)
|
||||||
except (KeyError, AttributeError, OverrideError):
|
except (KeyError, AttributeError, OverrideError):
|
||||||
|
# uncomment raise to fix dynamic highlighting
|
||||||
|
#raise
|
||||||
pass
|
pass
|
||||||
yield self.make_token(lexer, m.group(0), self.name, parent, d)
|
yield self.make_token(lexer, m.group(0), self.name, parent, d)
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
Loading…
Reference in New Issue