pmacs3/mode/ipython.py

24 lines
802 B
Python

import color, mode
from lex import Grammar, PatternRule, RegionRule
from mode.python import StringGrammar, PythonGrammar
class IpythonGrammar(Grammar):
rules = [
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
RegionRule(r'ipython_input', r'^(?:>>>|\.\.>)', PythonGrammar, '\n$'),
PatternRule(r'ipython_reserved', r'undef'),
]
class Ipython(mode.Fundamental):
modename = 'IPython'
grammar = IpythonGrammar()
colors = {
'ipython_input.start': ('red', 'default', 'bold'),
'ipython_reserved': ('magenta', 'default', 'bold'),
}
def __init__(self, w):
mode.Fundamental.__init__(self, w)
self.add_bindings('ipython-start', ('M-e',))
install = Ipython.install