diff --git a/IDEAS b/IDEAS index dbf35fb..f45e913 100644 --- a/IDEAS +++ b/IDEAS @@ -1,3 +1,7 @@ +2008/05/03: + +use render-strings for highlighted regions. + 2008/04/02: fix read-only warnings to seem less junky (e.g. catch the buffer.ReadOnlyError diff --git a/application.py b/application.py index 9086987..62472f5 100755 --- a/application.py +++ b/application.py @@ -41,7 +41,7 @@ class Application(object): (self.y, self.x) = self.stdscr.getmaxyx() # 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.highlighted_ranges = [] self.mini_active = False @@ -52,31 +52,28 @@ class Application(object): self.input = keyinput.Handler() # let's prepopulate some default token colors self.token_colors = { - 'comment': ('red', 'default'), - 'comment.start': ('red', 'default'), - 'comment.null': ('red', 'default'), - 'comment.end': ('red', 'default'), - - 'continuation': ('red', 'default'), - - 'string.start': ('green', 'default'), - 'string.null': ('green', 'default'), - 'string.hex': ('magenta', 'default'), - 'string.octal': ('magenta', 'default'), - 'string.escaped': ('magenta', 'default'), - 'string.end': ('green', 'default'), - - 'char': ('default', 'default'), - 'integer': ('default', 'default'), - 'float': ('default', 'default'), - - 'label': ('magenta', 'default'), - 'keyword': ('cyan', 'default'), - 'function': ('blue', 'default'), - 'builtin': ('magenta', 'default'), - 'method': ('cyan', 'default'), - 'bareword': ('default', 'default'), - 'delimiter': ('default', 'default'), + 'comment': ('red', 'default', 'bold'), + 'comment.start': ('red', 'default', 'bold'), + 'comment.null': ('red', 'default', 'bold'), + 'comment.end': ('red', 'default', 'bold'), + 'continuation': ('red', 'default', 'bold'), + 'string.start': ('green', 'default', 'bold'), + 'string.null': ('green', 'default', 'bold'), + 'string.hex': ('magenta', 'default', 'bold'), + 'string.octal': ('magenta', 'default', 'bold'), + 'string.escaped': ('magenta', 'default', 'bold'), + 'string.end': ('green', 'default', 'bold'), + 'char': ('default', 'default', 'bold'), + 'integer': ('default', 'default', 'bold'), + 'float': ('default', 'default', 'bold'), + 'number': ('default', 'default', 'bold'), + 'label': ('magenta', 'default', 'bold'), + 'keyword': ('cyan', 'default', 'bold'), + 'function': ('blue', 'default', 'bold'), + 'builtin': ('magenta', 'default', 'bold'), + 'method': ('cyan', 'default', 'bold'), + 'bareword': ('default', 'default', 'bold'), + 'delimiter': ('default', 'default', 'bold'), } self.default_color = ('default', 'default',) @@ -123,12 +120,12 @@ class Application(object): # ok, now let's load all the "standard" modes mode.install(self) - names = ('about', 'blame', 'c', 'console', 'consolemini', 'css', 'diff', - 'dir', 'elisp', 'hex', 'html', 'java', 'javascript', 'lisp', - 'make', 'mini', 'mutt', 'nasm', 'ocaml', 'perl', 'python', - 'replace', 'rst', 'scheme', 'search', 'sh', 'sql', 'tt', - 'text', 'text2', 'which', 'xml', 'cheetah', 'colortext', - 'latex', 'insertmini', 'conf', 'haskell') + names = ('about', 'blame', 'c', 'console', 'consolemini', 'css', + 'diff', 'dir', 'elisp', 'hex', 'html', 'java', 'javascript', + 'lisp', 'make', 'mini', 'mutt', 'nasm', 'ocaml', 'perl', + 'python', 'replace', 'rst', 'scheme', 'search', 'sh', 'sql', + 'tt', 'text', 'text2', 'which', 'xml', 'cheetah', 'colortext', + 'latex', 'insertmini', 'conf', 'haskell', 'erlang') for name in names: exec("import mode.%s; mode.%s.install(self)" % (name, name)) @@ -184,15 +181,14 @@ class Application(object): self.registers = {} # initialize tab handlers - method.DATATYPES['path'] = completer.FileCompleter() - method.DATATYPES['buffer'] = completer.BufferCompleter(self) - method.DATATYPES['command'] = completer.CommandCompleter() - method.DATATYPES['shell'] = completer.ShellCompleter() - method.DATATYPES['config'] = completer.ConfigCompleter() - method.DATATYPES['method'] = completer.MethodCompleter() - method.DATATYPES['register'] = completer.RegisterCompleter() - method.DATATYPES['mode'] = completer.ModeCompleter() - #method.DATATYPES['perlfunction'] = completer.PerlFunctionCompleter() + method.DATATYPES['path'] = completer.FileCompleter() + method.DATATYPES['buffer'] = completer.BufferCompleter(self) + method.DATATYPES['command'] = completer.CommandCompleter() + method.DATATYPES['shell'] = completer.ShellCompleter() + method.DATATYPES['config'] = completer.ConfigCompleter() + method.DATATYPES['method'] = completer.MethodCompleter() + method.DATATYPES['register'] = completer.RegisterCompleter() + method.DATATYPES['mode'] = completer.ModeCompleter() # set up curses self.win = curses.newwin(self.y, self.x, 0, 0) @@ -584,20 +580,18 @@ class Application(object): else: p = w.logical_cursor() + blen = len(w.buffer.lines) count = 0 (x, y) = w.first.xy() (vy, vx) = (None, None) while count < slot.height: - 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) + 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 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 y += 1 - #XYZ - #while w.ishidden(y) and y < len(w.buffer.lines): - # y += 1 else: x += swidth count += 1 diff --git a/code_examples/Reporting2.pm b/code_examples/Reporting2.pm index 3afafa2..838375d 100644 --- a/code_examples/Reporting2.pm +++ b/code_examples/Reporting2.pm @@ -2,13 +2,13 @@ package TBB::Reporting2; my $bar =~ s/foob/blag/g; +#@@:heredoc.string:xml sub foo { bar() unless 9 && 3; } #@@:heredoc:sql -#@@:heredoc.string:xml my $s = <bar bar'; drop table foog; diff --git a/lex.py b/lex.py index c204e1d..fcc30d5 100755 --- a/lex.py +++ b/lex.py @@ -118,7 +118,8 @@ class OverridePatternRule(PatternRule): modecls = a.modes[d['mode']] mode = modecls(FakeWindow(lexer.mode.window.application)) 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: raise OverrideError, "argh: %r" % mode except (KeyError, AttributeError, OverrideError): @@ -237,6 +238,7 @@ class RegionRule(Rule): # 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. fqname = toresume[0].fqname() + rname = toresume[0].rule.name p = Point(toresume[0].x, toresume[0].y) if fqname in lexer.mode.ghist and p in lexer.mode.ghist[fqname]: mode = lexer.mode.ghist[fqname][p] @@ -247,6 +249,16 @@ class RegionRule(Rule): lexer.mode.ghist.setdefault(fqname, {}) lexer.mode.ghist[fqname][p] = mode 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: mode = lexer.mode if self.pairs[i][0] is not None: @@ -476,7 +488,4 @@ class Lexer(object): v = list(app.token_colors[name]) break - # bold colors seem to always look nicer. - if True: - v.append('bold') return v diff --git a/mode/about.py b/mode/about.py index 127d08f..3d8b4d7 100644 --- a/mode/about.py +++ b/mode/about.py @@ -17,14 +17,14 @@ class About(mode.Fundamental): modename = 'About' grammar = AboutGrammar() colors = { - 'about_stars': ('yellow', 'default'), - 'about_equals': ('red', 'default'), - 'about_pmacs': ('cyan', 'default'), - 'about_author': ('cyan', 'default'), - 'about_copyright': ('blue', 'default'), - 'about_license': ('cyan', 'default'), - 'about_binding': ('cyan', 'default'), - 'about_command': ('blue', 'default'), + 'about_stars': ('yellow', 'default', 'bold'), + 'about_equals': ('red', 'default', 'bold'), + 'about_pmacs': ('cyan', 'default', 'bold'), + 'about_author': ('cyan', 'default', 'bold'), + 'about_copyright': ('blue', 'default', 'bold'), + 'about_license': ('cyan', 'default', 'bold'), + 'about_binding': ('cyan', 'default', 'bold'), + 'about_command': ('blue', 'default', 'bold'), } install = About.install diff --git a/mode/bds.py b/mode/bds.py index ae877e7..eeaa937 100644 --- a/mode/bds.py +++ b/mode/bds.py @@ -47,12 +47,12 @@ class BDS(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'bds_derived': ('yellow', 'default'), - 'bds_question': ('yellow', 'default'), - 'bds_misquoted': ('yellow', 'red'), - 'bds_function': ('magenta', 'default'), - 'bds_perlfunc': ('magenta', 'default'), - 'bds_operator': ('magenta', 'default'), + 'bds_derived': ('yellow', 'default', 'bold'), + 'bds_question': ('yellow', 'default', 'bold'), + 'bds_misquoted': ('yellow', 'red', 'bold'), + 'bds_function': ('magenta', 'default', 'bold'), + 'bds_perlfunc': ('magenta', 'default', 'bold'), + 'bds_operator': ('magenta', 'default', 'bold'), } actions = [BDSMakeInstall, BDSCompileResources, BDSRestart] def __init__(self, w): diff --git a/mode/c.py b/mode/c.py index 61c3550..6259543 100644 --- a/mode/c.py +++ b/mode/c.py @@ -213,28 +213,28 @@ class C(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'macrocomment.start': ('red', 'default'), - 'macrocomment.null': ('red', 'default'), - 'macrocomment.end': ('red', 'default'), - 'macro': ('blue', 'default'), - 'macro.start': ('blue', 'default'), - 'macro.name': ('yellow', 'default'), - 'macro.null': ('magenta', 'default'), - 'macro.continued': ('red', 'default'), - 'macro.delimiter': ('default', 'default'), - 'macro.integer': ('green', 'default'), - 'macro.float': ('green', 'default'), - 'macro.char': ('green', 'default'), - 'macro.string.start': ('green', 'default'), - 'macro.string.escaped': ('magenta', 'default'), - 'macro.string.octal': ('magenta', 'default'), - 'macro.string.null': ('green', 'default'), - 'macro.string.end': ('green', 'default'), - 'macro.end': ('magenta', 'default'), - 'include': ('blue', 'default'), - 'header': ('green', 'default'), - 'structname': ('yellow', 'default'), - 'enumname': ('yellow', 'default'), + 'macrocomment.start': ('red', 'default', 'bold'), + 'macrocomment.null': ('red', 'default', 'bold'), + 'macrocomment.end': ('red', 'default', 'bold'), + 'macro': ('blue', 'default', 'bold'), + 'macro.start': ('blue', 'default', 'bold'), + 'macro.name': ('yellow', 'default', 'bold'), + 'macro.null': ('magenta', 'default', 'bold'), + 'macro.continued': ('red', 'default', 'bold'), + 'macro.delimiter': ('default', 'default', 'bold'), + 'macro.integer': ('green', 'default', 'bold'), + 'macro.float': ('green', 'default', 'bold'), + 'macro.char': ('green', 'default', 'bold'), + 'macro.string.start': ('green', 'default', 'bold'), + 'macro.string.escaped': ('magenta', 'default', 'bold'), + 'macro.string.octal': ('magenta', 'default', 'bold'), + 'macro.string.null': ('green', 'default', 'bold'), + 'macro.string.end': ('green', 'default', 'bold'), + 'macro.end': ('magenta', 'default', 'bold'), + 'include': ('blue', 'default', 'bold'), + 'header': ('green', 'default', 'bold'), + 'structname': ('yellow', 'default', 'bold'), + 'enumname': ('yellow', 'default', 'bold'), } config = { 'c.syntax-cmd': "gcc -x c -fsyntax-only %(path)s", diff --git a/mode/cheetah.py b/mode/cheetah.py index 1e6706b..8759215 100644 --- a/mode/cheetah.py +++ b/mode/cheetah.py @@ -37,16 +37,16 @@ class Template(mode.Fundamental): extensions = ['.tmpl'] grammar = TemplateGrammar colors = { - 'cheetah_directive': ('magenta', 'default'), - 'cheetah_placeholder': ('magenta', 'default'), - 'cheetah_tag.start': ('default', 'default'), - 'cheetah_tag.namespace': ('magenta', 'default'), - 'cheetah_tag.name': ('blue', 'default'), - 'cheetah_tag.attrname': ('cyan', 'default'), - 'cheetah_tag.string.start': ('green', 'default'), - 'cheetah_tag.string.null': ('green', 'default'), - 'cheetah_tag.string.end': ('green', 'default'), - 'cheetah_tag.end': ('default', 'default'), + 'cheetah_directive': ('magenta', 'default', 'bold'), + 'cheetah_placeholder': ('magenta', 'default', 'bold'), + 'cheetah_tag.start': ('default', 'default', 'bold'), + 'cheetah_tag.namespace': ('magenta', 'default', 'bold'), + 'cheetah_tag.name': ('blue', 'default', 'bold'), + 'cheetah_tag.attrname': ('cyan', 'default', 'bold'), + 'cheetah_tag.string.start': ('green', 'default', 'bold'), + 'cheetah_tag.string.null': ('green', 'default', 'bold'), + 'cheetah_tag.string.end': ('green', 'default', 'bold'), + 'cheetah_tag.end': ('default', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/console.py b/mode/console.py index 87d69a1..f9ceba9 100644 --- a/mode/console.py +++ b/mode/console.py @@ -15,8 +15,8 @@ class Console(mode.Fundamental): modename = 'Console' grammar = ConsoleGrammar() colors = { - 'console_mesg': ('blue', 'default'), - 'console_input': ('cyan', 'default'), + 'console_mesg': ('blue', 'default', 'bold'), + 'console_input': ('cyan', 'default', 'bold'), } install = Console.install diff --git a/mode/css.py b/mode/css.py index 58ba434..6e79172 100644 --- a/mode/css.py +++ b/mode/css.py @@ -50,25 +50,25 @@ class CSS(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'css_dimension': ('magenta', 'default'), - 'css_percentage': ('magenta', 'default'), - 'css_length': ('magenta', 'default'), - 'css_real': ('magenta', 'default'), - 'css_int': ('magenta', 'default'), - 'css_color': ('magenta', 'default'), + 'css_dimension': ('magenta', 'default', 'bold'), + 'css_percentage': ('magenta', 'default', 'bold'), + 'css_length': ('magenta', 'default', 'bold'), + 'css_real': ('magenta', 'default', 'bold'), + 'css_int': ('magenta', 'default', 'bold'), + 'css_color': ('magenta', 'default', 'bold'), - 'css_hash': ('cyan', 'default'), - 'css_rule': ('cyan', 'default'), - 'css_label': ('cyan', 'default'), - 'css_keyword': ('cyan', 'default'), - 'css_ident': ('default', 'default'), - 'css_name': ('default', 'default'), - 'css_keyword': ('cyan', 'default'), - 'css_keyword.start': ('default', 'default'), - 'css_keyword.null': ('cyan', 'default'), - 'css_keyword.octal': ('magenta', 'default'), - 'css_keyword.escaped': ('magenta', 'default'), - 'css_keyword.end': ('default', 'default'), + 'css_hash': ('cyan', 'default', 'bold'), + 'css_rule': ('cyan', 'default', 'bold'), + 'css_label': ('cyan', 'default', 'bold'), + 'css_keyword': ('cyan', 'default', 'bold'), + 'css_ident': ('default', 'default', 'bold'), + 'css_name': ('default', 'default', 'bold'), + 'css_keyword': ('cyan', 'default', 'bold'), + 'css_keyword.start': ('default', 'default', 'bold'), + 'css_keyword.null': ('cyan', 'default', 'bold'), + 'css_keyword.octal': ('magenta', 'default', 'bold'), + 'css_keyword.escaped': ('magenta', 'default', 'bold'), + 'css_keyword.end': ('default', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/dir.py b/mode/dir.py index 768f48b..52bbc1a 100644 --- a/mode/dir.py +++ b/mode/dir.py @@ -165,31 +165,31 @@ class Dir(mode.Fundamental): modename = 'Dir' grammar = DirGrammar() colors = { - 'dir_blk.start': ('cyan', 'default'), - 'dir_blk.name': ('cyan', 'default'), - 'dir_chr.start': ('yellow', 'default'), - 'dir_chr.name': ('yellow', 'default'), - 'dir_dir.start': ('blue', 'default'), - 'dir_dir.dir_name': ('blue', 'default'), - 'dir_lnk.start': ('green', 'default'), - 'dir_lnk.name': ('green', 'default'), - 'dir_fifo.start': ('red', 'default'), - 'dir_fifo.name': ('red', 'default'), - 'dir_sock.start': ('red', 'default'), - 'dir_sock.name': ('red', 'default'), - 'dir_unk.start': ('magenta', 'default'), - 'dir_unk.name': ('magenta', 'default'), + 'dir_blk.start': ('cyan', 'default', 'bold'), + 'dir_blk.name': ('cyan', 'default', 'bold'), + 'dir_chr.start': ('yellow', 'default', 'bold'), + 'dir_chr.name': ('yellow', 'default', 'bold'), + 'dir_dir.start': ('blue', 'default', 'bold'), + 'dir_dir.dir_name': ('blue', 'default', 'bold'), + 'dir_lnk.start': ('green', 'default', 'bold'), + 'dir_lnk.name': ('green', 'default', 'bold'), + 'dir_fifo.start': ('red', 'default', 'bold'), + 'dir_fifo.name': ('red', 'default', 'bold'), + 'dir_sock.start': ('red', 'default', 'bold'), + 'dir_sock.name': ('red', 'default', 'bold'), + 'dir_unk.start': ('magenta', 'default', 'bold'), + 'dir_unk.name': ('magenta', 'default', 'bold'), - 'dir_perm.perm_setid': ('yellow', 'default'), - 'dir_perm.perm_sticky': ('yellow', 'default'), - 'dir_perm.perm_read': ('magenta', 'default'), - 'dir_perm.perm_write': ('magenta', 'default'), - 'dir_perm.perm_exec': ('magenta', 'default'), + 'dir_perm.perm_setid': ('yellow', 'default', 'bold'), + 'dir_perm.perm_sticky': ('yellow', 'default', 'bold'), + 'dir_perm.perm_read': ('magenta', 'default', 'bold'), + 'dir_perm.perm_write': ('magenta', 'default', 'bold'), + 'dir_perm.perm_exec': ('magenta', 'default', 'bold'), - 'dir_owner': ('cyan', 'default'), - 'dir_group': ('cyan', 'default'), - 'dir_size': ('yellow', 'default'), - 'dir_mtime': ('green', 'default'), + 'dir_owner': ('cyan', 'default', 'bold'), + 'dir_group': ('cyan', 'default', 'bold'), + 'dir_size': ('yellow', 'default', 'bold'), + 'dir_mtime': ('green', 'default', 'bold'), } actions = [RefreshView, OpenPath, DirGrep, Chmod, Chown, Chgrp, TouchPath, RemovePath] diff --git a/mode/elisp.py b/mode/elisp.py index 1984697..bb15073 100644 --- a/mode/elisp.py +++ b/mode/elisp.py @@ -39,10 +39,10 @@ class ELisp(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'elisp_keyword': ('cyan', 'default'), - 'elisp_reserved': ('blue', 'default'), - 'elisp_symbol': ('magenta', 'default'), - 'elisp_type': ('blue', 'default'), + 'elisp_keyword': ('cyan', 'default', 'bold'), + 'elisp_reserved': ('blue', 'default', 'bold'), + 'elisp_symbol': ('magenta', 'default', 'bold'), + 'elisp_type': ('blue', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/erlang.py b/mode/erlang.py new file mode 100644 index 0000000..5c60aaf --- /dev/null +++ b/mode/erlang.py @@ -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 diff --git a/mode/haskell.py b/mode/haskell.py index abdd3f9..45b5f8d 100644 --- a/mode/haskell.py +++ b/mode/haskell.py @@ -38,17 +38,17 @@ class Haskell(mode.Fundamental): #closetokens = ('delimiter',) #closetags = {')': '('} colors = { - 'hs_reserved': ('cyan', 'default'), - 'hs_constructor': ('magenta', 'default'), - 'hs_declaration': ('blue', 'default'), - 'hs_operator': ('green', 'default'), - 'hs_string.start': ('green', 'default'), - 'hs_string.null': ('green', 'default'), - 'hs_string.end': ('green', 'default'), - 'hs_string.escaped': ('magenta', 'default'), - 'hs_string.gap.start': ('red', 'default'), - 'hs_string.gap.null': ('red', 'default'), - 'hs_string.gap.end': ('red', 'default'), + 'hs_reserved': ('cyan', 'default', 'bold'), + 'hs_constructor': ('magenta', 'default', 'bold'), + 'hs_declaration': ('blue', 'default', 'bold'), + 'hs_operator': ('green', 'default', 'bold'), + 'hs_string.start': ('green', 'default', 'bold'), + 'hs_string.null': ('green', 'default', 'bold'), + 'hs_string.end': ('green', 'default', 'bold'), + 'hs_string.escaped': ('magenta', 'default', 'bold'), + 'hs_string.gap.start': ('red', 'default', 'bold'), + 'hs_string.gap.null': ('red', 'default', 'bold'), + 'hs_string.gap.end': ('red', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/html.py b/mode/html.py index e7c870f..d1291ca 100644 --- a/mode/html.py +++ b/mode/html.py @@ -54,14 +54,14 @@ class HTML(mode.Fundamental): } _colorbase = { - 'start': ('default', 'default'), - 'namespace': ('magenta', 'default'), - 'name': ('blue', 'default'), - 'attrname': ('cyan', 'default'), - 'string.start': ('green', 'default'), - 'string.null': ('green', 'default'), - 'string.end': ('green', 'default'), - 'end': ('default', 'default'), + 'start': ('default', 'default', 'bold'), + 'namespace': ('magenta', 'default', 'bold'), + 'name': ('blue', 'default', 'bold'), + 'attrname': ('cyan', 'default', 'bold'), + 'string.start': ('green', 'default', 'bold'), + 'string.null': ('green', 'default', 'bold'), + 'string.end': ('green', 'default', 'bold'), + 'end': ('default', 'default', 'bold'), } for _name in _colorbase: colors['script.%s' % _name] = _colorbase[_name] diff --git a/mode/java.py b/mode/java.py index 6b11e44..5d1fe64 100644 --- a/mode/java.py +++ b/mode/java.py @@ -164,15 +164,15 @@ class Java(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'doccomment.start': ('red', 'default'), - 'doccomment.end': ('red', 'default'), - 'doccomment.null': ('red', 'default'), - 'import': ('blue', 'default'), - 'java_label': ('magenta', 'default'), - 'java_builtin': ('magenta', 'default'), - 'java_char': ('green', 'default'), - 'java_integer': ('green', 'default'), - 'java_float': ('green', 'default'), + 'doccomment.start': ('red', 'default', 'bold'), + 'doccomment.end': ('red', 'default', 'bold'), + 'doccomment.null': ('red', 'default', 'bold'), + 'import': ('blue', 'default', 'bold'), + 'java_label': ('magenta', 'default', 'bold'), + 'java_builtin': ('magenta', 'default', 'bold'), + 'java_char': ('green', 'default', 'bold'), + 'java_integer': ('green', 'default', 'bold'), + 'java_float': ('green', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/javascript.py b/mode/javascript.py index b77ae09..4a46708 100644 --- a/mode/javascript.py +++ b/mode/javascript.py @@ -63,15 +63,15 @@ class Javascript(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'js_function': ('blue', 'default'), - 'js_class': ('green', 'default'), - 'js_reserved': ('cyan', 'default'), - 'js_nonreserved': ('cyan', 'default'), - 'js_regex.start': ('cyan', 'default'), - 'js_regex.null': ('cyan', 'default'), - 'js_regex.octal': ('magenta', 'default'), - 'js_regex.escaped': ('magenta', 'default'), - 'js_regex.end': ('cyan', 'default'), + 'js_function': ('blue', 'default', 'bold'), + 'js_class': ('green', 'default', 'bold'), + 'js_reserved': ('cyan', 'default', 'bold'), + 'js_nonreserved': ('cyan', 'default', 'bold'), + 'js_regex.start': ('cyan', 'default', 'bold'), + 'js_regex.null': ('cyan', 'default', 'bold'), + 'js_regex.octal': ('magenta', 'default', 'bold'), + 'js_regex.escaped': ('magenta', 'default', 'bold'), + 'js_regex.end': ('cyan', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/make.py b/mode/make.py index d1c256f..aab9b48 100644 --- a/mode/make.py +++ b/mode/make.py @@ -28,14 +28,14 @@ class Make(mode.Fundamental): grammar = MakeGrammar savetabs = True colors = { - 'targets.start': ('cyan', 'default'), - 'assignment.start': ('yellow', 'default'), - 'make_variable': ('yellow', 'default'), - 'make_string.start': ('green', 'default'), - 'make_string.variable': ('yellow', 'default'), - 'make_string.escaped': ('magenta', 'default'), - 'make_string.null': ('green', 'default'), - 'make_string.end': ('green', 'default'), + 'targets.start': ('cyan', 'default', 'bold'), + 'assignment.start': ('yellow', 'default', 'bold'), + 'make_variable': ('yellow', 'default', 'bold'), + 'make_string.start': ('green', 'default', 'bold'), + 'make_string.variable': ('yellow', 'default', 'bold'), + 'make_string.escaped': ('magenta', 'default', 'bold'), + 'make_string.null': ('green', 'default', 'bold'), + 'make_string.end': ('green', 'default', 'bold'), } install = Make.install diff --git a/mode/mini.py b/mode/mini.py index 84567ba..4edf5c4 100644 --- a/mode/mini.py +++ b/mode/mini.py @@ -19,18 +19,6 @@ class Mini(mode.Fundamental): actions = [MiniCallback, MiniTabComplete] def __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-tab-complete', ('TAB',)) diff --git a/mode/mutt.py b/mode/mutt.py index 9db5d5c..146e305 100644 --- a/mode/mutt.py +++ b/mode/mutt.py @@ -27,18 +27,18 @@ class Mutt(mode.Fundamental): modename = 'Mutt' grammar = MuttGrammar() colors = { - 'mutt_header': ('green', 'default', 'bold'), - 'email': ('cyan', 'default', 'bold'), - 'url': ('cyan', 'default', 'bold'), - 'quotea': ('yellow', 'default', 'bold'), - 'quoteb': ('cyan', 'default', 'bold'), - 'quotec': ('magenta', 'default', 'bold'), - 'misspelled': ('red', 'default'), - 'cont.start': ('default', 'default'), - 'cont.end': ('default', 'default'), - 'word': ('default', 'default'), - 'punct': ('default', 'default'), - 'stuff': ('default', 'default'), + 'mutt_header': ('green', 'default', 'bold'), + 'email': ('cyan', 'default', 'bold'), + 'url': ('cyan', 'default', 'bold'), + 'quotea': ('yellow', 'default', 'bold'), + 'quoteb': ('cyan', 'default', 'bold'), + 'quotec': ('magenta', 'default', 'bold'), + 'misspelled': ('red', 'default', 'bold'), + 'cont.start': ('default', 'default', 'bold'), + 'cont.end': ('default', 'default', 'bold'), + 'word': ('default', 'default', 'bold'), + 'punct': ('default', 'default', 'bold'), + 'stuff': ('default', 'default', 'bold'), } actions = [MuttInsertSpace, MuttWrapParagraph] def __init__(self, w): diff --git a/mode/nasm.py b/mode/nasm.py index a26307c..689854f 100644 --- a/mode/nasm.py +++ b/mode/nasm.py @@ -33,9 +33,9 @@ class Nasm(mode.Fundamental): colors = { 'nasm_keyword': ('cyan', 'default', 'bold'), 'macros': ('blue', 'default', 'bold'), - 'registers': ('yellow', 'default'), - 'instructions': ('magenta', 'default'), - 'nasm_label': ('blue', 'default'), + 'registers': ('yellow', 'default', 'bold'), + 'instructions': ('magenta', 'default', 'bold'), + 'nasm_label': ('blue', 'default', 'bold'), } install = Nasm.install diff --git a/mode/ocaml.py b/mode/ocaml.py index fde349b..df96a52 100644 --- a/mode/ocaml.py +++ b/mode/ocaml.py @@ -56,16 +56,16 @@ class Ocaml(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '('} colors = { - 'linenum': ('red', 'default'), - 'ocaml_keyword': ('cyan', 'default'), - 'ocaml_label': ('blue', 'default'), - 'optlabel': ('blue', 'default'), - 'ocaml_string.start': ('green', 'default'), - 'ocaml_string.null': ('green', 'default'), - 'ocaml_string.octal': ('magenta', 'default'), - 'ocaml_string.hex': ('magenta', 'default'), - 'ocaml_string.escaped': ('magenta', 'default'), - 'ocaml_string.end': ('green', 'default'), + 'linenum': ('red', 'default', 'bold'), + 'ocaml_keyword': ('cyan', 'default', 'bold'), + 'ocaml_label': ('blue', 'default', 'bold'), + 'optlabel': ('blue', 'default', 'bold'), + 'ocaml_string.start': ('green', 'default', 'bold'), + 'ocaml_string.null': ('green', 'default', 'bold'), + 'ocaml_string.octal': ('magenta', 'default', 'bold'), + 'ocaml_string.hex': ('magenta', 'default', 'bold'), + 'ocaml_string.escaped': ('magenta', 'default', 'bold'), + 'ocaml_string.end': ('green', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/perl.py b/mode/perl.py index aa2548e..022f395 100644 --- a/mode/perl.py +++ b/mode/perl.py @@ -595,97 +595,93 @@ class Perl(mode.Fundamental): closetags = {')': '(', ']': '[', '}': '{'} colors = { # comments - 'endblock.start': ('red', 'default'), - 'endblock.null': ('red', 'default'), - 'endblock.end': ('red', 'default'), + 'endblock.start': ('red', 'default', 'bold'), + 'endblock.null': ('red', 'default', 'bold'), + 'endblock.end': ('red', 'default', 'bold'), # pod - 'pod.start': ('red', 'default'), - 'pod.null': ('red', 'default'), - 'pod.entry.start': ('magenta', 'default'), - 'pod.entry.null': ('magenta', 'default'), - 'pod.entry.end': ('magenta', 'default'), - 'pod.end': ('red', 'default'), + 'pod.start': ('red', 'default', 'bold'), + 'pod.null': ('red', 'default', 'bold'), + 'pod.entry.start': ('magenta', 'default', 'bold'), + 'pod.entry.null': ('magenta', 'default', 'bold'), + 'pod.entry.end': ('magenta', 'default', 'bold'), + 'pod.end': ('red', 'default', 'bold'), # basic stuff - 'escaped': ('magenta', 'default'), - 'null': ('default', 'default'), - 'sub': ('cyan', 'default'), - 'prototype': ('magenta', 'default'), - 'number': ('default', 'default'), - 'operator': ('default', 'default'), - 'noperator': ('magenta', 'default'), - 'endblock': ('red', 'default'), - 'perl_keyword': ('magenta', 'default'), - 'cast': ('yellow', 'default'), - 'scalar': ('yellow', 'default'), - 'array': ('yellow', 'default'), - 'deref': ('yellow', 'default'), - 'perl_hash': ('yellow', 'default'), - 'hash_key': ('green', 'default'), - 'perl_function': ('cyan', 'default'), - 'perl_builtin': ('magenta', 'default'), - #'method': ('cyan', 'default'), - #'bareword': ('default', 'default'), - 'perl_label': ('cyan', 'default'), - 'package': ('cyan', 'default'), - 'perl_class': ('cyan', 'default'), - 'use': ('cyan', 'default'), - 'require': ('cyan', 'default'), - #'method': ('cyan', 'default'), + 'escaped': ('magenta', 'default', 'bold'), + 'null': ('default', 'default', 'bold'), + 'sub': ('cyan', 'default', 'bold'), + 'prototype': ('magenta', 'default', 'bold'), + 'operator': ('default', 'default', 'bold'), + 'noperator': ('magenta', 'default', 'bold'), + 'endblock': ('red', 'default', 'bold'), + 'perl_keyword': ('magenta', 'default', 'bold'), + 'cast': ('yellow', 'default', 'bold'), + 'scalar': ('yellow', 'default', 'bold'), + 'array': ('yellow', 'default', 'bold'), + 'deref': ('yellow', 'default', 'bold'), + 'perl_hash': ('yellow', 'default', 'bold'), + 'hash_key': ('green', 'default', 'bold'), + 'perl_function': ('cyan', 'default', 'bold'), + 'perl_builtin': ('magenta', 'default', 'bold'), + 'perl_label': ('cyan', 'default', 'bold'), + 'package': ('cyan', 'default', 'bold'), + 'perl_class': ('cyan', 'default', 'bold'), + 'use': ('cyan', 'default', 'bold'), + 'require': ('cyan', 'default', 'bold'), # heredoc/evaldoc - 'heredoc.start': ('green', 'default'), - 'heredoc.null': ('green', 'default'), - 'heredoc.end': ('green', 'default'), - 'evaldoc.start': ('cyan', 'default'), - 'evaldoc.null': ('cyan', 'default'), - 'evaldoc.end': ('cyan', 'default'), + 'heredoc.start': ('green', 'default', 'bold'), + 'heredoc.null': ('green', 'default', 'bold'), + 'heredoc.end': ('green', 'default', 'bold'), + 'evaldoc.start': ('cyan', 'default', 'bold'), + 'evaldoc.null': ('cyan', 'default', 'bold'), + 'evaldoc.end': ('cyan', 'default', 'bold'), # strings - 'perl_string.start': ('green', 'default'), - 'perl_string.null': ('green', 'default'), - 'perl_string.escaped': ('magenta', 'default'), - 'perl_string.deref': ('yellow', 'default'), - 'perl_string.end': ('green', 'default'), + 'perl_string.start': ('green', 'default', 'bold'), + 'perl_string.null': ('green', 'default', 'bold'), + 'perl_string.escaped': ('magenta', 'default', 'bold'), + 'perl_string.deref': ('yellow', 'default', 'bold'), + 'perl_string.end': ('green', 'default', 'bold'), # `` strings - 'evalstring.start': ('cyan', 'default'), - 'evalstring.null': ('cyan', 'default'), - 'evalstring.escaped': ('magenta', 'default'), - 'evalstring.deref': ('yellow', 'default'), - 'evalstring.end': ('cyan', 'default'), + 'evalstring.start': ('cyan', 'default', 'bold'), + 'evalstring.null': ('cyan', 'default', 'bold'), + 'evalstring.escaped': ('magenta', 'default', 'bold'), + 'evalstring.deref': ('yellow', 'default', 'bold'), + 'evalstring.end': ('cyan', 'default', 'bold'), # quoted region - 'quoted': ('cyan', 'default'), - 'quoted.start': ('cyan', 'default'), - 'quoted.null': ('cyan', 'default'), - 'quoted.escaped': ('magenta', 'default'), - 'quoted.deref': ('yellow', 'default'), - 'quoted.end': ('cyan', 'default'), + 'quoted': ('cyan', 'default', 'bold'), + 'quoted.start': ('cyan', 'default', 'bold'), + 'quoted.null': ('cyan', 'default', 'bold'), + 'quoted.escaped': ('magenta', 'default', 'bold'), + 'quoted.deref': ('yellow', 'default', 'bold'), + 'quoted.end': ('cyan', 'default', 'bold'), # match regex - 'match.start': ('cyan', 'default'), - 'match.end': ('cyan', 'default'), - 'match.null': ('cyan', 'default'), + 'match.start': ('cyan', 'default', 'bold'), + 'match.end': ('cyan', 'default', 'bold'), + 'match.null': ('cyan', 'default', 'bold'), # replace regex - 'replace.start': ('cyan', 'default'), - 'replace.middle0': ('cyan', 'default'), - 'replace.end': ('cyan', 'default'), - 'replace.null': ('cyan', 'default'), - 'replace.escaped': ('magenta', 'default'), - 'replace.deref': ('yellow', 'default'), - 'replace.length': ('yellow', 'default'), - 'replace.scalar': ('yellow', 'default'), - 'replace.perl_hash': ('yellow', 'default'), - 'replace.cast': ('yellow', 'default'), + 'replace.start': ('cyan', 'default', 'bold'), + 'replace.middle0': ('cyan', 'default', 'bold'), + 'replace.end': ('cyan', 'default', 'bold'), + 'replace.null': ('cyan', 'default', 'bold'), + 'replace.escaped': ('magenta', 'default', 'bold'), + 'replace.deref': ('yellow', 'default', 'bold'), + 'replace.length': ('yellow', 'default', 'bold'), + 'replace.scalar': ('yellow', 'default', 'bold'), + 'replace.perl_hash': ('yellow', 'default', 'bold'), + 'replace.cast': ('yellow', 'default', 'bold'), # translate regex - 'translate.start': ('magenta', 'default'), - 'translate.middle0': ('magenta', 'default'), - 'translate.end': ('magenta', 'default'), - 'translate.null': ('magenta', 'default'), + 'translate.start': ('magenta', 'default', 'bold'), + 'translate.middle0': ('magenta', 'default', 'bold'), + 'translate.end': ('magenta', 'default', 'bold'), + 'translate.null': ('magenta', 'default', 'bold'), } config = { 'perl.lib': 'lib', diff --git a/mode/python.py b/mode/python.py index 0ca6598..3c8b4ab 100644 --- a/mode/python.py +++ b/mode/python.py @@ -359,16 +359,16 @@ class Python(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'python_keyword': ('cyan', 'default'), - 'python_reserved': ('magenta', 'default'), - 'python_builtin': ('cyan', 'default'), - 'functionname': ('blue', 'default'), - 'classname': ('green', 'default'), - 'rawstring.start': ('green', 'default'), - 'rawstring.null': ('green', 'default'), - 'rawstring.escaped': ('green', 'default'), - 'rawstring.end': ('green', 'default'), - 'system_identifier': ('cyan', 'default'), + 'python_keyword': ('cyan', 'default', 'bold'), + 'python_reserved': ('magenta', 'default', 'bold'), + 'python_builtin': ('cyan', 'default', 'bold'), + 'functionname': ('blue', 'default', 'bold'), + 'classname': ('green', 'default', 'bold'), + 'rawstring.start': ('green', 'default', 'bold'), + 'rawstring.null': ('green', 'default', 'bold'), + 'rawstring.escaped': ('green', 'default', 'bold'), + 'rawstring.end': ('green', 'default', 'bold'), + 'system_identifier': ('cyan', 'default', 'bold'), } config = { 'python.lib': '.', diff --git a/mode/rst.py b/mode/rst.py index 67737f9..d918b24 100644 --- a/mode/rst.py +++ b/mode/rst.py @@ -52,35 +52,35 @@ class RST(mode.Fundamental): extensions = ['.rst'] grammar = RSTGrammar colors = { - 'title': ('blue', 'default'), - 'title_over': ('blue', 'default'), - 'title_under': ('blue', 'default'), - 'subtitle': ('cyan', 'default'), - 'subtitle_over': ('cyan', 'default'), - 'subtitle_under': ('cyan', 'default'), + 'title': ('blue', 'default', 'bold'), + 'title_over': ('blue', 'default', 'bold'), + 'title_under': ('blue', 'default', 'bold'), + 'subtitle': ('cyan', 'default', 'bold'), + 'subtitle_over': ('cyan', 'default', 'bold'), + 'subtitle_under': ('cyan', 'default', 'bold'), - 'definition': ('green', 'default'), - 'fieldname': ('green', 'default'), - 'optionname': ('green', 'default'), + 'definition': ('green', 'default', 'bold'), + 'fieldname': ('green', 'default', 'bold'), + 'optionname': ('green', 'default', 'bold'), - 'lineblock': ('cyan', 'default'), - 'blocktest': ('cyan', 'default'), - 'transition': ('cyan', 'default'), + 'lineblock': ('cyan', 'default', 'bold'), + 'blocktest': ('cyan', 'default', 'bold'), + 'transition': ('cyan', 'default', 'bold'), - 'emphasis': ('red', 'default'), - 'strong_emphasis': ('red', 'default'), - 'interpreted': ('magenta', 'default'), - 'inline_literal': ('magenta', 'default'), - 'substitution': ('magenta', 'default'), + 'emphasis': ('red', 'default', 'bold'), + 'strong_emphasis': ('red', 'default', 'bold'), + 'interpreted': ('magenta', 'default', 'bold'), + 'inline_literal': ('magenta', 'default', 'bold'), + 'substitution': ('magenta', 'default', 'bold'), - 'anonymous': ('blue', 'default'), - 'reference': ('blue', 'default'), - 'footnote': ('blue', 'default'), - 'citation': ('blue', 'default'), - 'rst_url': ('blue', 'default'), + 'anonymous': ('blue', 'default', 'bold'), + 'reference': ('blue', 'default', 'bold'), + 'footnote': ('blue', 'default', 'bold'), + 'citation': ('blue', 'default', 'bold'), + 'rst_url': ('blue', 'default', 'bold'), - 'bullet': ('magenta', 'default'), - 'enumeration': ('magenta', 'default'), + 'bullet': ('magenta', 'default', 'bold'), + 'enumeration': ('magenta', 'default', 'bold'), } actions = [RstInsertSpace, RstWrapParagraph] def __init__(self, w): diff --git a/mode/scheme.py b/mode/scheme.py index 9fb92fe..dd95913 100644 --- a/mode/scheme.py +++ b/mode/scheme.py @@ -48,10 +48,10 @@ class Scheme(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '('} colors = { - 'scheme_keyword': ('cyan', 'default'), - 'scheme_char': ('green', 'default'), - 'scheme_boolean': ('magenta', 'default'), - 'scheme_number': ('default', 'default'), + 'scheme_keyword': ('cyan', 'default', 'bold'), + 'scheme_char': ('green', 'default', 'bold'), + 'scheme_boolean': ('magenta', 'default', 'bold'), + 'scheme_number': ('default', 'default', 'bold'), } actions = [SchemeCheckSyntax] def __init__(self, w): diff --git a/mode/sh.py b/mode/sh.py index ef1229a..29714ba 100644 --- a/mode/sh.py +++ b/mode/sh.py @@ -152,19 +152,18 @@ class Sh(mode.Fundamental): 'case.middle0': ('magenta', 'default', 'bold'), 'case.end': ('magenta', 'default', 'bold'), - #'delimiter': ('default', 'default', 'bold'), 'test.start': ('cyan', 'default', 'bold'), 'binop': ('magenta', 'default', 'bold'), 'unop': ('magenta', 'default', 'bold'), - 'eval.start': ('cyan', 'default'), - 'eval.variable': ('yellow', 'default'), - 'eval.null': ('cyan', 'default'), - 'eval.end': ('cyan', 'default'), - 'neval.start': ('yellow', 'default'), - 'neval.variable': ('yellow', 'default'), - 'neval.null': ('cyan', 'default'), - 'neval.end': ('yellow', 'default'), + 'eval.start': ('cyan', 'default', 'bold'), + 'eval.variable': ('yellow', 'default', 'bold'), + 'eval.null': ('cyan', 'default', 'bold'), + 'eval.end': ('cyan', 'default', 'bold'), + 'neval.start': ('yellow', 'default', 'bold'), + 'neval.variable': ('yellow', 'default', 'bold'), + 'neval.null': ('cyan', 'default', 'bold'), + 'neval.end': ('yellow', 'default', 'bold'), } actions = [ShCheckSyntax] def __init__(self, w): diff --git a/mode/sql.py b/mode/sql.py index 6a6207c..50036a1 100644 --- a/mode/sql.py +++ b/mode/sql.py @@ -117,28 +117,28 @@ class Sql(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'sql_operator': ('yellow', 'default'), - 'attribute': ('magenta', 'default'), - 'sql_keyword': ('cyan', 'default'), - 'pseudokeyword': ('cyan', 'default'), - 'sql_type': ('green', 'default'), - 'sql_builtin': ('yellow', 'default'), - 'sql_quoted.start': ('yellow', 'default'), - 'sql_quoted.null': ('yellow', 'default'), - 'sql_quoted.end': ('yellow', 'default'), - 'sql_variable': ('yellow', 'default'), - 'sql_bareword': ('default', 'default'), + 'sql_operator': ('yellow', 'default', 'bold'), + 'attribute': ('magenta', 'default', 'bold'), + 'sql_keyword': ('cyan', 'default', 'bold'), + 'pseudokeyword': ('cyan', 'default', 'bold'), + 'sql_type': ('green', 'default', 'bold'), + 'sql_builtin': ('yellow', 'default', 'bold'), + 'sql_quoted.start': ('yellow', 'default', 'bold'), + 'sql_quoted.null': ('yellow', 'default', 'bold'), + 'sql_quoted.end': ('yellow', 'default', 'bold'), + 'sql_variable': ('yellow', 'default', 'bold'), + 'sql_bareword': ('default', 'default', 'bold'), - 'function.start': ('cyan', 'default'), - 'function.null': ('default', 'default'), - 'function.name': ('magenta', 'default'), - 'function.language': ('magenta', 'default'), - 'function.end': ('default', 'default'), + 'function.start': ('cyan', 'default', 'bold'), + 'function.null': ('default', 'default', 'bold'), + 'function.name': ('magenta', 'default', 'bold'), + 'function.language': ('magenta', 'default', 'bold'), + 'function.end': ('default', 'default', 'bold'), - 'function.definition.start': ('magenta', 'default'), - 'function.definition.sql_bareword': ('magenta', 'default'), - 'function.definition.null': ('magenta', 'default'), - 'function.definition.end': ('magenta', 'default'), + 'function.definition.start': ('magenta', 'default', 'bold'), + 'function.definition.sql_bareword': ('magenta', 'default', 'bold'), + 'function.definition.null': ('magenta', 'default', 'bold'), + 'function.definition.end': ('magenta', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/text2.py b/mode/text2.py index 8c613a3..e0080d3 100644 --- a/mode/text2.py +++ b/mode/text2.py @@ -18,8 +18,8 @@ class Text2(mode.text.Text): extensions = ['.txt'] extensions = [] colors = { - 'text2_email': ('cyan', 'default'), - 'text2_url': ('green', 'default'), + 'text2_email': ('cyan', 'default', 'bold'), + 'text2_url': ('green', 'default', 'bold'), } install = Text2.install diff --git a/mode/tt.py b/mode/tt.py index 8fba683..000e0c4 100644 --- a/mode/tt.py +++ b/mode/tt.py @@ -32,25 +32,25 @@ class Template(mode.Fundamental): extensions = ['.tt'] grammar = TemplateGrammar colors = { - 'directive.start': ('magenta', 'default'), - 'directive.comment': ('red', 'default'), - 'directive.keyword': ('cyan', 'default'), - 'directive.string.start': ('green', 'default'), - 'directive.string.escaped': ('magenta', 'default'), - 'directive.string.octal': ('magenta', 'default'), - 'directive.string.null': ('green', 'default'), - 'directive.string.end': ('green', 'default'), - 'directive.null': ('magenta', 'default'), - 'directive.end': ('magenta', 'default'), + 'directive.start': ('magenta', 'default', 'bold'), + 'directive.comment': ('red', 'default', 'bold'), + 'directive.keyword': ('cyan', 'default', 'bold'), + 'directive.string.start': ('green', 'default', 'bold'), + 'directive.string.escaped': ('magenta', 'default', 'bold'), + 'directive.string.octal': ('magenta', 'default', 'bold'), + 'directive.string.null': ('green', 'default', 'bold'), + 'directive.string.end': ('green', 'default', 'bold'), + 'directive.null': ('magenta', 'default', 'bold'), + 'directive.end': ('magenta', 'default', 'bold'), - 'tt_tag.start': ('default', 'default'), - 'tt_tag.namespace': ('magenta', 'default'), - 'tt_tag.name': ('blue', 'default'), - 'tt_tag.attrname': ('cyan', 'default'), - 'tt_tag.string.start': ('green', 'default'), - 'tt_tag.string.null': ('green', 'default'), - 'tt_tag.string.end': ('green', 'default'), - 'tt_tag.end': ('default', 'default'), + 'tt_tag.start': ('default', 'default', 'bold'), + 'tt_tag.namespace': ('magenta', 'default', 'bold'), + 'tt_tag.name': ('blue', 'default', 'bold'), + 'tt_tag.attrname': ('cyan', 'default', 'bold'), + 'tt_tag.string.start': ('green', 'default', 'bold'), + 'tt_tag.string.null': ('green', 'default', 'bold'), + 'tt_tag.string.end': ('green', 'default', 'bold'), + 'tt_tag.end': ('default', 'default', 'bold'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/xml.py b/mode/xml.py index aef15ca..231c356 100644 --- a/mode/xml.py +++ b/mode/xml.py @@ -29,14 +29,14 @@ class XML(mode.Fundamental): extensions = ['.xml', '.xml.in'] grammar = XMLGrammar colors = { - 'xml_tag.start': ('default', 'default'), - 'xml_tag.namespace': ('magenta', 'default'), - 'xml_tag.name': ('blue', 'default'), - 'xml_tag.attrname': ('cyan', 'default'), - 'xml_tag.string.start': ('green', 'default'), - 'xml_tag.string.null': ('green', 'default'), - 'xml_tag.string.end': ('green', 'default'), - 'xml_tag.end': ('default', 'default'), + 'xml_tag.start': ('default', 'default', 'bold'), + 'xml_tag.namespace': ('magenta', 'default', 'bold'), + 'xml_tag.name': ('blue', 'default', 'bold'), + 'xml_tag.attrname': ('cyan', 'default', 'bold'), + 'xml_tag.string.start': ('green', 'default', 'bold'), + 'xml_tag.string.null': ('green', 'default', 'bold'), + 'xml_tag.string.end': ('green', 'default', 'bold'), + 'xml_tag.end': ('default', 'default', 'bold'), } actions = [XmlValidate] diff --git a/window.py b/window.py index 409824d..767856c 100644 --- a/window.py +++ b/window.py @@ -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 # 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 -# 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): margins = ((80, 'blue'),) @@ -31,18 +38,18 @@ class Window(object): if mode_name is not None: pass - elif hasattr(self.buffer, 'modename') and self.buffer.modename is not None: - mode_name = self.buffer.modename - elif self.buffer.btype == 'mini': + elif hasattr(b, 'modename') and b.modename is not None: + mode_name = b.modename + elif b.btype == 'mini': mode_name = 'mini' - elif self.buffer.btype == 'console': + elif b.btype == 'console': mode_name = "fundamental" - elif self.buffer.btype == 'dir': + elif b.btype == 'dir': mode_name = 'dir' - elif hasattr(self.buffer, 'path'): - path = self.buffer.path + elif hasattr(b, 'path'): + path = b.path basename = os.path.basename(path) - ext = self._get_path_ext(path) + ext = self._get_path_ext(path) if path in self.application.mode_paths: mode_name = self.application.mode_paths[path] @@ -50,9 +57,9 @@ class Window(object): mode_name = self.application.mode_basenames[basename] elif ext in self.application.mode_extensions: mode_name = self.application.mode_extensions[ext] - elif len(self.buffer.lines) > 0 and \ - self.buffer.lines[0].startswith('#!'): - line = self.buffer.lines[0] + elif len(b.lines) > 0 and \ + b.lines[0].startswith('#!'): + line = b.lines[0] for word in self.application.mode_detection: if word in line: mode_name = self.application.mode_detection[word] @@ -62,7 +69,7 @@ class Window(object): m = self.application.modes[mode_name](self) self.set_mode(m) - self.buffer.add_window(self) + b.add_window(self) # private method used in window constructor def _get_path_ext(self, path): @@ -95,7 +102,7 @@ class Window(object): return self.buffer.highlights[self.mode.name()] # 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 if not self.point_is_visible(p): self.application.set_error(msg % {'x': p.x, 'y': p.y}) @@ -111,7 +118,10 @@ class Window(object): # point right 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 elif p.x == len(self.buffer.lines[p.y]): return Point(0, p.y + 1) @@ -246,7 +256,8 @@ class Window(object): if cursor.x > 0: self.cursor = Point(cursor.x - 1, cursor.y) 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() def end_of_line(self): cursor = self.logical_cursor() @@ -471,7 +482,8 @@ class Window(object): if x > 0: self.buffer.delete_char(Point(x - 1, y)) 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): cursor = self.logical_cursor() if cursor < self.last: @@ -662,7 +674,7 @@ class Window(object): # application drawing # # 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): modename = self.mode.name() if modename in self.buffer.highlights: