color updates, some bug fixes, grammar-override improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-05-03 17:31:30 +00:00
parent 541f241d7d
commit 9c19cffcf0
32 changed files with 465 additions and 413 deletions

4
IDEAS
View File

@ -1,3 +1,7 @@
2008/05/03:
use render-strings for highlighted regions.
2008/04/02: 2008/04/02:
fix read-only warnings to seem less junky (e.g. catch the buffer.ReadOnlyError fix read-only warnings to seem less junky (e.g. catch the buffer.ReadOnlyError

View File

@ -41,7 +41,7 @@ class Application(object):
(self.y, self.x) = self.stdscr.getmaxyx() (self.y, self.x) = self.stdscr.getmaxyx()
# initialize some basic stuff # initialize some basic stuff
# each highlighted_range contains three things: (window, start_p, end_p) # a highlighted_range contains three things: (window, start_p, end_p)
self.config = {} self.config = {}
self.highlighted_ranges = [] self.highlighted_ranges = []
self.mini_active = False self.mini_active = False
@ -52,31 +52,28 @@ class Application(object):
self.input = keyinput.Handler() self.input = keyinput.Handler()
# let's prepopulate some default token colors # let's prepopulate some default token colors
self.token_colors = { self.token_colors = {
'comment': ('red', 'default'), 'comment': ('red', 'default', 'bold'),
'comment.start': ('red', 'default'), 'comment.start': ('red', 'default', 'bold'),
'comment.null': ('red', 'default'), 'comment.null': ('red', 'default', 'bold'),
'comment.end': ('red', 'default'), 'comment.end': ('red', 'default', 'bold'),
'continuation': ('red', 'default', 'bold'),
'continuation': ('red', 'default'), 'string.start': ('green', 'default', 'bold'),
'string.null': ('green', 'default', 'bold'),
'string.start': ('green', 'default'), 'string.hex': ('magenta', 'default', 'bold'),
'string.null': ('green', 'default'), 'string.octal': ('magenta', 'default', 'bold'),
'string.hex': ('magenta', 'default'), 'string.escaped': ('magenta', 'default', 'bold'),
'string.octal': ('magenta', 'default'), 'string.end': ('green', 'default', 'bold'),
'string.escaped': ('magenta', 'default'), 'char': ('default', 'default', 'bold'),
'string.end': ('green', 'default'), 'integer': ('default', 'default', 'bold'),
'float': ('default', 'default', 'bold'),
'char': ('default', 'default'), 'number': ('default', 'default', 'bold'),
'integer': ('default', 'default'), 'label': ('magenta', 'default', 'bold'),
'float': ('default', 'default'), 'keyword': ('cyan', 'default', 'bold'),
'function': ('blue', 'default', 'bold'),
'label': ('magenta', 'default'), 'builtin': ('magenta', 'default', 'bold'),
'keyword': ('cyan', 'default'), 'method': ('cyan', 'default', 'bold'),
'function': ('blue', 'default'), 'bareword': ('default', 'default', 'bold'),
'builtin': ('magenta', 'default'), 'delimiter': ('default', 'default', 'bold'),
'method': ('cyan', 'default'),
'bareword': ('default', 'default'),
'delimiter': ('default', 'default'),
} }
self.default_color = ('default', 'default',) self.default_color = ('default', 'default',)
@ -123,12 +120,12 @@ class Application(object):
# ok, now let's load all the "standard" modes # ok, now let's load all the "standard" modes
mode.install(self) mode.install(self)
names = ('about', 'blame', 'c', 'console', 'consolemini', 'css', 'diff', names = ('about', 'blame', 'c', 'console', 'consolemini', 'css',
'dir', 'elisp', 'hex', 'html', 'java', 'javascript', 'lisp', 'diff', 'dir', 'elisp', 'hex', 'html', 'java', 'javascript',
'make', 'mini', 'mutt', 'nasm', 'ocaml', 'perl', 'python', 'lisp', 'make', 'mini', 'mutt', 'nasm', 'ocaml', 'perl',
'replace', 'rst', 'scheme', 'search', 'sh', 'sql', 'tt', 'python', 'replace', 'rst', 'scheme', 'search', 'sh', 'sql',
'text', 'text2', 'which', 'xml', 'cheetah', 'colortext', 'tt', 'text', 'text2', 'which', 'xml', 'cheetah', 'colortext',
'latex', 'insertmini', 'conf', 'haskell') 'latex', 'insertmini', 'conf', 'haskell', 'erlang')
for name in names: for name in names:
exec("import mode.%s; mode.%s.install(self)" % (name, name)) exec("import mode.%s; mode.%s.install(self)" % (name, name))
@ -192,7 +189,6 @@ class Application(object):
method.DATATYPES['method'] = completer.MethodCompleter() method.DATATYPES['method'] = completer.MethodCompleter()
method.DATATYPES['register'] = completer.RegisterCompleter() method.DATATYPES['register'] = completer.RegisterCompleter()
method.DATATYPES['mode'] = completer.ModeCompleter() method.DATATYPES['mode'] = completer.ModeCompleter()
#method.DATATYPES['perlfunction'] = completer.PerlFunctionCompleter()
# set up curses # set up curses
self.win = curses.newwin(self.y, self.x, 0, 0) self.win = curses.newwin(self.y, self.x, 0, 0)
@ -584,20 +580,18 @@ class Application(object):
else: else:
p = w.logical_cursor() p = w.logical_cursor()
blen = len(w.buffer.lines)
count = 0 count = 0
(x, y) = w.first.xy() (x, y) = w.first.xy()
(vy, vx) = (None, None) (vy, vx) = (None, None)
while count < slot.height: while count < slot.height:
if p.y == y and p.x >= x and p.x < x + swidth: if p.y == y and p.x >= x and p.x <= x + swidth:
(vy, vx) = (slot.y_offset + count, p.x - x + w.mode.lmargin) vy, vx = slot.y_offset + count, p.x - x + w.mode.lmargin
break break
if y >= len(w.buffer.lines) or x + swidth >= len(w.buffer.lines[y]): if y >= blen or x + swidth >= len(w.buffer.lines[y]):
x = 0 x = 0
y += 1 y += 1
#XYZ
#while w.ishidden(y) and y < len(w.buffer.lines):
# y += 1
else: else:
x += swidth x += swidth
count += 1 count += 1

View File

@ -2,13 +2,13 @@ package TBB::Reporting2;
my $bar =~ s/foob/blag/g; my $bar =~ s/foob/blag/g;
#@@:heredoc.string:xml
sub foo { sub foo {
bar() bar()
unless 9 && 3; unless 9 && 3;
} }
#@@:heredoc:sql #@@:heredoc:sql
#@@:heredoc.string:xml
my $s = <<EOT; my $s = <<EOT;
select '<foo attr="3">bar bar</foo>'; select '<foo attr="3">bar bar</foo>';
drop table foog; drop table foog;

17
lex.py
View File

@ -118,7 +118,8 @@ class OverridePatternRule(PatternRule):
modecls = a.modes[d['mode']] modecls = a.modes[d['mode']]
mode = modecls(FakeWindow(lexer.mode.window.application)) mode = modecls(FakeWindow(lexer.mode.window.application))
if hasattr(mode, 'grammar') and hasattr(mode, 'colors'): if hasattr(mode, 'grammar') and hasattr(mode, 'colors'):
lexer.mode.gstack['%s.start' % d['token']] = mode #lexer.mode.gstack['%s.start' % 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):
@ -237,6 +238,7 @@ class RegionRule(Rule):
# for each one, we will compile our stop-regex, and figure out the # for each one, we will compile our stop-regex, and figure out the
# name of the stop token to be created if this stop-regex matches. # name of the stop token to be created if this stop-regex matches.
fqname = toresume[0].fqname() fqname = toresume[0].fqname()
rname = toresume[0].rule.name
p = Point(toresume[0].x, toresume[0].y) p = Point(toresume[0].x, toresume[0].y)
if fqname in lexer.mode.ghist and p in lexer.mode.ghist[fqname]: if fqname in lexer.mode.ghist and p in lexer.mode.ghist[fqname]:
mode = lexer.mode.ghist[fqname][p] mode = lexer.mode.ghist[fqname][p]
@ -247,6 +249,16 @@ class RegionRule(Rule):
lexer.mode.ghist.setdefault(fqname, {}) lexer.mode.ghist.setdefault(fqname, {})
lexer.mode.ghist[fqname][p] = mode lexer.mode.ghist[fqname][p] = mode
del lexer.mode.gstack[fqname] del lexer.mode.gstack[fqname]
elif rname in lexer.mode.ghist and p in lexer.mode.ghist[rname]:
mode = lexer.mode.ghist[rname][p]
grammar = mode.grammar
elif rname in lexer.mode.gstack:
mode = lexer.mode.gstack[rname]
grammar = mode.grammar
lexer.mode.ghist.setdefault(rname, {})
lexer.mode.ghist[rname][p] = mode
if i == len(self.pairs) - 1:
del lexer.mode.gstack[rname]
else: else:
mode = lexer.mode mode = lexer.mode
if self.pairs[i][0] is not None: if self.pairs[i][0] is not None:
@ -476,7 +488,4 @@ class Lexer(object):
v = list(app.token_colors[name]) v = list(app.token_colors[name])
break break
# bold colors seem to always look nicer.
if True:
v.append('bold')
return v return v

View File

@ -17,14 +17,14 @@ class About(mode.Fundamental):
modename = 'About' modename = 'About'
grammar = AboutGrammar() grammar = AboutGrammar()
colors = { colors = {
'about_stars': ('yellow', 'default'), 'about_stars': ('yellow', 'default', 'bold'),
'about_equals': ('red', 'default'), 'about_equals': ('red', 'default', 'bold'),
'about_pmacs': ('cyan', 'default'), 'about_pmacs': ('cyan', 'default', 'bold'),
'about_author': ('cyan', 'default'), 'about_author': ('cyan', 'default', 'bold'),
'about_copyright': ('blue', 'default'), 'about_copyright': ('blue', 'default', 'bold'),
'about_license': ('cyan', 'default'), 'about_license': ('cyan', 'default', 'bold'),
'about_binding': ('cyan', 'default'), 'about_binding': ('cyan', 'default', 'bold'),
'about_command': ('blue', 'default'), 'about_command': ('blue', 'default', 'bold'),
} }
install = About.install install = About.install

View File

@ -47,12 +47,12 @@ class BDS(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'bds_derived': ('yellow', 'default'), 'bds_derived': ('yellow', 'default', 'bold'),
'bds_question': ('yellow', 'default'), 'bds_question': ('yellow', 'default', 'bold'),
'bds_misquoted': ('yellow', 'red'), 'bds_misquoted': ('yellow', 'red', 'bold'),
'bds_function': ('magenta', 'default'), 'bds_function': ('magenta', 'default', 'bold'),
'bds_perlfunc': ('magenta', 'default'), 'bds_perlfunc': ('magenta', 'default', 'bold'),
'bds_operator': ('magenta', 'default'), 'bds_operator': ('magenta', 'default', 'bold'),
} }
actions = [BDSMakeInstall, BDSCompileResources, BDSRestart] actions = [BDSMakeInstall, BDSCompileResources, BDSRestart]
def __init__(self, w): def __init__(self, w):

View File

@ -213,28 +213,28 @@ class C(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'macrocomment.start': ('red', 'default'), 'macrocomment.start': ('red', 'default', 'bold'),
'macrocomment.null': ('red', 'default'), 'macrocomment.null': ('red', 'default', 'bold'),
'macrocomment.end': ('red', 'default'), 'macrocomment.end': ('red', 'default', 'bold'),
'macro': ('blue', 'default'), 'macro': ('blue', 'default', 'bold'),
'macro.start': ('blue', 'default'), 'macro.start': ('blue', 'default', 'bold'),
'macro.name': ('yellow', 'default'), 'macro.name': ('yellow', 'default', 'bold'),
'macro.null': ('magenta', 'default'), 'macro.null': ('magenta', 'default', 'bold'),
'macro.continued': ('red', 'default'), 'macro.continued': ('red', 'default', 'bold'),
'macro.delimiter': ('default', 'default'), 'macro.delimiter': ('default', 'default', 'bold'),
'macro.integer': ('green', 'default'), 'macro.integer': ('green', 'default', 'bold'),
'macro.float': ('green', 'default'), 'macro.float': ('green', 'default', 'bold'),
'macro.char': ('green', 'default'), 'macro.char': ('green', 'default', 'bold'),
'macro.string.start': ('green', 'default'), 'macro.string.start': ('green', 'default', 'bold'),
'macro.string.escaped': ('magenta', 'default'), 'macro.string.escaped': ('magenta', 'default', 'bold'),
'macro.string.octal': ('magenta', 'default'), 'macro.string.octal': ('magenta', 'default', 'bold'),
'macro.string.null': ('green', 'default'), 'macro.string.null': ('green', 'default', 'bold'),
'macro.string.end': ('green', 'default'), 'macro.string.end': ('green', 'default', 'bold'),
'macro.end': ('magenta', 'default'), 'macro.end': ('magenta', 'default', 'bold'),
'include': ('blue', 'default'), 'include': ('blue', 'default', 'bold'),
'header': ('green', 'default'), 'header': ('green', 'default', 'bold'),
'structname': ('yellow', 'default'), 'structname': ('yellow', 'default', 'bold'),
'enumname': ('yellow', 'default'), 'enumname': ('yellow', 'default', 'bold'),
} }
config = { config = {
'c.syntax-cmd': "gcc -x c -fsyntax-only %(path)s", 'c.syntax-cmd': "gcc -x c -fsyntax-only %(path)s",

View File

@ -37,16 +37,16 @@ class Template(mode.Fundamental):
extensions = ['.tmpl'] extensions = ['.tmpl']
grammar = TemplateGrammar grammar = TemplateGrammar
colors = { colors = {
'cheetah_directive': ('magenta', 'default'), 'cheetah_directive': ('magenta', 'default', 'bold'),
'cheetah_placeholder': ('magenta', 'default'), 'cheetah_placeholder': ('magenta', 'default', 'bold'),
'cheetah_tag.start': ('default', 'default'), 'cheetah_tag.start': ('default', 'default', 'bold'),
'cheetah_tag.namespace': ('magenta', 'default'), 'cheetah_tag.namespace': ('magenta', 'default', 'bold'),
'cheetah_tag.name': ('blue', 'default'), 'cheetah_tag.name': ('blue', 'default', 'bold'),
'cheetah_tag.attrname': ('cyan', 'default'), 'cheetah_tag.attrname': ('cyan', 'default', 'bold'),
'cheetah_tag.string.start': ('green', 'default'), 'cheetah_tag.string.start': ('green', 'default', 'bold'),
'cheetah_tag.string.null': ('green', 'default'), 'cheetah_tag.string.null': ('green', 'default', 'bold'),
'cheetah_tag.string.end': ('green', 'default'), 'cheetah_tag.string.end': ('green', 'default', 'bold'),
'cheetah_tag.end': ('default', 'default'), 'cheetah_tag.end': ('default', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -15,8 +15,8 @@ class Console(mode.Fundamental):
modename = 'Console' modename = 'Console'
grammar = ConsoleGrammar() grammar = ConsoleGrammar()
colors = { colors = {
'console_mesg': ('blue', 'default'), 'console_mesg': ('blue', 'default', 'bold'),
'console_input': ('cyan', 'default'), 'console_input': ('cyan', 'default', 'bold'),
} }
install = Console.install install = Console.install

View File

@ -50,25 +50,25 @@ class CSS(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'css_dimension': ('magenta', 'default'), 'css_dimension': ('magenta', 'default', 'bold'),
'css_percentage': ('magenta', 'default'), 'css_percentage': ('magenta', 'default', 'bold'),
'css_length': ('magenta', 'default'), 'css_length': ('magenta', 'default', 'bold'),
'css_real': ('magenta', 'default'), 'css_real': ('magenta', 'default', 'bold'),
'css_int': ('magenta', 'default'), 'css_int': ('magenta', 'default', 'bold'),
'css_color': ('magenta', 'default'), 'css_color': ('magenta', 'default', 'bold'),
'css_hash': ('cyan', 'default'), 'css_hash': ('cyan', 'default', 'bold'),
'css_rule': ('cyan', 'default'), 'css_rule': ('cyan', 'default', 'bold'),
'css_label': ('cyan', 'default'), 'css_label': ('cyan', 'default', 'bold'),
'css_keyword': ('cyan', 'default'), 'css_keyword': ('cyan', 'default', 'bold'),
'css_ident': ('default', 'default'), 'css_ident': ('default', 'default', 'bold'),
'css_name': ('default', 'default'), 'css_name': ('default', 'default', 'bold'),
'css_keyword': ('cyan', 'default'), 'css_keyword': ('cyan', 'default', 'bold'),
'css_keyword.start': ('default', 'default'), 'css_keyword.start': ('default', 'default', 'bold'),
'css_keyword.null': ('cyan', 'default'), 'css_keyword.null': ('cyan', 'default', 'bold'),
'css_keyword.octal': ('magenta', 'default'), 'css_keyword.octal': ('magenta', 'default', 'bold'),
'css_keyword.escaped': ('magenta', 'default'), 'css_keyword.escaped': ('magenta', 'default', 'bold'),
'css_keyword.end': ('default', 'default'), 'css_keyword.end': ('default', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -165,31 +165,31 @@ class Dir(mode.Fundamental):
modename = 'Dir' modename = 'Dir'
grammar = DirGrammar() grammar = DirGrammar()
colors = { colors = {
'dir_blk.start': ('cyan', 'default'), 'dir_blk.start': ('cyan', 'default', 'bold'),
'dir_blk.name': ('cyan', 'default'), 'dir_blk.name': ('cyan', 'default', 'bold'),
'dir_chr.start': ('yellow', 'default'), 'dir_chr.start': ('yellow', 'default', 'bold'),
'dir_chr.name': ('yellow', 'default'), 'dir_chr.name': ('yellow', 'default', 'bold'),
'dir_dir.start': ('blue', 'default'), 'dir_dir.start': ('blue', 'default', 'bold'),
'dir_dir.dir_name': ('blue', 'default'), 'dir_dir.dir_name': ('blue', 'default', 'bold'),
'dir_lnk.start': ('green', 'default'), 'dir_lnk.start': ('green', 'default', 'bold'),
'dir_lnk.name': ('green', 'default'), 'dir_lnk.name': ('green', 'default', 'bold'),
'dir_fifo.start': ('red', 'default'), 'dir_fifo.start': ('red', 'default', 'bold'),
'dir_fifo.name': ('red', 'default'), 'dir_fifo.name': ('red', 'default', 'bold'),
'dir_sock.start': ('red', 'default'), 'dir_sock.start': ('red', 'default', 'bold'),
'dir_sock.name': ('red', 'default'), 'dir_sock.name': ('red', 'default', 'bold'),
'dir_unk.start': ('magenta', 'default'), 'dir_unk.start': ('magenta', 'default', 'bold'),
'dir_unk.name': ('magenta', 'default'), 'dir_unk.name': ('magenta', 'default', 'bold'),
'dir_perm.perm_setid': ('yellow', 'default'), 'dir_perm.perm_setid': ('yellow', 'default', 'bold'),
'dir_perm.perm_sticky': ('yellow', 'default'), 'dir_perm.perm_sticky': ('yellow', 'default', 'bold'),
'dir_perm.perm_read': ('magenta', 'default'), 'dir_perm.perm_read': ('magenta', 'default', 'bold'),
'dir_perm.perm_write': ('magenta', 'default'), 'dir_perm.perm_write': ('magenta', 'default', 'bold'),
'dir_perm.perm_exec': ('magenta', 'default'), 'dir_perm.perm_exec': ('magenta', 'default', 'bold'),
'dir_owner': ('cyan', 'default'), 'dir_owner': ('cyan', 'default', 'bold'),
'dir_group': ('cyan', 'default'), 'dir_group': ('cyan', 'default', 'bold'),
'dir_size': ('yellow', 'default'), 'dir_size': ('yellow', 'default', 'bold'),
'dir_mtime': ('green', 'default'), 'dir_mtime': ('green', 'default', 'bold'),
} }
actions = [RefreshView, OpenPath, DirGrep, Chmod, Chown, Chgrp, TouchPath, actions = [RefreshView, OpenPath, DirGrep, Chmod, Chown, Chgrp, TouchPath,
RemovePath] RemovePath]

View File

@ -39,10 +39,10 @@ class ELisp(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'elisp_keyword': ('cyan', 'default'), 'elisp_keyword': ('cyan', 'default', 'bold'),
'elisp_reserved': ('blue', 'default'), 'elisp_reserved': ('blue', 'default', 'bold'),
'elisp_symbol': ('magenta', 'default'), 'elisp_symbol': ('magenta', 'default', 'bold'),
'elisp_type': ('blue', 'default'), 'elisp_type': ('blue', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

50
mode/erlang.py Normal file
View File

@ -0,0 +1,50 @@
import commands, os.path, sets, string, sys, traceback
import color, completer, default, mode, method, regex, tab
from point import Point
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule
class StringGrammar(Grammar):
rules = [
NocasePatternRule(r'escaped', r'\\(?:[bdefnrstv\\"\']|\^[a-z]|\d{1,3})'),
]
class ErlangGrammar(Grammar):
rules = [
PatternRule(r'comment', r'%.*$'),
PatternRule(r'erl_attribute', r'-[a-z][a-zA-Z0-9_@]+'),
PatternRule(r'erl_reserved', r"(?:xor|when|try|rem|receive|query|orelse|or|of|not|let|if|fun|end|div|cond|catch|case|bxor|bsr|bsl|bor|bnot|begin|band|andalso|and|after)(?![a-zA-Z0-9_'])"),
PatternRule(r'erl_builtin', r"whereis|unregister|unlink|tuple_to_list|tuple_size|trunc|tl|time|throw|term_to_binary|term_to_binary|statistics|split_binary|spawn_opt|spawn_opt|spawn_opt|spawn_opt|spawn_monitor|spawn_monitor|spawn_link|spawn_link|spawn_link|spawn_link|spawn|spawn|spawn|spawn|size|setelement|self|round|registered|register|put|purge_module|process_info|process_info|process_flag|process_flag|processes|pre_loaded|port_control|port_connect|port_command|port_close|pid_to_list|open_port|now|nodes|nodes|node|node|monitor_node|module_loaded|make_ref|load_module|list_to_tuple|list_to_pid|list_to_integer|list_to_float|list_to_existing_atom|list_to_bitstring|list_to_binary|list_to_atom|link|length|is_tuple|is_reference|is_record|is_record|is_process_alive|is_port|is_pid|is_number|is_list|is_integer|is_function|is_function|is_float|is_boolean|is_bitstring|is_binary|is_atom|is_alive|iolist_to_binary|iolist_size|iolist|iodata|integer_to_list|hd|halt|halt|group_leader|group_leader|get_keys|get|get|garbage_collect|garbage_collect|float_to_list|float|ext_binary|exit|exit|erase|erase|ence|element|disconnect_node|delete_module|date|concat_binary|check_process_code|byte_size|bitstring_to_list|bit_size|binary_to_term|binary_to_list|binary_to_list|atom_to_list|atom_to_list|apply|apply|apply|abs"),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'erl_atom', r"'", StringGrammar, r"'"),
PatternRule(r'erl_atom', r"[a-z][a-zA-Z0-9_@]*"),
PatternRule(r'erl_variable', r"[A-Z_][a-zA-Z0-9_@]*"),
PatternRule(r'operator', r'\+\+|--|==|/=|=<|<|>=|>|=:=|=/=>|-|\+|\*|/|:|#|!]'),
PatternRule(r'delimiter', r'->|<<|>>|\(|\)|{|}|\[|\]|\.|;|,|\|'),
NocasePatternRule(r'number', r'\$.|[+-]?\d+#[a-z0-9]+|[+-]?\d+\.\d+|[+-]?\.\d+|[+-]?\d+'),
]
class Erlang(mode.Fundamental):
modename = 'Erlang'
extensions = ['.erl']
tabwidth = 4
#tabbercls = mode.lisp.LispTabber
grammar = ErlangGrammar
opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'erl_attribute': ('cyan', 'default', 'bold'),
'erl_reserved': ('cyan', 'default', 'bold'),
'erl_builtin': ('magenta', 'default', 'bold'),
'erl_atom': ('blue', 'default', 'bold'),
'erl_variable': ('yellow', 'default', 'bold'),
'erl_operator': ('default', '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 = Erlang.install

View File

@ -38,17 +38,17 @@ class Haskell(mode.Fundamental):
#closetokens = ('delimiter',) #closetokens = ('delimiter',)
#closetags = {')': '('} #closetags = {')': '('}
colors = { colors = {
'hs_reserved': ('cyan', 'default'), 'hs_reserved': ('cyan', 'default', 'bold'),
'hs_constructor': ('magenta', 'default'), 'hs_constructor': ('magenta', 'default', 'bold'),
'hs_declaration': ('blue', 'default'), 'hs_declaration': ('blue', 'default', 'bold'),
'hs_operator': ('green', 'default'), 'hs_operator': ('green', 'default', 'bold'),
'hs_string.start': ('green', 'default'), 'hs_string.start': ('green', 'default', 'bold'),
'hs_string.null': ('green', 'default'), 'hs_string.null': ('green', 'default', 'bold'),
'hs_string.end': ('green', 'default'), 'hs_string.end': ('green', 'default', 'bold'),
'hs_string.escaped': ('magenta', 'default'), 'hs_string.escaped': ('magenta', 'default', 'bold'),
'hs_string.gap.start': ('red', 'default'), 'hs_string.gap.start': ('red', 'default', 'bold'),
'hs_string.gap.null': ('red', 'default'), 'hs_string.gap.null': ('red', 'default', 'bold'),
'hs_string.gap.end': ('red', 'default'), 'hs_string.gap.end': ('red', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -54,14 +54,14 @@ class HTML(mode.Fundamental):
} }
_colorbase = { _colorbase = {
'start': ('default', 'default'), 'start': ('default', 'default', 'bold'),
'namespace': ('magenta', 'default'), 'namespace': ('magenta', 'default', 'bold'),
'name': ('blue', 'default'), 'name': ('blue', 'default', 'bold'),
'attrname': ('cyan', 'default'), 'attrname': ('cyan', 'default', 'bold'),
'string.start': ('green', 'default'), 'string.start': ('green', 'default', 'bold'),
'string.null': ('green', 'default'), 'string.null': ('green', 'default', 'bold'),
'string.end': ('green', 'default'), 'string.end': ('green', 'default', 'bold'),
'end': ('default', 'default'), 'end': ('default', 'default', 'bold'),
} }
for _name in _colorbase: for _name in _colorbase:
colors['script.%s' % _name] = _colorbase[_name] colors['script.%s' % _name] = _colorbase[_name]

View File

@ -164,15 +164,15 @@ class Java(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'doccomment.start': ('red', 'default'), 'doccomment.start': ('red', 'default', 'bold'),
'doccomment.end': ('red', 'default'), 'doccomment.end': ('red', 'default', 'bold'),
'doccomment.null': ('red', 'default'), 'doccomment.null': ('red', 'default', 'bold'),
'import': ('blue', 'default'), 'import': ('blue', 'default', 'bold'),
'java_label': ('magenta', 'default'), 'java_label': ('magenta', 'default', 'bold'),
'java_builtin': ('magenta', 'default'), 'java_builtin': ('magenta', 'default', 'bold'),
'java_char': ('green', 'default'), 'java_char': ('green', 'default', 'bold'),
'java_integer': ('green', 'default'), 'java_integer': ('green', 'default', 'bold'),
'java_float': ('green', 'default'), 'java_float': ('green', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -63,15 +63,15 @@ class Javascript(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'js_function': ('blue', 'default'), 'js_function': ('blue', 'default', 'bold'),
'js_class': ('green', 'default'), 'js_class': ('green', 'default', 'bold'),
'js_reserved': ('cyan', 'default'), 'js_reserved': ('cyan', 'default', 'bold'),
'js_nonreserved': ('cyan', 'default'), 'js_nonreserved': ('cyan', 'default', 'bold'),
'js_regex.start': ('cyan', 'default'), 'js_regex.start': ('cyan', 'default', 'bold'),
'js_regex.null': ('cyan', 'default'), 'js_regex.null': ('cyan', 'default', 'bold'),
'js_regex.octal': ('magenta', 'default'), 'js_regex.octal': ('magenta', 'default', 'bold'),
'js_regex.escaped': ('magenta', 'default'), 'js_regex.escaped': ('magenta', 'default', 'bold'),
'js_regex.end': ('cyan', 'default'), 'js_regex.end': ('cyan', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -28,14 +28,14 @@ class Make(mode.Fundamental):
grammar = MakeGrammar grammar = MakeGrammar
savetabs = True savetabs = True
colors = { colors = {
'targets.start': ('cyan', 'default'), 'targets.start': ('cyan', 'default', 'bold'),
'assignment.start': ('yellow', 'default'), 'assignment.start': ('yellow', 'default', 'bold'),
'make_variable': ('yellow', 'default'), 'make_variable': ('yellow', 'default', 'bold'),
'make_string.start': ('green', 'default'), 'make_string.start': ('green', 'default', 'bold'),
'make_string.variable': ('yellow', 'default'), 'make_string.variable': ('yellow', 'default', 'bold'),
'make_string.escaped': ('magenta', 'default'), 'make_string.escaped': ('magenta', 'default', 'bold'),
'make_string.null': ('green', 'default'), 'make_string.null': ('green', 'default', 'bold'),
'make_string.end': ('green', 'default'), 'make_string.end': ('green', 'default', 'bold'),
} }
install = Make.install install = Make.install

View File

@ -19,18 +19,6 @@ class Mini(mode.Fundamental):
actions = [MiniCallback, MiniTabComplete] actions = [MiniCallback, MiniTabComplete]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
# delete actions relating to multiple lines
#self.del_action('center-view')
#self.del_action('next-line')
#self.del_action('previous-line')
#self.del_action('page-down')
#self.del_action('page-up')
#self.del_action('goto-beginning')
#self.del_action('goto-end')
#self.del_action('switch-buffer')
# add some new actions for the minibuffer
self.add_bindings('mini-callback', ('RETURN',)) self.add_bindings('mini-callback', ('RETURN',))
self.add_bindings('mini-tab-complete', ('TAB',)) self.add_bindings('mini-tab-complete', ('TAB',))

View File

@ -33,12 +33,12 @@ class Mutt(mode.Fundamental):
'quotea': ('yellow', 'default', 'bold'), 'quotea': ('yellow', 'default', 'bold'),
'quoteb': ('cyan', 'default', 'bold'), 'quoteb': ('cyan', 'default', 'bold'),
'quotec': ('magenta', 'default', 'bold'), 'quotec': ('magenta', 'default', 'bold'),
'misspelled': ('red', 'default'), 'misspelled': ('red', 'default', 'bold'),
'cont.start': ('default', 'default'), 'cont.start': ('default', 'default', 'bold'),
'cont.end': ('default', 'default'), 'cont.end': ('default', 'default', 'bold'),
'word': ('default', 'default'), 'word': ('default', 'default', 'bold'),
'punct': ('default', 'default'), 'punct': ('default', 'default', 'bold'),
'stuff': ('default', 'default'), 'stuff': ('default', 'default', 'bold'),
} }
actions = [MuttInsertSpace, MuttWrapParagraph] actions = [MuttInsertSpace, MuttWrapParagraph]
def __init__(self, w): def __init__(self, w):

View File

@ -33,9 +33,9 @@ class Nasm(mode.Fundamental):
colors = { colors = {
'nasm_keyword': ('cyan', 'default', 'bold'), 'nasm_keyword': ('cyan', 'default', 'bold'),
'macros': ('blue', 'default', 'bold'), 'macros': ('blue', 'default', 'bold'),
'registers': ('yellow', 'default'), 'registers': ('yellow', 'default', 'bold'),
'instructions': ('magenta', 'default'), 'instructions': ('magenta', 'default', 'bold'),
'nasm_label': ('blue', 'default'), 'nasm_label': ('blue', 'default', 'bold'),
} }
install = Nasm.install install = Nasm.install

View File

@ -56,16 +56,16 @@ class Ocaml(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '('} closetags = {')': '('}
colors = { colors = {
'linenum': ('red', 'default'), 'linenum': ('red', 'default', 'bold'),
'ocaml_keyword': ('cyan', 'default'), 'ocaml_keyword': ('cyan', 'default', 'bold'),
'ocaml_label': ('blue', 'default'), 'ocaml_label': ('blue', 'default', 'bold'),
'optlabel': ('blue', 'default'), 'optlabel': ('blue', 'default', 'bold'),
'ocaml_string.start': ('green', 'default'), 'ocaml_string.start': ('green', 'default', 'bold'),
'ocaml_string.null': ('green', 'default'), 'ocaml_string.null': ('green', 'default', 'bold'),
'ocaml_string.octal': ('magenta', 'default'), 'ocaml_string.octal': ('magenta', 'default', 'bold'),
'ocaml_string.hex': ('magenta', 'default'), 'ocaml_string.hex': ('magenta', 'default', 'bold'),
'ocaml_string.escaped': ('magenta', 'default'), 'ocaml_string.escaped': ('magenta', 'default', 'bold'),
'ocaml_string.end': ('green', 'default'), 'ocaml_string.end': ('green', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -595,97 +595,93 @@ class Perl(mode.Fundamental):
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
# comments # comments
'endblock.start': ('red', 'default'), 'endblock.start': ('red', 'default', 'bold'),
'endblock.null': ('red', 'default'), 'endblock.null': ('red', 'default', 'bold'),
'endblock.end': ('red', 'default'), 'endblock.end': ('red', 'default', 'bold'),
# pod # pod
'pod.start': ('red', 'default'), 'pod.start': ('red', 'default', 'bold'),
'pod.null': ('red', 'default'), 'pod.null': ('red', 'default', 'bold'),
'pod.entry.start': ('magenta', 'default'), 'pod.entry.start': ('magenta', 'default', 'bold'),
'pod.entry.null': ('magenta', 'default'), 'pod.entry.null': ('magenta', 'default', 'bold'),
'pod.entry.end': ('magenta', 'default'), 'pod.entry.end': ('magenta', 'default', 'bold'),
'pod.end': ('red', 'default'), 'pod.end': ('red', 'default', 'bold'),
# basic stuff # basic stuff
'escaped': ('magenta', 'default'), 'escaped': ('magenta', 'default', 'bold'),
'null': ('default', 'default'), 'null': ('default', 'default', 'bold'),
'sub': ('cyan', 'default'), 'sub': ('cyan', 'default', 'bold'),
'prototype': ('magenta', 'default'), 'prototype': ('magenta', 'default', 'bold'),
'number': ('default', 'default'), 'operator': ('default', 'default', 'bold'),
'operator': ('default', 'default'), 'noperator': ('magenta', 'default', 'bold'),
'noperator': ('magenta', 'default'), 'endblock': ('red', 'default', 'bold'),
'endblock': ('red', 'default'), 'perl_keyword': ('magenta', 'default', 'bold'),
'perl_keyword': ('magenta', 'default'), 'cast': ('yellow', 'default', 'bold'),
'cast': ('yellow', 'default'), 'scalar': ('yellow', 'default', 'bold'),
'scalar': ('yellow', 'default'), 'array': ('yellow', 'default', 'bold'),
'array': ('yellow', 'default'), 'deref': ('yellow', 'default', 'bold'),
'deref': ('yellow', 'default'), 'perl_hash': ('yellow', 'default', 'bold'),
'perl_hash': ('yellow', 'default'), 'hash_key': ('green', 'default', 'bold'),
'hash_key': ('green', 'default'), 'perl_function': ('cyan', 'default', 'bold'),
'perl_function': ('cyan', 'default'), 'perl_builtin': ('magenta', 'default', 'bold'),
'perl_builtin': ('magenta', 'default'), 'perl_label': ('cyan', 'default', 'bold'),
#'method': ('cyan', 'default'), 'package': ('cyan', 'default', 'bold'),
#'bareword': ('default', 'default'), 'perl_class': ('cyan', 'default', 'bold'),
'perl_label': ('cyan', 'default'), 'use': ('cyan', 'default', 'bold'),
'package': ('cyan', 'default'), 'require': ('cyan', 'default', 'bold'),
'perl_class': ('cyan', 'default'),
'use': ('cyan', 'default'),
'require': ('cyan', 'default'),
#'method': ('cyan', 'default'),
# heredoc/evaldoc # heredoc/evaldoc
'heredoc.start': ('green', 'default'), 'heredoc.start': ('green', 'default', 'bold'),
'heredoc.null': ('green', 'default'), 'heredoc.null': ('green', 'default', 'bold'),
'heredoc.end': ('green', 'default'), 'heredoc.end': ('green', 'default', 'bold'),
'evaldoc.start': ('cyan', 'default'), 'evaldoc.start': ('cyan', 'default', 'bold'),
'evaldoc.null': ('cyan', 'default'), 'evaldoc.null': ('cyan', 'default', 'bold'),
'evaldoc.end': ('cyan', 'default'), 'evaldoc.end': ('cyan', 'default', 'bold'),
# strings # strings
'perl_string.start': ('green', 'default'), 'perl_string.start': ('green', 'default', 'bold'),
'perl_string.null': ('green', 'default'), 'perl_string.null': ('green', 'default', 'bold'),
'perl_string.escaped': ('magenta', 'default'), 'perl_string.escaped': ('magenta', 'default', 'bold'),
'perl_string.deref': ('yellow', 'default'), 'perl_string.deref': ('yellow', 'default', 'bold'),
'perl_string.end': ('green', 'default'), 'perl_string.end': ('green', 'default', 'bold'),
# `` strings # `` strings
'evalstring.start': ('cyan', 'default'), 'evalstring.start': ('cyan', 'default', 'bold'),
'evalstring.null': ('cyan', 'default'), 'evalstring.null': ('cyan', 'default', 'bold'),
'evalstring.escaped': ('magenta', 'default'), 'evalstring.escaped': ('magenta', 'default', 'bold'),
'evalstring.deref': ('yellow', 'default'), 'evalstring.deref': ('yellow', 'default', 'bold'),
'evalstring.end': ('cyan', 'default'), 'evalstring.end': ('cyan', 'default', 'bold'),
# quoted region # quoted region
'quoted': ('cyan', 'default'), 'quoted': ('cyan', 'default', 'bold'),
'quoted.start': ('cyan', 'default'), 'quoted.start': ('cyan', 'default', 'bold'),
'quoted.null': ('cyan', 'default'), 'quoted.null': ('cyan', 'default', 'bold'),
'quoted.escaped': ('magenta', 'default'), 'quoted.escaped': ('magenta', 'default', 'bold'),
'quoted.deref': ('yellow', 'default'), 'quoted.deref': ('yellow', 'default', 'bold'),
'quoted.end': ('cyan', 'default'), 'quoted.end': ('cyan', 'default', 'bold'),
# match regex # match regex
'match.start': ('cyan', 'default'), 'match.start': ('cyan', 'default', 'bold'),
'match.end': ('cyan', 'default'), 'match.end': ('cyan', 'default', 'bold'),
'match.null': ('cyan', 'default'), 'match.null': ('cyan', 'default', 'bold'),
# replace regex # replace regex
'replace.start': ('cyan', 'default'), 'replace.start': ('cyan', 'default', 'bold'),
'replace.middle0': ('cyan', 'default'), 'replace.middle0': ('cyan', 'default', 'bold'),
'replace.end': ('cyan', 'default'), 'replace.end': ('cyan', 'default', 'bold'),
'replace.null': ('cyan', 'default'), 'replace.null': ('cyan', 'default', 'bold'),
'replace.escaped': ('magenta', 'default'), 'replace.escaped': ('magenta', 'default', 'bold'),
'replace.deref': ('yellow', 'default'), 'replace.deref': ('yellow', 'default', 'bold'),
'replace.length': ('yellow', 'default'), 'replace.length': ('yellow', 'default', 'bold'),
'replace.scalar': ('yellow', 'default'), 'replace.scalar': ('yellow', 'default', 'bold'),
'replace.perl_hash': ('yellow', 'default'), 'replace.perl_hash': ('yellow', 'default', 'bold'),
'replace.cast': ('yellow', 'default'), 'replace.cast': ('yellow', 'default', 'bold'),
# translate regex # translate regex
'translate.start': ('magenta', 'default'), 'translate.start': ('magenta', 'default', 'bold'),
'translate.middle0': ('magenta', 'default'), 'translate.middle0': ('magenta', 'default', 'bold'),
'translate.end': ('magenta', 'default'), 'translate.end': ('magenta', 'default', 'bold'),
'translate.null': ('magenta', 'default'), 'translate.null': ('magenta', 'default', 'bold'),
} }
config = { config = {
'perl.lib': 'lib', 'perl.lib': 'lib',

View File

@ -359,16 +359,16 @@ class Python(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'python_keyword': ('cyan', 'default'), 'python_keyword': ('cyan', 'default', 'bold'),
'python_reserved': ('magenta', 'default'), 'python_reserved': ('magenta', 'default', 'bold'),
'python_builtin': ('cyan', 'default'), 'python_builtin': ('cyan', 'default', 'bold'),
'functionname': ('blue', 'default'), 'functionname': ('blue', 'default', 'bold'),
'classname': ('green', 'default'), 'classname': ('green', 'default', 'bold'),
'rawstring.start': ('green', 'default'), 'rawstring.start': ('green', 'default', 'bold'),
'rawstring.null': ('green', 'default'), 'rawstring.null': ('green', 'default', 'bold'),
'rawstring.escaped': ('green', 'default'), 'rawstring.escaped': ('green', 'default', 'bold'),
'rawstring.end': ('green', 'default'), 'rawstring.end': ('green', 'default', 'bold'),
'system_identifier': ('cyan', 'default'), 'system_identifier': ('cyan', 'default', 'bold'),
} }
config = { config = {
'python.lib': '.', 'python.lib': '.',

View File

@ -52,35 +52,35 @@ class RST(mode.Fundamental):
extensions = ['.rst'] extensions = ['.rst']
grammar = RSTGrammar grammar = RSTGrammar
colors = { colors = {
'title': ('blue', 'default'), 'title': ('blue', 'default', 'bold'),
'title_over': ('blue', 'default'), 'title_over': ('blue', 'default', 'bold'),
'title_under': ('blue', 'default'), 'title_under': ('blue', 'default', 'bold'),
'subtitle': ('cyan', 'default'), 'subtitle': ('cyan', 'default', 'bold'),
'subtitle_over': ('cyan', 'default'), 'subtitle_over': ('cyan', 'default', 'bold'),
'subtitle_under': ('cyan', 'default'), 'subtitle_under': ('cyan', 'default', 'bold'),
'definition': ('green', 'default'), 'definition': ('green', 'default', 'bold'),
'fieldname': ('green', 'default'), 'fieldname': ('green', 'default', 'bold'),
'optionname': ('green', 'default'), 'optionname': ('green', 'default', 'bold'),
'lineblock': ('cyan', 'default'), 'lineblock': ('cyan', 'default', 'bold'),
'blocktest': ('cyan', 'default'), 'blocktest': ('cyan', 'default', 'bold'),
'transition': ('cyan', 'default'), 'transition': ('cyan', 'default', 'bold'),
'emphasis': ('red', 'default'), 'emphasis': ('red', 'default', 'bold'),
'strong_emphasis': ('red', 'default'), 'strong_emphasis': ('red', 'default', 'bold'),
'interpreted': ('magenta', 'default'), 'interpreted': ('magenta', 'default', 'bold'),
'inline_literal': ('magenta', 'default'), 'inline_literal': ('magenta', 'default', 'bold'),
'substitution': ('magenta', 'default'), 'substitution': ('magenta', 'default', 'bold'),
'anonymous': ('blue', 'default'), 'anonymous': ('blue', 'default', 'bold'),
'reference': ('blue', 'default'), 'reference': ('blue', 'default', 'bold'),
'footnote': ('blue', 'default'), 'footnote': ('blue', 'default', 'bold'),
'citation': ('blue', 'default'), 'citation': ('blue', 'default', 'bold'),
'rst_url': ('blue', 'default'), 'rst_url': ('blue', 'default', 'bold'),
'bullet': ('magenta', 'default'), 'bullet': ('magenta', 'default', 'bold'),
'enumeration': ('magenta', 'default'), 'enumeration': ('magenta', 'default', 'bold'),
} }
actions = [RstInsertSpace, RstWrapParagraph] actions = [RstInsertSpace, RstWrapParagraph]
def __init__(self, w): def __init__(self, w):

View File

@ -48,10 +48,10 @@ class Scheme(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '('} closetags = {')': '('}
colors = { colors = {
'scheme_keyword': ('cyan', 'default'), 'scheme_keyword': ('cyan', 'default', 'bold'),
'scheme_char': ('green', 'default'), 'scheme_char': ('green', 'default', 'bold'),
'scheme_boolean': ('magenta', 'default'), 'scheme_boolean': ('magenta', 'default', 'bold'),
'scheme_number': ('default', 'default'), 'scheme_number': ('default', 'default', 'bold'),
} }
actions = [SchemeCheckSyntax] actions = [SchemeCheckSyntax]
def __init__(self, w): def __init__(self, w):

View File

@ -152,19 +152,18 @@ class Sh(mode.Fundamental):
'case.middle0': ('magenta', 'default', 'bold'), 'case.middle0': ('magenta', 'default', 'bold'),
'case.end': ('magenta', 'default', 'bold'), 'case.end': ('magenta', 'default', 'bold'),
#'delimiter': ('default', 'default', 'bold'),
'test.start': ('cyan', 'default', 'bold'), 'test.start': ('cyan', 'default', 'bold'),
'binop': ('magenta', 'default', 'bold'), 'binop': ('magenta', 'default', 'bold'),
'unop': ('magenta', 'default', 'bold'), 'unop': ('magenta', 'default', 'bold'),
'eval.start': ('cyan', 'default'), 'eval.start': ('cyan', 'default', 'bold'),
'eval.variable': ('yellow', 'default'), 'eval.variable': ('yellow', 'default', 'bold'),
'eval.null': ('cyan', 'default'), 'eval.null': ('cyan', 'default', 'bold'),
'eval.end': ('cyan', 'default'), 'eval.end': ('cyan', 'default', 'bold'),
'neval.start': ('yellow', 'default'), 'neval.start': ('yellow', 'default', 'bold'),
'neval.variable': ('yellow', 'default'), 'neval.variable': ('yellow', 'default', 'bold'),
'neval.null': ('cyan', 'default'), 'neval.null': ('cyan', 'default', 'bold'),
'neval.end': ('yellow', 'default'), 'neval.end': ('yellow', 'default', 'bold'),
} }
actions = [ShCheckSyntax] actions = [ShCheckSyntax]
def __init__(self, w): def __init__(self, w):

View File

@ -117,28 +117,28 @@ class Sql(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'sql_operator': ('yellow', 'default'), 'sql_operator': ('yellow', 'default', 'bold'),
'attribute': ('magenta', 'default'), 'attribute': ('magenta', 'default', 'bold'),
'sql_keyword': ('cyan', 'default'), 'sql_keyword': ('cyan', 'default', 'bold'),
'pseudokeyword': ('cyan', 'default'), 'pseudokeyword': ('cyan', 'default', 'bold'),
'sql_type': ('green', 'default'), 'sql_type': ('green', 'default', 'bold'),
'sql_builtin': ('yellow', 'default'), 'sql_builtin': ('yellow', 'default', 'bold'),
'sql_quoted.start': ('yellow', 'default'), 'sql_quoted.start': ('yellow', 'default', 'bold'),
'sql_quoted.null': ('yellow', 'default'), 'sql_quoted.null': ('yellow', 'default', 'bold'),
'sql_quoted.end': ('yellow', 'default'), 'sql_quoted.end': ('yellow', 'default', 'bold'),
'sql_variable': ('yellow', 'default'), 'sql_variable': ('yellow', 'default', 'bold'),
'sql_bareword': ('default', 'default'), 'sql_bareword': ('default', 'default', 'bold'),
'function.start': ('cyan', 'default'), 'function.start': ('cyan', 'default', 'bold'),
'function.null': ('default', 'default'), 'function.null': ('default', 'default', 'bold'),
'function.name': ('magenta', 'default'), 'function.name': ('magenta', 'default', 'bold'),
'function.language': ('magenta', 'default'), 'function.language': ('magenta', 'default', 'bold'),
'function.end': ('default', 'default'), 'function.end': ('default', 'default', 'bold'),
'function.definition.start': ('magenta', 'default'), 'function.definition.start': ('magenta', 'default', 'bold'),
'function.definition.sql_bareword': ('magenta', 'default'), 'function.definition.sql_bareword': ('magenta', 'default', 'bold'),
'function.definition.null': ('magenta', 'default'), 'function.definition.null': ('magenta', 'default', 'bold'),
'function.definition.end': ('magenta', 'default'), 'function.definition.end': ('magenta', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -18,8 +18,8 @@ class Text2(mode.text.Text):
extensions = ['.txt'] extensions = ['.txt']
extensions = [] extensions = []
colors = { colors = {
'text2_email': ('cyan', 'default'), 'text2_email': ('cyan', 'default', 'bold'),
'text2_url': ('green', 'default'), 'text2_url': ('green', 'default', 'bold'),
} }
install = Text2.install install = Text2.install

View File

@ -32,25 +32,25 @@ class Template(mode.Fundamental):
extensions = ['.tt'] extensions = ['.tt']
grammar = TemplateGrammar grammar = TemplateGrammar
colors = { colors = {
'directive.start': ('magenta', 'default'), 'directive.start': ('magenta', 'default', 'bold'),
'directive.comment': ('red', 'default'), 'directive.comment': ('red', 'default', 'bold'),
'directive.keyword': ('cyan', 'default'), 'directive.keyword': ('cyan', 'default', 'bold'),
'directive.string.start': ('green', 'default'), 'directive.string.start': ('green', 'default', 'bold'),
'directive.string.escaped': ('magenta', 'default'), 'directive.string.escaped': ('magenta', 'default', 'bold'),
'directive.string.octal': ('magenta', 'default'), 'directive.string.octal': ('magenta', 'default', 'bold'),
'directive.string.null': ('green', 'default'), 'directive.string.null': ('green', 'default', 'bold'),
'directive.string.end': ('green', 'default'), 'directive.string.end': ('green', 'default', 'bold'),
'directive.null': ('magenta', 'default'), 'directive.null': ('magenta', 'default', 'bold'),
'directive.end': ('magenta', 'default'), 'directive.end': ('magenta', 'default', 'bold'),
'tt_tag.start': ('default', 'default'), 'tt_tag.start': ('default', 'default', 'bold'),
'tt_tag.namespace': ('magenta', 'default'), 'tt_tag.namespace': ('magenta', 'default', 'bold'),
'tt_tag.name': ('blue', 'default'), 'tt_tag.name': ('blue', 'default', 'bold'),
'tt_tag.attrname': ('cyan', 'default'), 'tt_tag.attrname': ('cyan', 'default', 'bold'),
'tt_tag.string.start': ('green', 'default'), 'tt_tag.string.start': ('green', 'default', 'bold'),
'tt_tag.string.null': ('green', 'default'), 'tt_tag.string.null': ('green', 'default', 'bold'),
'tt_tag.string.end': ('green', 'default'), 'tt_tag.string.end': ('green', 'default', 'bold'),
'tt_tag.end': ('default', 'default'), 'tt_tag.end': ('default', 'default', 'bold'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -29,14 +29,14 @@ class XML(mode.Fundamental):
extensions = ['.xml', '.xml.in'] extensions = ['.xml', '.xml.in']
grammar = XMLGrammar grammar = XMLGrammar
colors = { colors = {
'xml_tag.start': ('default', 'default'), 'xml_tag.start': ('default', 'default', 'bold'),
'xml_tag.namespace': ('magenta', 'default'), 'xml_tag.namespace': ('magenta', 'default', 'bold'),
'xml_tag.name': ('blue', 'default'), 'xml_tag.name': ('blue', 'default', 'bold'),
'xml_tag.attrname': ('cyan', 'default'), 'xml_tag.attrname': ('cyan', 'default', 'bold'),
'xml_tag.string.start': ('green', 'default'), 'xml_tag.string.start': ('green', 'default', 'bold'),
'xml_tag.string.null': ('green', 'default'), 'xml_tag.string.null': ('green', 'default', 'bold'),
'xml_tag.string.end': ('green', 'default'), 'xml_tag.string.end': ('green', 'default', 'bold'),
'xml_tag.end': ('default', 'default'), 'xml_tag.end': ('default', 'default', 'bold'),
} }
actions = [XmlValidate] actions = [XmlValidate]

View File

@ -9,7 +9,14 @@ WORD_LETTERS = list(string.letters + string.digits)
# character it highlights. to this end, it needs to be able to highlight behind # character it highlights. to this end, it needs to be able to highlight behind
# the last character on a line. thus, the x coordinate of the (logical) cursor # the last character on a line. thus, the x coordinate of the (logical) cursor
# can equal the length of lines[y], even though lines[y][x] throws an index # can equal the length of lines[y], even though lines[y][x] throws an index
# error. both buffer and window need to be aware of this possibility for points. # error. both buffer and window need to be aware of this possibility.
#
# furthermore, when moving down from a long line to a shorter one, the cursor
# will jump in to the end of the shorter line. however, moving back up will
# jump back out to its previous position. in these cases the cursor stores the
# original x value, but the logical cursor function maps x to the "last
# character on the line" for the shorter line. any line movement or actions on
# the shorter line will "set" the cursor to its position on the shorter line.
class Window(object): class Window(object):
margins = ((80, 'blue'),) margins = ((80, 'blue'),)
@ -31,16 +38,16 @@ class Window(object):
if mode_name is not None: if mode_name is not None:
pass pass
elif hasattr(self.buffer, 'modename') and self.buffer.modename is not None: elif hasattr(b, 'modename') and b.modename is not None:
mode_name = self.buffer.modename mode_name = b.modename
elif self.buffer.btype == 'mini': elif b.btype == 'mini':
mode_name = 'mini' mode_name = 'mini'
elif self.buffer.btype == 'console': elif b.btype == 'console':
mode_name = "fundamental" mode_name = "fundamental"
elif self.buffer.btype == 'dir': elif b.btype == 'dir':
mode_name = 'dir' mode_name = 'dir'
elif hasattr(self.buffer, 'path'): elif hasattr(b, 'path'):
path = self.buffer.path path = b.path
basename = os.path.basename(path) basename = os.path.basename(path)
ext = self._get_path_ext(path) ext = self._get_path_ext(path)
@ -50,9 +57,9 @@ class Window(object):
mode_name = self.application.mode_basenames[basename] mode_name = self.application.mode_basenames[basename]
elif ext in self.application.mode_extensions: elif ext in self.application.mode_extensions:
mode_name = self.application.mode_extensions[ext] mode_name = self.application.mode_extensions[ext]
elif len(self.buffer.lines) > 0 and \ elif len(b.lines) > 0 and \
self.buffer.lines[0].startswith('#!'): b.lines[0].startswith('#!'):
line = self.buffer.lines[0] line = b.lines[0]
for word in self.application.mode_detection: for word in self.application.mode_detection:
if word in line: if word in line:
mode_name = self.application.mode_detection[word] mode_name = self.application.mode_detection[word]
@ -62,7 +69,7 @@ class Window(object):
m = self.application.modes[mode_name](self) m = self.application.modes[mode_name](self)
self.set_mode(m) self.set_mode(m)
self.buffer.add_window(self) b.add_window(self)
# private method used in window constructor # private method used in window constructor
def _get_path_ext(self, path): def _get_path_ext(self, path):
@ -95,7 +102,7 @@ class Window(object):
return self.buffer.highlights[self.mode.name()] return self.buffer.highlights[self.mode.name()]
# this is used to temporarily draw the user's attention to another point # this is used to temporarily draw the user's attention to another point
def set_active_point(self, p, msg='marking on line %(y)d, character %(x)d'): def set_active_point(self, p, msg='marking on line %(y)d, char %(x)d'):
self.active_point = p self.active_point = p
if not self.point_is_visible(p): if not self.point_is_visible(p):
self.application.set_error(msg % {'x': p.x, 'y': p.y}) self.application.set_error(msg % {'x': p.x, 'y': p.y})
@ -111,7 +118,10 @@ class Window(object):
# point right # point right
def point_right(self, p): def point_right(self, p):
if p.y == len(self.buffer.lines)-1 and p.x == len(self.buffer.lines[-1]): blen = len(self.buffer.lines)
if p.y >= blen:
return None
elif p.y == blen-1 and p.x >= len(self.buffer.lines[-1]):
return None return None
elif p.x == len(self.buffer.lines[p.y]): elif p.x == len(self.buffer.lines[p.y]):
return Point(0, p.y + 1) return Point(0, p.y + 1)
@ -246,7 +256,8 @@ class Window(object):
if cursor.x > 0: if cursor.x > 0:
self.cursor = Point(cursor.x - 1, cursor.y) self.cursor = Point(cursor.x - 1, cursor.y)
elif cursor.y > 0: elif cursor.y > 0:
self.cursor = Point(len(self.buffer.lines[cursor.y - 1]), cursor.y - 1) x = len(self.buffer.lines[cursor.y - 1])
self.cursor = Point(x, cursor.y - 1)
self.assure_visible_cursor() self.assure_visible_cursor()
def end_of_line(self): def end_of_line(self):
cursor = self.logical_cursor() cursor = self.logical_cursor()
@ -471,7 +482,8 @@ class Window(object):
if x > 0: if x > 0:
self.buffer.delete_char(Point(x - 1, y)) self.buffer.delete_char(Point(x - 1, y))
elif y > 0: elif y > 0:
self.buffer.delete_char(Point(len(self.buffer.lines[y - 1]), y - 1)) x = len(self.buffer.lines[y - 1])
self.buffer.delete_char(Point(x, y - 1))
def right_delete(self): def right_delete(self):
cursor = self.logical_cursor() cursor = self.logical_cursor()
if cursor < self.last: if cursor < self.last:
@ -662,7 +674,7 @@ class Window(object):
# application drawing # application drawing
# #
# render methods return a list of lists of RenderString objects # render methods return a list of lists of RenderString objects
# (i.e. multiple physical lines, each containing multiple areas to be drawn) # (i.e. multiple physical lines containing multiple areas to be drawn)
def render_line(self, y, width): def render_line(self, y, width):
modename = self.mode.name() modename = self.mode.name()
if modename in self.buffer.highlights: if modename in self.buffer.highlights: