parent
e81712afc1
commit
dd780d2f7e
|
@ -492,10 +492,8 @@ class GetIndentionLevel(Method):
|
||||||
w.set_error('Indention level: %r' % i)
|
w.set_error('Indention level: %r' % i)
|
||||||
|
|
||||||
# commenting
|
# commenting
|
||||||
# commenting in python
|
|
||||||
class CommentRegion(Method):
|
class CommentRegion(Method):
|
||||||
'''Prepend a comment to every line in the current buffer'''
|
'''Prepend a comment to every line in the current buffer'''
|
||||||
commentc = '#'
|
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
cursor = w.logical_cursor()
|
cursor = w.logical_cursor()
|
||||||
if cursor < w.mark:
|
if cursor < w.mark:
|
||||||
|
@ -508,16 +506,17 @@ class CommentRegion(Method):
|
||||||
w.input_line = "Empty kill region"
|
w.input_line = "Empty kill region"
|
||||||
return
|
return
|
||||||
|
|
||||||
|
commentc = w.mode.commentc or '#'
|
||||||
|
|
||||||
x = w.buffer.detect_indent_level(p1.y, p2.y) or 0
|
x = w.buffer.detect_indent_level(p1.y, p2.y) or 0
|
||||||
for y in range(p1.y, p2.y):
|
for y in range(p1.y, p2.y):
|
||||||
c = self.commentc
|
c = commentc
|
||||||
if len(w.buffer.lines[y]) < x:
|
if len(w.buffer.lines[y]) < x:
|
||||||
c += ' ' * (x - len(w.buffer.lines[y]))
|
c += ' ' * (x - len(w.buffer.lines[y]))
|
||||||
w.buffer.insert_string(Point(x, y), c)
|
w.buffer.insert_string(Point(x, y), c)
|
||||||
|
|
||||||
class UncommentRegion(Method):
|
class UncommentRegion(Method):
|
||||||
'''Remove a comment from every line in the current buffer'''
|
'''Remove a comment from every line in the current buffer'''
|
||||||
commentre = re.compile('^( *)(#+)')
|
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
cursor = w.logical_cursor()
|
cursor = w.logical_cursor()
|
||||||
if cursor < w.mark:
|
if cursor < w.mark:
|
||||||
|
@ -530,9 +529,12 @@ class UncommentRegion(Method):
|
||||||
w.input_line = "Empty kill region"
|
w.input_line = "Empty kill region"
|
||||||
return
|
return
|
||||||
|
|
||||||
|
commentc = w.mode.commentc or '#'
|
||||||
|
commentre = re.compile('^( *)((?:%s)+)' % commentc)
|
||||||
|
|
||||||
for y in range(p1.y, p2.y):
|
for y in range(p1.y, p2.y):
|
||||||
line = w.buffer.lines[y]
|
line = w.buffer.lines[y]
|
||||||
m = self.commentre.match(line)
|
m = commentre.match(line)
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
continue
|
||||||
s1, s2 = m.groups()
|
s1, s2 = m.groups()
|
||||||
|
|
|
@ -32,11 +32,12 @@ class Handler(object):
|
||||||
del self.bindings[binding]
|
del self.bindings[binding]
|
||||||
def add_binding(self, name, sequence):
|
def add_binding(self, name, sequence):
|
||||||
if self.window is None:
|
if self.window is None:
|
||||||
return
|
#return
|
||||||
|
raise Exception("No window available")
|
||||||
elif not hasattr(self.window, 'application'):
|
elif not hasattr(self.window, 'application'):
|
||||||
raise Exception, "argh %r %r" % (self, self.window)
|
raise Exception("No application available")
|
||||||
elif name not in self.window.application.methods:
|
elif name not in self.window.application.methods:
|
||||||
raise Exception, "No action called %r found" % name
|
raise Exception("No action called %r found" % name)
|
||||||
else:
|
else:
|
||||||
self.bindings[sequence] = name
|
self.bindings[sequence] = name
|
||||||
def add_bindings(self, name, sequences):
|
def add_bindings(self, name, sequences):
|
||||||
|
@ -89,6 +90,7 @@ class Fundamental(Handler):
|
||||||
context = None
|
context = None
|
||||||
colors = {}
|
colors = {}
|
||||||
word_letters = None
|
word_letters = None
|
||||||
|
commentc = None
|
||||||
|
|
||||||
# config settings installed/modified by the mode
|
# config settings installed/modified by the mode
|
||||||
config = {}
|
config = {}
|
||||||
|
@ -97,6 +99,7 @@ class Fundamental(Handler):
|
||||||
sconfig = {}
|
sconfig = {}
|
||||||
|
|
||||||
actions = []
|
actions = []
|
||||||
|
_bindings = {}
|
||||||
completers = {}
|
completers = {}
|
||||||
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s"
|
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s"
|
||||||
|
|
||||||
|
@ -151,6 +154,7 @@ class Fundamental(Handler):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
app.methods[m.name] = m
|
app.methods[m.name] = m
|
||||||
|
|
||||||
for (datatype, completer) in cls.completers.iteritems():
|
for (datatype, completer) in cls.completers.iteritems():
|
||||||
app.set_completer(datatype, completer)
|
app.set_completer(datatype, completer)
|
||||||
install = classmethod(install)
|
install = classmethod(install)
|
||||||
|
@ -264,6 +268,10 @@ class Fundamental(Handler):
|
||||||
for c in string.letters + string.digits + string.punctuation:
|
for c in string.letters + string.digits + string.punctuation:
|
||||||
self.add_binding('insert-string-%s' % c, c)
|
self.add_binding('insert-string-%s' % c, c)
|
||||||
|
|
||||||
|
# per-mode bindings
|
||||||
|
for (name, sequences) in self._bindings.iteritems():
|
||||||
|
self.add_bindings(name, sequences)
|
||||||
|
|
||||||
# lexing for highlighting, etc.
|
# lexing for highlighting, etc.
|
||||||
if self.grammar:
|
if self.grammar:
|
||||||
self.lexer = Lexer(self, self.grammar)
|
self.lexer = Lexer(self, self.grammar)
|
||||||
|
@ -405,7 +413,6 @@ class Fundamental(Handler):
|
||||||
return '%d%s' % (b.indentlvl, t)
|
return '%d%s' % (b.indentlvl, t)
|
||||||
def _get_mark(self):
|
def _get_mark(self):
|
||||||
w = self.window
|
w = self.window
|
||||||
return '(%d,%d)' % (w.first.y + 1, w.first.x + 1),
|
|
||||||
if w.mark:
|
if w.mark:
|
||||||
return '(%d,%d)' % (w.mark.y + 1, w.mark.x + 1)
|
return '(%d,%d)' % (w.mark.y + 1, w.mark.x + 1)
|
||||||
else:
|
else:
|
||||||
|
|
22
mode/awk.py
22
mode/awk.py
|
@ -132,10 +132,16 @@ class AwkFilterInput(Method):
|
||||||
|
|
||||||
class Awk(mode.Fundamental):
|
class Awk(mode.Fundamental):
|
||||||
tabbercls = AwkTabber
|
tabbercls = AwkTabber
|
||||||
modename = 'awk'
|
modename = 'awk'
|
||||||
extensions = ['.awk']
|
extensions = ['.awk']
|
||||||
grammar = AwkGrammar
|
grammar = AwkGrammar
|
||||||
colors = {
|
opentokens = ('delimiter',)
|
||||||
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
|
closetokens = ('delimiter',)
|
||||||
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
|
config = {'awk.cmd-opts': ""}
|
||||||
|
actions = [AwkFilterFile, AwkFilterBuffer, AwkFilterInput]
|
||||||
|
colors = {
|
||||||
'awk_global': ('yellow', 'default', 'bold'),
|
'awk_global': ('yellow', 'default', 'bold'),
|
||||||
'awk_function': ('magenta', 'default', 'bold'),
|
'awk_function': ('magenta', 'default', 'bold'),
|
||||||
'awk_field': ('yellow', 'default', 'bold'),
|
'awk_field': ('yellow', 'default', 'bold'),
|
||||||
|
@ -145,7 +151,9 @@ class Awk(mode.Fundamental):
|
||||||
'awk_regex.data': ('cyan', 'default', 'bold'),
|
'awk_regex.data': ('cyan', 'default', 'bold'),
|
||||||
'awk_regex.end': ('cyan', 'default', 'bold'),
|
'awk_regex.end': ('cyan', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
config = {'awk.cmd-opts': ""}
|
_bindings = {
|
||||||
actions = [AwkFilterFile, AwkFilterBuffer, AwkFilterInput]
|
'close-paren': (')',),
|
||||||
|
'close-brace': ('}',),
|
||||||
|
'close-bracket': (']',),
|
||||||
|
}
|
||||||
install = Awk.install
|
install = Awk.install
|
||||||
|
|
21
mode/c.py
21
mode/c.py
|
@ -137,6 +137,10 @@ class C(mode.Fundamental):
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
|
actions = [CCheckSyntax, CMake]
|
||||||
|
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(func)s]"
|
||||||
|
commentc = '//'
|
||||||
|
|
||||||
colors = {
|
colors = {
|
||||||
'macrocomment.start': ('red', 'default', 'bold'),
|
'macrocomment.start': ('red', 'default', 'bold'),
|
||||||
'macrocomment.null': ('red', 'default', 'bold'),
|
'macrocomment.null': ('red', 'default', 'bold'),
|
||||||
|
@ -170,9 +174,14 @@ class C(mode.Fundamental):
|
||||||
lconfig = {
|
lconfig = {
|
||||||
'ignore-suffix': ['.o'],
|
'ignore-suffix': ['.o'],
|
||||||
}
|
}
|
||||||
actions = [CCheckSyntax, CMake]
|
|
||||||
|
|
||||||
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(func)s]"
|
_bindings = {
|
||||||
|
'close-paren': (')',),
|
||||||
|
'close-brace': ('}',),
|
||||||
|
'close-bracket': (']',),
|
||||||
|
'c-check-syntax': ('C-c s',),
|
||||||
|
'c-make': ('C-c C-c',),
|
||||||
|
}
|
||||||
|
|
||||||
def get_status_names(self):
|
def get_status_names(self):
|
||||||
names = mode.Fundamental.get_status_names(self)
|
names = mode.Fundamental.get_status_names(self)
|
||||||
|
@ -180,14 +189,6 @@ class C(mode.Fundamental):
|
||||||
names['func'] = self.get_line_function(c.y)
|
names['func'] = self.get_line_function(c.y)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def __init__(self, w):
|
|
||||||
mode.Fundamental.__init__(self, w)
|
|
||||||
self.add_bindings('close-paren', (')',))
|
|
||||||
self.add_bindings('close-brace', ('}',))
|
|
||||||
self.add_bindings('close-bracket', (']',))
|
|
||||||
self.add_bindings('c-check-syntax', ('C-c s',))
|
|
||||||
self.add_bindings('c-make', ('C-c C-c',))
|
|
||||||
|
|
||||||
def get_functions(self):
|
def get_functions(self):
|
||||||
return {}
|
return {}
|
||||||
def get_function_names(self):
|
def get_function_names(self):
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Template(mode.Fundamental):
|
||||||
modename = 'Cheetah'
|
modename = 'Cheetah'
|
||||||
extensions = ['.tmpl']
|
extensions = ['.tmpl']
|
||||||
grammar = TemplateGrammar
|
grammar = TemplateGrammar
|
||||||
|
commentc = '##'
|
||||||
colors = {
|
colors = {
|
||||||
'cheetah_directive': ('magenta', 'default', 'bold'),
|
'cheetah_directive': ('magenta', 'default', 'bold'),
|
||||||
'cheetah_placeholder': ('magenta', 'default', 'bold'),
|
'cheetah_placeholder': ('magenta', 'default', 'bold'),
|
||||||
|
@ -48,10 +49,10 @@ class Template(mode.Fundamental):
|
||||||
'cheetah_tag.string.end': ('green', 'default', 'bold'),
|
'cheetah_tag.string.end': ('green', 'default', 'bold'),
|
||||||
'cheetah_tag.end': ('default', 'default', 'bold'),
|
'cheetah_tag.end': ('default', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
|
|
||||||
install = Template.install
|
install = Template.install
|
||||||
|
|
|
@ -2,23 +2,7 @@ import color, mode
|
||||||
from lex import Grammar, PatternRule, RegionRule
|
from lex import Grammar, PatternRule, RegionRule
|
||||||
from mode.python import StringGrammar1, StringGrammar2, PythonGrammar
|
from mode.python import StringGrammar1, StringGrammar2, PythonGrammar
|
||||||
|
|
||||||
#class ConsoleGrammar(Grammar):
|
|
||||||
# rules = [
|
|
||||||
# RegionRule(r'string', r'"', StringGrammar2, r'"'),
|
|
||||||
# RegionRule(r'string', r"'", StringGrammar1, r"'"),
|
|
||||||
# RegionRule(r'console_input', r'^(?:>>>|-->)', PythonGrammar, '\n$'),
|
|
||||||
# PatternRule(r'console_mesg', r'^[A-Za-z].*$'),
|
|
||||||
# PatternRule(r'console_reserved', r'True|False|None'),
|
|
||||||
# PatternRule(r'console_bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
|
||||||
# ]
|
|
||||||
class Console(mode.Fundamental):
|
class Console(mode.Fundamental):
|
||||||
modename = 'Console'
|
modename = 'Console'
|
||||||
# grammar = ConsoleGrammar()
|
|
||||||
# colors = {
|
|
||||||
# 'console_mesg': ('red', 'default', 'bold'),
|
|
||||||
# 'console_input.start': ('red', 'default', 'bold'),
|
|
||||||
# 'console_reserved': ('magenta', 'default', 'bold'),
|
|
||||||
# 'console_bareword': ('default', 'default', 'bold'),
|
|
||||||
# }
|
|
||||||
|
|
||||||
install = Console.install
|
install = Console.install
|
||||||
|
|
|
@ -5,7 +5,6 @@ from mode.python import PythonGrammar
|
||||||
from point import Point
|
from point import Point
|
||||||
|
|
||||||
PAD = ' '
|
PAD = ' '
|
||||||
LIMIT = 79
|
|
||||||
|
|
||||||
class ConsoleExec(method.Method):
|
class ConsoleExec(method.Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
|
@ -57,12 +56,7 @@ class ConsoleExec(method.Method):
|
||||||
t = sys.exc_traceback
|
t = sys.exc_traceback
|
||||||
output = str(e) + traceback.format_exc()
|
output = str(e) + traceback.format_exc()
|
||||||
|
|
||||||
limit = 1000
|
limit = min([w.width for w in b.windows]) - len(PAD)
|
||||||
for w2 in b.windows:
|
|
||||||
limit = min(w.width, limit)
|
|
||||||
if limit == 1000:
|
|
||||||
limit = LIMIT
|
|
||||||
limit -= len(PAD)
|
|
||||||
|
|
||||||
if output:
|
if output:
|
||||||
newlines = []
|
newlines = []
|
||||||
|
@ -224,6 +218,18 @@ class ConsoleMini(mode.Fundamental):
|
||||||
actions = [ConsoleExec, ConsoleClear, ConsoleCancel, ConsoleHistoryPrev,
|
actions = [ConsoleExec, ConsoleClear, ConsoleCancel, ConsoleHistoryPrev,
|
||||||
ConsoleHistoryNext, ConsoleTab,
|
ConsoleHistoryNext, ConsoleTab,
|
||||||
ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd]
|
ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd]
|
||||||
|
_bindings = {
|
||||||
|
'console-exec': ('RETURN',),
|
||||||
|
'console-clear': ('C-l',),
|
||||||
|
'console-cancel': ('C-]', 'C-g'),
|
||||||
|
'console-history-prev': ('C-p', 'UP'),
|
||||||
|
'console-history-next': ('C-n', 'DOWN'),
|
||||||
|
'console-tab': ('TAB',),
|
||||||
|
'console-page-up': ('M-v',),
|
||||||
|
'console-page-down': ('C-v',),
|
||||||
|
'console-goto-beginning': ('M-<',),
|
||||||
|
'console-goto-end': ('M->',),
|
||||||
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
self.globals = dict(w.application.globals())
|
self.globals = dict(w.application.globals())
|
||||||
|
@ -231,15 +237,5 @@ class ConsoleMini(mode.Fundamental):
|
||||||
self.saved_input = ""
|
self.saved_input = ""
|
||||||
self.history = ['']
|
self.history = ['']
|
||||||
self.hindex = 0
|
self.hindex = 0
|
||||||
self.add_bindings('console-exec', ('RETURN',))
|
|
||||||
self.add_bindings('console-clear', ('C-l',))
|
|
||||||
self.add_bindings('console-cancel', ('C-]', 'C-g'))
|
|
||||||
self.add_bindings('console-history-prev', ('C-p', 'UP'))
|
|
||||||
self.add_bindings('console-history-next', ('C-n', 'DOWN'))
|
|
||||||
self.add_bindings('console-tab', ('TAB',))
|
|
||||||
self.add_bindings('console-page-up', ('M-v',))
|
|
||||||
self.add_bindings('console-page-down', ('C-v',))
|
|
||||||
self.add_bindings('console-goto-beginning', ('M-<',))
|
|
||||||
self.add_bindings('console-goto-end', ('M->',))
|
|
||||||
|
|
||||||
install = ConsoleMini.install
|
install = ConsoleMini.install
|
||||||
|
|
10
mode/css.py
10
mode/css.py
|
@ -80,10 +80,10 @@ class CSS(mode.Fundamental):
|
||||||
'css_keyword.escaped': ('magenta', 'default', 'bold'),
|
'css_keyword.escaped': ('magenta', 'default', 'bold'),
|
||||||
'css_keyword.end': ('default', 'default', 'bold'),
|
'css_keyword.end': ('default', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
|
|
||||||
install = CSS.install
|
install = CSS.install
|
||||||
|
|
|
@ -2,7 +2,7 @@ import commands, os.path, string, sys, traceback
|
||||||
import color, completer, default, mode, method, regex, tab
|
import color, completer, default, mode, method, regex, tab
|
||||||
from point import Point
|
from point import Point
|
||||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
from mode.lisp import LispTabber, LispCommentRegion, LispUncommentRegion
|
from mode.lisp import LispTabber
|
||||||
|
|
||||||
class StringGrammar(Grammar):
|
class StringGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -35,6 +35,7 @@ class ELisp(mode.Fundamental):
|
||||||
extensions = ['.el']
|
extensions = ['.el']
|
||||||
tabbercls = LispTabber
|
tabbercls = LispTabber
|
||||||
grammar = ELispGrammar
|
grammar = ELispGrammar
|
||||||
|
commentc = ';'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
@ -45,12 +46,12 @@ class ELisp(mode.Fundamental):
|
||||||
'elisp_symbol': ('magenta', 'default', 'bold'),
|
'elisp_symbol': ('magenta', 'default', 'bold'),
|
||||||
'elisp_type': ('blue', 'default', 'bold'),
|
'elisp_type': ('blue', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
'lisp-comment-region': ('C-c #',),
|
||||||
self.add_bindings('lisp-comment-region', ('C-c #',))
|
'lisp-uncomment-region': ('C-u C-C #',),
|
||||||
self.add_bindings('lisp-uncomment-region', ('C-u C-C #',))
|
}
|
||||||
|
|
||||||
install = ELisp.install
|
install = ELisp.install
|
||||||
|
|
|
@ -82,6 +82,7 @@ class Erlang(mode.Fundamental):
|
||||||
tabwidth = 4
|
tabwidth = 4
|
||||||
tabbercls = ErlangTabber
|
tabbercls = ErlangTabber
|
||||||
grammar = ErlangGrammar
|
grammar = ErlangGrammar
|
||||||
|
commentc = '%'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
@ -100,10 +101,10 @@ class Erlang(mode.Fundamental):
|
||||||
'erl_atom.null': ('magenta', 'default', 'bold'),
|
'erl_atom.null': ('magenta', 'default', 'bold'),
|
||||||
'erl_atom.end': ('magenta', 'default', 'bold'),
|
'erl_atom.end': ('magenta', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
|
|
||||||
install = Erlang.install
|
install = Erlang.install
|
||||||
|
|
|
@ -29,16 +29,17 @@ class HaskellGrammar(Grammar):
|
||||||
]
|
]
|
||||||
|
|
||||||
class Haskell(mode.Fundamental):
|
class Haskell(mode.Fundamental):
|
||||||
modename = 'Haskell'
|
modename = 'Haskell'
|
||||||
extensions = ['.hs']
|
extensions = ['.hs']
|
||||||
tabwidth = 4
|
tabwidth = 4
|
||||||
|
commentc = '--'
|
||||||
#tabbercls = mode.lisp.LispTabber
|
#tabbercls = mode.lisp.LispTabber
|
||||||
grammar = HaskellGrammar
|
grammar = HaskellGrammar
|
||||||
#opentokens = ('delimiter',)
|
#opentokens = ('delimiter',)
|
||||||
#opentags = {'(': ')'}
|
#opentags = {'(': ')'}
|
||||||
#closetokens = ('delimiter',)
|
#closetokens = ('delimiter',)
|
||||||
#closetags = {')': '('}
|
#closetags = {')': '('}
|
||||||
colors = {
|
colors = {
|
||||||
'hs_reserved': ('cyan', 'default', 'bold'),
|
'hs_reserved': ('cyan', 'default', 'bold'),
|
||||||
'hs_constructor': ('magenta', 'default', 'bold'),
|
'hs_constructor': ('magenta', 'default', 'bold'),
|
||||||
'hs_declaration': ('blue', 'default', 'bold'),
|
'hs_declaration': ('blue', 'default', 'bold'),
|
||||||
|
@ -51,10 +52,5 @@ class Haskell(mode.Fundamental):
|
||||||
'hs_string.gap.null': ('red', 'default', 'bold'),
|
'hs_string.gap.null': ('red', 'default', 'bold'),
|
||||||
'hs_string.gap.end': ('red', 'default', 'bold'),
|
'hs_string.gap.end': ('red', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
|
||||||
mode.Fundamental.__init__(self, w)
|
|
||||||
#self.add_bindings('close-paren', (')',))
|
|
||||||
#self.add_bindings('close-brace', ('}',))
|
|
||||||
#self.add_bindings('close-bracket', (']',))
|
|
||||||
|
|
||||||
install = Haskell.install
|
install = Haskell.install
|
||||||
|
|
15
mode/html.py
15
mode/html.py
|
@ -99,13 +99,12 @@ class HTML(mode.Fundamental):
|
||||||
colors['style.%s' % _name] = _colorbase[_name]
|
colors['style.%s' % _name] = _colorbase[_name]
|
||||||
colors['tag.%s' % _name] = _colorbase[_name]
|
colors['tag.%s' % _name] = _colorbase[_name]
|
||||||
actions = [HtmlViewPage, HtmlValidatePage, HtmlCheckSpelling]
|
actions = [HtmlViewPage, HtmlValidatePage, HtmlCheckSpelling]
|
||||||
|
_bindings = {
|
||||||
def __init__(self, w):
|
'close-paren': (')',),
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'xml-create-tag': ('M-t',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
self.add_bindings('xml-create-tag', ('M-t',))
|
url = None
|
||||||
self.url = None
|
|
||||||
|
|
||||||
install = HTML.install
|
install = HTML.install
|
||||||
|
|
|
@ -121,6 +121,7 @@ class Java(mode.Fundamental):
|
||||||
extensions = ['.java']
|
extensions = ['.java']
|
||||||
tabbercls = JavaTabber2
|
tabbercls = JavaTabber2
|
||||||
grammar = JavaGrammar
|
grammar = JavaGrammar
|
||||||
|
commentc = '//'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
|
|
@ -91,6 +91,7 @@ class Javascript(mode.Fundamental):
|
||||||
extensions = ['.js']
|
extensions = ['.js']
|
||||||
grammar = JavascriptGrammar
|
grammar = JavascriptGrammar
|
||||||
tabbercls = JavascriptTabber2
|
tabbercls = JavascriptTabber2
|
||||||
|
commentc = '//'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
@ -106,10 +107,10 @@ class Javascript(mode.Fundamental):
|
||||||
'js_regex.escaped': ('magenta', 'default', 'bold'),
|
'js_regex.escaped': ('magenta', 'default', 'bold'),
|
||||||
'js_regex.end': ('cyan', 'default', 'bold'),
|
'js_regex.end': ('cyan', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
|
|
||||||
install = Javascript.install
|
install = Javascript.install
|
||||||
|
|
|
@ -78,10 +78,10 @@ class LatexViewPdf(LatexBuildPdf):
|
||||||
pdfpath = self._modpath(w, '.pdf')
|
pdfpath = self._modpath(w, '.pdf')
|
||||||
os.execvp(viewcmd, (viewcmd, pdfpath))
|
os.execvp(viewcmd, (viewcmd, pdfpath))
|
||||||
|
|
||||||
class LatexCommentRegion(method.CommentRegion):
|
#class LatexCommentRegion(method.CommentRegion):
|
||||||
commentc = '%'
|
# commentc = '%'
|
||||||
class LatexUncommentRegion(method.UncommentRegion):
|
#class LatexUncommentRegion(method.UncommentRegion):
|
||||||
commentc = '%'
|
# commentc = '%'
|
||||||
|
|
||||||
class LatexInsertSquotes(method.Method):
|
class LatexInsertSquotes(method.Method):
|
||||||
'''Insert a pair of LaTeX-style single-quotes into the buffer'''
|
'''Insert a pair of LaTeX-style single-quotes into the buffer'''
|
||||||
|
@ -116,6 +116,7 @@ class LatexCheckSpelling(method.Method):
|
||||||
class Latex(mode.Fundamental):
|
class Latex(mode.Fundamental):
|
||||||
modename = 'Latex'
|
modename = 'Latex'
|
||||||
extensions = ['.latex', '.tex']
|
extensions = ['.latex', '.tex']
|
||||||
|
commentc = '%'
|
||||||
grammar = LatexGrammar
|
grammar = LatexGrammar
|
||||||
colors = {
|
colors = {
|
||||||
'latex_wrapper': ('magenta', 'default', 'bold'),
|
'latex_wrapper': ('magenta', 'default', 'bold'),
|
||||||
|
@ -133,21 +134,19 @@ class Latex(mode.Fundamental):
|
||||||
'latex.pdfbuildcmd': 'pdflatex',
|
'latex.pdfbuildcmd': 'pdflatex',
|
||||||
'latex.pdfviewcmd': 'evince',
|
'latex.pdfviewcmd': 'evince',
|
||||||
}
|
}
|
||||||
actions = [LatexCommentRegion, LatexUncommentRegion, LatexInsertSquotes,
|
actions = [LatexInsertSquotes,
|
||||||
LatexInsertDquotes, LatexInsertBraces, LatexBuild,
|
LatexInsertDquotes, LatexInsertBraces, LatexBuild,
|
||||||
LatexInsertSpace, LatexBuildPdf, LatexViewPdf,
|
LatexInsertSpace, LatexBuildPdf, LatexViewPdf,
|
||||||
LatexCheckSpelling]
|
LatexCheckSpelling]
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'wrap-paragraph': ('M-q',),
|
||||||
self.add_bindings('wrap-paragraph', ('M-q',))
|
'latex-insert-squotes': ("M-'",),
|
||||||
self.add_bindings('latex-comment-region', ('C-c #', "C-c \%"))
|
'latex-insert-dquotes': ('M-"',),
|
||||||
self.add_bindings('latex-uncomment-region', ('C-u C-c #', "C-u C-c \%"))
|
'latex-insert-braces': ('M-{',),
|
||||||
self.add_bindings('latex-insert-squotes', ("M-'",))
|
'latex-build': ("C-c C-c", 'C-c B'),
|
||||||
self.add_bindings('latex-insert-dquotes', ('M-"',))
|
'latex-insert-space': ('SPACE',),
|
||||||
self.add_bindings('latex-insert-braces', ('M-{',))
|
'latex-build-pdf': ("C-c C-p",),
|
||||||
self.add_bindings('latex-build', ("C-c C-c", 'C-c B'))
|
'latex-view-pdf': ('C-c C-v',),
|
||||||
self.add_bindings('latex-insert-space', ('SPACE',))
|
}
|
||||||
self.add_bindings('latex-build-pdf', ("C-c C-p",))
|
|
||||||
self.add_bindings('latex-view-pdf', ('C-c C-v',))
|
|
||||||
|
|
||||||
install = Latex.install
|
install = Latex.install
|
||||||
|
|
20
mode/lisp.py
20
mode/lisp.py
|
@ -14,11 +14,6 @@ class LispGrammar(Grammar):
|
||||||
PatternRule(r'eol', r'\n'),
|
PatternRule(r'eol', r'\n'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class LispCommentRegion(CommentRegion):
|
|
||||||
commentc = ';'
|
|
||||||
class LispUncommentRegion(UncommentRegion):
|
|
||||||
commentc = ';'
|
|
||||||
|
|
||||||
class LispTabber(tab.StackTabber):
|
class LispTabber(tab.StackTabber):
|
||||||
wsre = regex.whitespace
|
wsre = regex.whitespace
|
||||||
wst = ('spaces', 'null', 'eol',)
|
wst = ('spaces', 'null', 'eol',)
|
||||||
|
@ -49,14 +44,11 @@ class Lisp(mode.Fundamental):
|
||||||
opentags = {'(': ')'}
|
opentags = {'(': ')'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '('}
|
closetags = {')': '('}
|
||||||
actions = [LispCommentRegion, LispUncommentRegion]
|
_bindings = {
|
||||||
|
'close-paren': (')',),
|
||||||
def __init__(self, w):
|
'close-brace': ('}',),
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-paren', (')',))
|
}
|
||||||
self.add_bindings('close-brace', ('}',))
|
commentc = ';'
|
||||||
self.add_bindings('close-bracket', (']',))
|
|
||||||
self.add_bindings('lisp-comment-region', ('C-c #',))
|
|
||||||
self.add_bindings('lisp-uncomment-region', ('C-u C-C #',))
|
|
||||||
|
|
||||||
install = Lisp.install
|
install = Lisp.install
|
||||||
|
|
17
mode/lua.py
17
mode/lua.py
|
@ -40,19 +40,20 @@ class LuaCheckSyntax(method.Method):
|
||||||
class Lua(mode.Fundamental):
|
class Lua(mode.Fundamental):
|
||||||
modename = 'Lua'
|
modename = 'Lua'
|
||||||
extensions = ['.lua']
|
extensions = ['.lua']
|
||||||
#tabbercls = mode.lisp.LispTabber
|
#tabbercls = mode.lisp.LispTabber
|
||||||
grammar = LuaGrammar
|
grammar = LuaGrammar
|
||||||
|
commentc = '--'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {}
|
colors = {}
|
||||||
actions = [LuaCheckSyntax]
|
actions = [LuaCheckSyntax]
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
'lua-check-syntax': ('C-c s',),
|
||||||
self.add_bindings('lua-check-syntax', ('C-c s',))
|
}
|
||||||
|
|
||||||
install = Lua.install
|
install = Lua.install
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Make(mode.Fundamental):
|
||||||
modename = 'Make'
|
modename = 'Make'
|
||||||
basenames = ['Makefile']
|
basenames = ['Makefile']
|
||||||
grammar = MakeGrammar
|
grammar = MakeGrammar
|
||||||
|
commentc = '#'
|
||||||
savetabs = True
|
savetabs = True
|
||||||
colors = {
|
colors = {
|
||||||
'targets.start': ('cyan', 'default', 'bold'),
|
'targets.start': ('cyan', 'default', 'bold'),
|
||||||
|
|
|
@ -25,11 +25,11 @@ class NasmGrammar(Grammar):
|
||||||
PatternRule(r'comment', r';.*$'),
|
PatternRule(r'comment', r';.*$'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Nasm(mode.Fundamental):
|
class Nasm(mode.Fundamental):
|
||||||
modename = 'nasm'
|
modename = 'nasm'
|
||||||
extensions = ['.s']
|
extensions = ['.s']
|
||||||
grammar = NasmGrammar
|
grammar = NasmGrammar
|
||||||
|
commentc = ';'
|
||||||
colors = {
|
colors = {
|
||||||
'nasm_keyword': ('cyan', 'default', 'bold'),
|
'nasm_keyword': ('cyan', 'default', 'bold'),
|
||||||
'macros': ('blue', 'default', 'bold'),
|
'macros': ('blue', 'default', 'bold'),
|
||||||
|
|
|
@ -67,10 +67,10 @@ class Ocaml(mode.Fundamental):
|
||||||
'ocaml_string.escaped': ('magenta', 'default', 'bold'),
|
'ocaml_string.escaped': ('magenta', 'default', 'bold'),
|
||||||
'ocaml_string.end': ('green', 'default', 'bold'),
|
'ocaml_string.end': ('green', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
|
|
||||||
install = Ocaml.install
|
install = Ocaml.install
|
||||||
|
|
|
@ -619,6 +619,7 @@ class Perl(mode.Fundamental):
|
||||||
detection = ['perl']
|
detection = ['perl']
|
||||||
tabbercls = PerlTabber2
|
tabbercls = PerlTabber2
|
||||||
grammar = PerlGrammar
|
grammar = PerlGrammar
|
||||||
|
commentc = '#'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
|
35
mode/php.py
35
mode/php.py
|
@ -3,7 +3,7 @@ from lex import Grammar, PatternRule, RegionRule
|
||||||
from mode.python import StringGrammar
|
from mode.python import StringGrammar
|
||||||
#from mode.c import CTabber
|
#from mode.c import CTabber
|
||||||
|
|
||||||
class JavaGrammar(Grammar):
|
class PHPGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
#PatternRule(r'import', r'(?<=import ) *[a-zA-Z0-9_.*]+'),
|
#PatternRule(r'import', r'(?<=import ) *[a-zA-Z0-9_.*]+'),
|
||||||
#PatternRule(r'package', r'(?<=package ) *[a-zA-Z0-9_.*]+'),
|
#PatternRule(r'package', r'(?<=package ) *[a-zA-Z0-9_.*]+'),
|
||||||
|
@ -19,19 +19,19 @@ class JavaGrammar(Grammar):
|
||||||
PatternRule(r'php_constants', r'PHP_VERSION|PHP_OS|DEFAULT_INCLUDE_PATH|PEAR_INSTALL_DIR|PEAR_EXTENSION_DIR|PHP_EXTENSION_DIR|PHP_BINDIR|PHP_LIBDIR|PHP_DATADIR|PHP_SYSCONFDIR|PHP_LOCALSTATEDIR|PHP_CONFIG_FILE_PATH|PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CONT|PHP_OUTPUT_HANDLER_END|E_ERROR|E_WARNING|E_PARSE|E_NOTICE|E_CORE_ERROR|E_CORE_WARNING|E_COMPILE_ERROR|E_COMPILE_WARNING|E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_ALL'),
|
PatternRule(r'php_constants', r'PHP_VERSION|PHP_OS|DEFAULT_INCLUDE_PATH|PEAR_INSTALL_DIR|PEAR_EXTENSION_DIR|PHP_EXTENSION_DIR|PHP_BINDIR|PHP_LIBDIR|PHP_DATADIR|PHP_SYSCONFDIR|PHP_LOCALSTATEDIR|PHP_CONFIG_FILE_PATH|PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CONT|PHP_OUTPUT_HANDLER_END|E_ERROR|E_WARNING|E_PARSE|E_NOTICE|E_CORE_ERROR|E_CORE_WARNING|E_COMPILE_ERROR|E_COMPILE_WARNING|E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_ALL'),
|
||||||
|
|
||||||
PatternRule(r'keyword', r"(?:abstract|assert|boolean|break|byte|case|catch|char|class|continue|default|double|do|else|extends|finally|final|float|for|if|implements|import|instanceof|interface|int|long|native|new|package|private|protected|public|return|short|static|switch|super|synchronized|threadsafe|throws|throw|transient|try|void|while)(?![a-zA-Z_])"),
|
PatternRule(r'keyword', r"(?:abstract|assert|boolean|break|byte|case|catch|char|class|continue|default|double|do|else|extends|finally|final|float|for|if|implements|import|instanceof|interface|int|long|native|new|package|private|protected|public|return|short|static|switch|super|synchronized|threadsafe|throws|throw|transient|try|void|while)(?![a-zA-Z_])"),
|
||||||
PatternRule(r'java_label', r'[a-zA-Z_][a-zA-Z0-9_]*(?=:)'),
|
PatternRule(r'php_label', r'[a-zA-Z_][a-zA-Z0-9_]*(?=:)'),
|
||||||
|
|
||||||
PatternRule(r'java_builtin', r"(?:null|true|false|this)"),
|
PatternRule(r'php_builtin', r"(?:null|true|false|this)"),
|
||||||
PatternRule(r'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
|
PatternRule(r'identifier', r"[a-zA-Z_][a-zA-Z0-9_]*"),
|
||||||
PatternRule(r"unop", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
|
PatternRule(r"unop", r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*="),
|
||||||
PatternRule(r'binop', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
PatternRule(r'binop', r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
|
||||||
|
|
||||||
PatternRule(r"delimiter", r"->|\.|\(|\)|\[|\]|{|}|@|,|:|`|;|=|\?"),
|
PatternRule(r"delimiter", r"->|\.|\(|\)|\[|\]|{|}|@|,|:|`|;|=|\?"),
|
||||||
|
|
||||||
PatternRule(r"java_integer", r"(?:0(?![x0-9])|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
|
PatternRule(r"php_integer", r"(?:0(?![x0-9])|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"),
|
||||||
PatternRule(r"java_float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
|
PatternRule(r"php_float", r"[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"),
|
||||||
RegionRule(r'string', '"', StringGrammar, '"'),
|
RegionRule(r'string', '"', StringGrammar, '"'),
|
||||||
PatternRule(r'java_char', r"'.'|'\\.'|'\\[0-7]{3}'"),
|
PatternRule(r'php_char', r"'.'|'\\.'|'\\[0-7]{3}'"),
|
||||||
PatternRule(r"eol", r"\n$"),
|
PatternRule(r"eol", r"\n$"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -160,11 +160,12 @@ class JavaGrammar(Grammar):
|
||||||
# self._opt_append('cont', currlvl + w)
|
# self._opt_append('cont', currlvl + w)
|
||||||
# return currlvl
|
# return currlvl
|
||||||
|
|
||||||
class Java(mode.Fundamental):
|
class PHP(mode.Fundamental):
|
||||||
modename = 'Java'
|
modename = 'PHP'
|
||||||
extensions = ['.java']
|
extensions = ['.php']
|
||||||
#tabbercls = JavaTabber
|
#tabbercls = JavaTabber
|
||||||
grammar = JavaGrammar
|
grammar = PHPGrammar
|
||||||
|
commentc = '#'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
@ -174,11 +175,11 @@ class Java(mode.Fundamental):
|
||||||
'doccomment.end': ('red', 'default', 'bold'),
|
'doccomment.end': ('red', 'default', 'bold'),
|
||||||
'doccomment.null': ('red', 'default', 'bold'),
|
'doccomment.null': ('red', 'default', 'bold'),
|
||||||
'import': ('blue', 'default', 'bold'),
|
'import': ('blue', 'default', 'bold'),
|
||||||
'java_label': ('magenta', 'default', 'bold'),
|
'php_label': ('magenta', 'default', 'bold'),
|
||||||
'java_builtin': ('magenta', 'default', 'bold'),
|
'php_builtin': ('magenta', 'default', 'bold'),
|
||||||
'java_char': ('green', 'default', 'bold'),
|
'php_char': ('green', 'default', 'bold'),
|
||||||
'java_integer': ('green', 'default', 'bold'),
|
'php_integer': ('green', 'default', 'bold'),
|
||||||
'java_float': ('green', 'default', 'bold'),
|
'php_float': ('green', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
@ -186,4 +187,4 @@ class Java(mode.Fundamental):
|
||||||
self.add_bindings('close-brace', ('}',))
|
self.add_bindings('close-brace', ('}',))
|
||||||
self.add_bindings('close-bracket', (']',))
|
self.add_bindings('close-bracket', (']',))
|
||||||
|
|
||||||
install = Java.install
|
install = PHP.install
|
||||||
|
|
|
@ -402,54 +402,6 @@ class PythonBrmFindReferences(method.Method):
|
||||||
else:
|
else:
|
||||||
w.set_error('%d references found' % n)
|
w.set_error('%d references found' % n)
|
||||||
|
|
||||||
# commenting in python
|
|
||||||
class PythonCommentRegion(Method):
|
|
||||||
'''Prepend a comment to every line in the current buffer'''
|
|
||||||
commentc = '#'
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
cursor = w.logical_cursor()
|
|
||||||
if cursor < w.mark:
|
|
||||||
p1 = cursor
|
|
||||||
p2 = w.mark
|
|
||||||
elif w.mark < cursor:
|
|
||||||
p1 = w.mark
|
|
||||||
p2 = cursor
|
|
||||||
else:
|
|
||||||
w.input_line = "Empty kill region"
|
|
||||||
return
|
|
||||||
|
|
||||||
x = w.buffer.detect_indent_level(p1.y, p2.y)
|
|
||||||
for y in range(p1.y, p2.y):
|
|
||||||
c = self.commentc
|
|
||||||
if len(w.buffer.lines[y]) < x:
|
|
||||||
c += ' ' * (x - len(w.buffer.lines[y]))
|
|
||||||
w.buffer.insert_string(Point(x, y), c)
|
|
||||||
|
|
||||||
class PythonUncommentRegion(Method):
|
|
||||||
'''Remove a comment from every line in the current buffer'''
|
|
||||||
commentre = re.compile('^( *)(#+)')
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
cursor = w.logical_cursor()
|
|
||||||
if cursor < w.mark:
|
|
||||||
p1 = cursor
|
|
||||||
p2 = w.mark
|
|
||||||
elif w.mark < cursor:
|
|
||||||
p1 = w.mark
|
|
||||||
p2 = cursor
|
|
||||||
else:
|
|
||||||
w.input_line = "Empty kill region"
|
|
||||||
return
|
|
||||||
|
|
||||||
x = w.buffer.detect_indent_level(p1.y, p2.y)
|
|
||||||
for y in range(p1.y, p2.y):
|
|
||||||
line = w.buffer.lines[y]
|
|
||||||
m = self.commentre.match(line)
|
|
||||||
if not m:
|
|
||||||
continue
|
|
||||||
s1, s2 = m.groups()
|
|
||||||
x1, x2 = len(s1), len(s1) + len(s2)
|
|
||||||
w.buffer.delete(Point(x1, y), Point(x2, y))
|
|
||||||
|
|
||||||
class PythonNameCompleter(completer.Completer):
|
class PythonNameCompleter(completer.Completer):
|
||||||
def _get_dict(self, w):
|
def _get_dict(self, w):
|
||||||
return w.buffer.method.old_window.mode.context.get_names()
|
return w.buffer.method.old_window.mode.context.get_names()
|
||||||
|
@ -586,6 +538,7 @@ class Python(mode.Fundamental):
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
|
commentc = '#'
|
||||||
colors = {
|
colors = {
|
||||||
'python_keyword': ('cyan', 'default', 'bold'),
|
'python_keyword': ('cyan', 'default', 'bold'),
|
||||||
'python_reserved': ('magenta', 'default', 'bold'),
|
'python_reserved': ('magenta', 'default', 'bold'),
|
||||||
|
@ -605,8 +558,7 @@ class Python(mode.Fundamental):
|
||||||
lconfig = {
|
lconfig = {
|
||||||
'ignore-suffix': ['.pyc', '.pyo'],
|
'ignore-suffix': ['.pyc', '.pyo'],
|
||||||
}
|
}
|
||||||
actions = [PythonCommentRegion, PythonUncommentRegion,
|
actions = [PythonInitNames, PythonListNames, PythonGotoName,
|
||||||
PythonInitNames, PythonListNames, PythonGotoName,
|
|
||||||
PythonGotoFunction, PythonGotoClass, PythonCheckSyntax,
|
PythonGotoFunction, PythonGotoClass, PythonCheckSyntax,
|
||||||
PythonDictCleanup, PythonSemanticComplete, PythonBrmFindReferences,
|
PythonDictCleanup, PythonSemanticComplete, PythonBrmFindReferences,
|
||||||
PythonInsertTripleSquotes, PythonInsertTripleDquotes]
|
PythonInsertTripleSquotes, PythonInsertTripleDquotes]
|
||||||
|
|
|
@ -102,9 +102,9 @@ class RST(mode.Fundamental):
|
||||||
config = {
|
config = {
|
||||||
'rst.margin': 75,
|
'rst.margin': 75,
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'rst-insert-space': ('SPACE',),
|
||||||
self.add_bindings('rst-insert-space', ('SPACE',))
|
'rst-wrap-paragraph': ('M-q',),
|
||||||
self.add_bindings('rst-wrap-paragraph', ('M-q',))
|
}
|
||||||
|
|
||||||
install = RST.install
|
install = RST.install
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Scheme(mode.Fundamental):
|
||||||
tabwidth = 2
|
tabwidth = 2
|
||||||
tabbercls = mode.lisp.LispTabber
|
tabbercls = mode.lisp.LispTabber
|
||||||
grammar = SchemeGrammar
|
grammar = SchemeGrammar
|
||||||
|
commentc = ';'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')'}
|
opentags = {'(': ')'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
|
@ -54,13 +55,11 @@ class Scheme(mode.Fundamental):
|
||||||
'scheme_number': ('default', 'default', 'bold'),
|
'scheme_number': ('default', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
actions = [SchemeCheckSyntax]
|
actions = [SchemeCheckSyntax]
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
'scheme-check-syntax': ('C-c s',),
|
||||||
self.add_bindings('scheme-check-syntax', ('C-c s',))
|
}
|
||||||
self.add_bindings('lisp-comment-region', ('C-c #',))
|
|
||||||
self.add_bindings('lisp-uncomment-region', ('C-u C-C #',))
|
|
||||||
|
|
||||||
install = Scheme.install
|
install = Scheme.install
|
||||||
|
|
|
@ -209,8 +209,8 @@ class Sh(mode.Fundamental):
|
||||||
'neval.end': ('yellow', 'default', 'bold'),
|
'neval.end': ('yellow', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
actions = [ShCheckSyntax]
|
actions = [ShCheckSyntax]
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'sh-check-syntax': ('C-c s',),
|
||||||
self.add_bindings('sh-check-syntax', ('C-c s',))
|
}
|
||||||
|
|
||||||
install = Sh.install
|
install = Sh.install
|
||||||
|
|
59
mode/sql.py
59
mode/sql.py
|
@ -1,7 +1,6 @@
|
||||||
import mode, tab
|
import mode, tab
|
||||||
from lex import Grammar, PatternRule, NocasePatternRule, RegionRule, NocaseRegionRule
|
from lex import Grammar, PatternRule, NocasePatternRule, RegionRule, NocaseRegionRule
|
||||||
from mode.python import StringGrammar1, StringGrammar2
|
from mode.python import StringGrammar1, StringGrammar2
|
||||||
from method import CommentRegion, UncommentRegion
|
|
||||||
|
|
||||||
class BitStringGrammar(Grammar):
|
class BitStringGrammar(Grammar):
|
||||||
rules = [PatternRule(r'data', r'[01]+')]
|
rules = [PatternRule(r'data', r'[01]+')]
|
||||||
|
@ -60,23 +59,9 @@ sql_rules = [
|
||||||
|
|
||||||
PlPgSqlGrammar.rules = base_rules + sql_rules + end_rules
|
PlPgSqlGrammar.rules = base_rules + sql_rules + end_rules
|
||||||
|
|
||||||
#class FunctionGrammar(Grammar):
|
|
||||||
# rules = base_rules + [
|
|
||||||
# PatternRule(r'name', r'[a-zA-Z_][a-zA-Z0-9_]*(?=\()'),
|
|
||||||
# NocasePatternRule(r'sql_keyword', r'(?:as|returns|language)'),
|
|
||||||
# sql_type_rule,
|
|
||||||
# NocasePatternRule(r'language', r'(?<=language ) *[a-zA-Z_][a-zA-Z0-9_]+'),
|
|
||||||
# RegionRule(r'definition', "'", PlPgSqlGrammar, "'(?!')"),
|
|
||||||
# ] + end_rules
|
|
||||||
|
|
||||||
class SqlGrammar(Grammar):
|
class SqlGrammar(Grammar):
|
||||||
rules = base_rules + function_rules + sql_rules + end_rules
|
rules = base_rules + function_rules + sql_rules + end_rules
|
||||||
|
|
||||||
class SqlCommentRegion(CommentRegion):
|
|
||||||
commentc = '--'
|
|
||||||
class SqlUncommentRegion(UncommentRegion):
|
|
||||||
commentc = '--'
|
|
||||||
|
|
||||||
class SqlTabber(tab.StackTabber):
|
class SqlTabber(tab.StackTabber):
|
||||||
wst = ('null', 'eol',)
|
wst = ('null', 'eol',)
|
||||||
def is_base(self, y):
|
def is_base(self, y):
|
||||||
|
@ -126,26 +111,24 @@ class Sql(mode.Fundamental):
|
||||||
extensions = ['.sql']
|
extensions = ['.sql']
|
||||||
grammar = SqlGrammar
|
grammar = SqlGrammar
|
||||||
tabbercls = SqlTabber
|
tabbercls = SqlTabber
|
||||||
|
commentc = '--'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
actions = [SqlCommentRegion, SqlUncommentRegion]
|
colors = {
|
||||||
|
'sql_operator': ('yellow', 'default', 'bold'),
|
||||||
colors = {
|
'attribute': ('magenta', 'default', 'bold'),
|
||||||
'sql_operator': ('yellow', 'default', 'bold'),
|
'sql_keyword': ('cyan', 'default', 'bold'),
|
||||||
'attribute': ('magenta', 'default', 'bold'),
|
'pseudokeyword': ('cyan', 'default', 'bold'),
|
||||||
'sql_keyword': ('cyan', 'default', 'bold'),
|
'sql_type': ('green', 'default', 'bold'),
|
||||||
'pseudokeyword': ('cyan', 'default', 'bold'),
|
'sql_builtin': ('yellow', 'default', 'bold'),
|
||||||
'sql_type': ('green', 'default', 'bold'),
|
'sql_quoted.start': ('yellow', 'default', 'bold'),
|
||||||
'sql_builtin': ('yellow', 'default', 'bold'),
|
'sql_quoted.data': ('yellow', 'default', 'bold'),
|
||||||
'sql_quoted.start': ('yellow', 'default', 'bold'),
|
'sql_quoted.null': ('yellow', 'default', 'bold'),
|
||||||
'sql_quoted.data': ('yellow', 'default', 'bold'),
|
'sql_quoted.end': ('yellow', 'default', 'bold'),
|
||||||
'sql_quoted.null': ('yellow', 'default', 'bold'),
|
'sql_variable': ('yellow', 'default', 'bold'),
|
||||||
'sql_quoted.end': ('yellow', 'default', 'bold'),
|
'sql_bareword': ('default', 'default', 'bold'),
|
||||||
'sql_variable': ('yellow', 'default', 'bold'),
|
|
||||||
'sql_bareword': ('default', 'default', 'bold'),
|
|
||||||
|
|
||||||
'function.start': ('cyan', 'default', 'bold'),
|
'function.start': ('cyan', 'default', 'bold'),
|
||||||
'function.data': ('default', 'default', 'bold'),
|
'function.data': ('default', 'default', 'bold'),
|
||||||
'function.null': ('default', 'default', 'bold'),
|
'function.null': ('default', 'default', 'bold'),
|
||||||
|
@ -159,12 +142,12 @@ class Sql(mode.Fundamental):
|
||||||
'function.definition.null': ('magenta', 'default', 'bold'),
|
'function.definition.null': ('magenta', 'default', 'bold'),
|
||||||
'function.definition.end': ('magenta', 'default', 'bold'),
|
'function.definition.end': ('magenta', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
'sql-comment-region': ('C-c #',),
|
||||||
self.add_bindings('sql-comment-region', ('C-c #',))
|
'sql-uncomment-region': ('C-u C-c #',),
|
||||||
self.add_bindings('sql-uncomment-region', ('C-u C-c #',))
|
}
|
||||||
|
|
||||||
install = Sql.install
|
install = Sql.install
|
||||||
|
|
11
mode/tt.py
11
mode/tt.py
|
@ -52,10 +52,9 @@ class Template(mode.Fundamental):
|
||||||
'tt_tag.string.end': ('green', 'default', 'bold'),
|
'tt_tag.string.end': ('green', 'default', 'bold'),
|
||||||
'tt_tag.end': ('default', 'default', 'bold'),
|
'tt_tag.end': ('default', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'close-paren': (')',),
|
||||||
self.add_bindings('close-paren', (')',))
|
'close-brace': ('}',),
|
||||||
self.add_bindings('close-brace', ('}',))
|
'close-bracket': (']',),
|
||||||
self.add_bindings('close-bracket', (']',))
|
}
|
||||||
|
|
||||||
install = Template.install
|
install = Template.install
|
||||||
|
|
|
@ -77,8 +77,7 @@ class XML(mode.Fundamental):
|
||||||
'xml_entity': ('magenta', 'default', 'bold'),
|
'xml_entity': ('magenta', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
actions = [XmlValidate, XmlCreateTag]
|
actions = [XmlValidate, XmlCreateTag]
|
||||||
def __init__(self, w):
|
_bindings = {
|
||||||
mode.Fundamental.__init__(self, w)
|
'xml-create-tag': ('M-t',),
|
||||||
self.add_bindings('xml-create-tag', ('M-t',))
|
}
|
||||||
|
|
||||||
install = XML.install
|
install = XML.install
|
||||||
|
|
14
mode/yacc.py
14
mode/yacc.py
|
@ -2,6 +2,7 @@ import color, mode, tab
|
||||||
from lex import Grammar, PatternRule, RegionRule
|
from lex import Grammar, PatternRule, RegionRule
|
||||||
from mode.c import C, CGrammar, CTabber2
|
from mode.c import C, CGrammar, CTabber2
|
||||||
|
|
||||||
|
# ugh
|
||||||
_rules = list(CGrammar.rules)
|
_rules = list(CGrammar.rules)
|
||||||
_rules.insert(0, PatternRule(r"yacc_directive", r"^%[a-zA-Z_]+"))
|
_rules.insert(0, PatternRule(r"yacc_directive", r"^%[a-zA-Z_]+"))
|
||||||
_rules.insert(1, PatternRule(r"yacc_section", r"%%"))
|
_rules.insert(1, PatternRule(r"yacc_section", r"%%"))
|
||||||
|
@ -10,6 +11,7 @@ _rules.insert(3, PatternRule(r"yacc_production", r"^[a-z_]+:"))
|
||||||
_rules.insert(4, PatternRule(r"yacc_var", r"\$[0-9\$]"))
|
_rules.insert(4, PatternRule(r"yacc_var", r"\$[0-9\$]"))
|
||||||
_rules.insert(5, PatternRule(r"yacc_empty", r"^ +\n$"))
|
_rules.insert(5, PatternRule(r"yacc_empty", r"^ +\n$"))
|
||||||
|
|
||||||
|
# TODO: don't think we need this anymore
|
||||||
class TrueDict(dict):
|
class TrueDict(dict):
|
||||||
def __contains__(self, k): return True
|
def __contains__(self, k): return True
|
||||||
def __getitem__(self, k): return True
|
def __getitem__(self, k): return True
|
||||||
|
@ -23,10 +25,14 @@ class YaccGrammar(CGrammar):
|
||||||
rules = _rules
|
rules = _rules
|
||||||
|
|
||||||
class YaccTabber(CTabber2):
|
class YaccTabber(CTabber2):
|
||||||
open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'},
|
open_tokens = {
|
||||||
'yacc_delimiter': {'%{': '%}'}}
|
'delimiter': {'{': '}', '(': ')', '[': ']'},
|
||||||
close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['},
|
'yacc_delimiter': {'%{': '%}'},
|
||||||
'yacc_delimiter': {'%}': '%{'}}
|
}
|
||||||
|
close_tokens = {
|
||||||
|
'delimiter': {'}': '{', ')': '(', ']': '['},
|
||||||
|
'yacc_delimiter': {'%}': '%{'},
|
||||||
|
}
|
||||||
control_tokens = {'yacc_production': TrueDict()}
|
control_tokens = {'yacc_production': TrueDict()}
|
||||||
scope_tokens = {}
|
scope_tokens = {}
|
||||||
end_at_eof = False
|
end_at_eof = False
|
||||||
|
|
Loading…
Reference in New Issue