improving token names

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-03-16 14:53:35 +00:00
parent a968dae8b0
commit d75b3bd6a1
7 changed files with 65 additions and 118 deletions

View File

@ -50,12 +50,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'),
'comment.start': ('red', 'default'), 'comment.start': ('red', 'default'),
'comment.null': ('red', 'default'), 'comment.null': ('red', 'default'),
'comment.end': ('red', 'default'), 'comment.end': ('red', 'default'),
'continuation': ('red', 'default'),
'string.start': ('green', 'default'),
'string.null': ('green', 'default'),
'string.octal': ('magenta', 'default'),
'string.escaped': ('magenta', 'default'),
'string.end': ('green', 'default'),
'char': ('green', 'default'),
'integer': ('green', 'default'),
'float': ('green', 'default'),
'label': ('magenta', 'default'),
'keyword': ('cyan', 'default'),
'function': ('blue', 'default'),
'builtin': ('magenta', 'default'),
'method': ('cyan', 'default'),
'bareword': ('default', 'default'),
'delimiter': ('default', 'default'),
} }
self.default_color = ('default', 'default',) self.default_color = ('default', 'default',)
# initialize our colors # initialize our colors
if curses.has_colors(): if curses.has_colors():

View File

@ -7,7 +7,7 @@ sub foo {
unless 9 && 3; unless 9 && 3;
} }
#@@:heredoc:mode.sql.Sql #@@:heredoc:sql
my $s = <<EOT; my $s = <<EOT;
drop table foog; drop table foog;
insert into mytable (col1, col2, "col3") values (99, 33, 1234); insert into mytable (col1, col2, "col3") values (99, 33, 1234);
@ -24,7 +24,7 @@ EOT
# wejgiwe jgiweg jweigewgj we gwee e e e ee e # wejgiwe jgiweg jweigewgj we gwee e e e ee e
my $foo = { my $foo = {
#@@:perl_string:mode.sql.Sql #@@:perl_string:sql
'drop table foogy;', 'drop table foogy;',
'bar', 'bar',
}; };

View File

@ -185,18 +185,13 @@ class C(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'macrocomment.start': ('red', 'default'), 'macrocomment.start': ('red', 'default'),
'macrocomment.null': ('red', 'default'), 'macrocomment.null': ('red', 'default'),
'macrocomment.end': ('red', 'default'), 'macrocomment.end': ('red', 'default'),
'include': ('blue', 'default'),
'header': ('green', 'default'),
'macro': ('blue', 'default'), 'macro': ('blue', 'default'),
'macro.start': ('blue', 'default'), 'macro.start': ('blue', 'default'),
'macro.name': ('yellow', 'default'), 'macro.name': ('yellow', 'default'),
'macro.null': ('magenta', 'default'), 'macro.null': ('magenta', 'default'),
#'macro.null': ('default', 'default'),
'macro.continued': ('red', 'default'), 'macro.continued': ('red', 'default'),
'macro.delimiter': ('default', 'default'), 'macro.delimiter': ('default', 'default'),
'macro.integer': ('green', 'default'), 'macro.integer': ('green', 'default'),
@ -205,28 +200,13 @@ class C(mode.Fundamental):
'macro.string.start': ('green', 'default'), 'macro.string.start': ('green', 'default'),
'macro.string.escaped': ('magenta', 'default'), 'macro.string.escaped': ('magenta', 'default'),
'macro.string.octal': ('magenta', 'default'), 'macro.string.octal': ('magenta', 'default'),
#'macro.string.escaped': ('default', 'default'),
#'macro.string.octal': ('default', 'default'),
'macro.string.null': ('green', 'default'), 'macro.string.null': ('green', 'default'),
'macro.string.end': ('green', 'default'), 'macro.string.end': ('green', 'default'),
'macro.end': ('magenta', 'default'), 'macro.end': ('magenta', 'default'),
#'macro.end': ('default', 'default'), 'include': ('blue', 'default'),
'header': ('green', 'default'),
'label': ('magenta', 'default'), 'structname': ('yellow', 'default'),
'keyword': ('cyan', 'default'), 'enumname': ('yellow', 'default'),
'function': ('blue', 'default'),
'builtin': ('magenta', 'default'),
'structname': ('yellow', 'default'),
'enumname': ('yellow', 'default'),
'char': ('green', 'default'),
'string.start': ('green', 'default'),
'string.octal': ('green', 'default'),
'string.escaped': ('green', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
'integer': ('green', 'default'),
'float': ('green', 'default'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -12,30 +12,30 @@ class KeywordGrammar(Grammar):
rules = [ rules = [
PatternRule(r'octal', r'\\[0-7]{3}'), PatternRule(r'octal', r'\\[0-7]{3}'),
PatternRule(r'escaped', r'\\.'), PatternRule(r'escaped', r'\\.'),
RegionRule('string', "'", StringGrammar, r"'"), RegionRule(r'string', "'", StringGrammar, r"'"),
RegionRule('string', '"', StringGrammar, r'"'), RegionRule(r'string', '"', StringGrammar, r'"'),
] ]
class CSSGrammar(Grammar): class CSSGrammar(Grammar):
rules = [ rules = [
RegionRule(r'comment', '/\*', Grammar, '\*/'), RegionRule(r'comment', '/\*', Grammar, '\*/'),
RegionRule(r'htmlcomment', '<!--', Grammar, '-->'), RegionRule(r'comment', '<!--', Grammar, '-->'),
NocasePatternRule(r'dimension', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)[-a-z_][-a-z0-9_]*'), NocasePatternRule(r'css_dimension', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)[-a-z_][-a-z0-9_]*'),
NocasePatternRule(r'percentage', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)%%'), NocasePatternRule(r'css_percentage', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)%%'),
NocasePatternRule(r'length', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)(?:em|ex|px|in|cm|mm|pt|pc)'), NocasePatternRule(r'css_length', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)(?:em|ex|px|in|cm|mm|pt|pc)'),
NocasePatternRule(r'hash', r'#[-a-z0-9_]+'), NocasePatternRule(r'css_hash', r'#[-a-z0-9_]+'),
NocasePatternRule(r'real', r'[+-]?[0-9]*\.[0-9]+'), NocasePatternRule(r'css_real', r'[+-]?[0-9]*\.[0-9]+'),
NocasePatternRule(r'int', r'[+-]?[0-9]+'), NocasePatternRule(r'css_int', r'[+-]?[0-9]+'),
NocasePatternRule(r'rule', r'@(?:page|media|import)'), NocasePatternRule(r'css_rule', r'@(?:page|media|import)'),
NocasePatternRule(r'color', r'(?:aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|#[0-9]{6}|#[0-9]{3})'), NocasePatternRule(r'css_color', r'(?:aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|#[0-9]{6}|#[0-9]{3})'),
NocasePatternRule(r'css_keyword', r'(?:url|rgb|counter)'), NocasePatternRule(r'css_keyword', r'(?:url|rgb|counter)'),
NocaseRegionRule(r'css_keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'), NocaseRegionRule(r'css_keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'),
NocasePatternRule(r'css_label', r"\.?[-a-zA-Z0-9_]+(?= *{)"), NocasePatternRule(r'css_label', r"\.?[-a-zA-Z0-9_]+(?= *{)"),
NocasePatternRule(r'ident', r"-?[a-z_][-a-z0-9_]*"), NocasePatternRule(r'css_ident', r"-?[a-z_][-a-z0-9_]*"),
NocasePatternRule(r'name', r"[-a-z0-9_]+"), NocasePatternRule(r'css_name', r"[-a-z0-9_]+"),
NocasePatternRule(r'delimiter', r'[:;,{}()\[\]]|~=|\|=|='), NocasePatternRule(r'delimiter', r'[:;,{}()\[\]]|~=|\|=|='),
RegionRule(r'string', "'", StringGrammar, r"'"), RegionRule(r'string', "'", StringGrammar, r"'"),
RegionRule(r'string', '"', StringGrammar, r'"'), RegionRule(r'string', '"', StringGrammar, r'"'),
@ -50,45 +50,25 @@ class CSS(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
#'comment': ('red', 'default'), 'css_dimension': ('magenta', 'default'),
#'comment.start': ('red', 'default'), 'css_percentage': ('magenta', 'default'),
#'comment.null': ('red', 'default'), 'css_length': ('magenta', 'default'),
#'comment.end': ('red', 'default'), 'css_real': ('magenta', 'default'),
'css_int': ('magenta', 'default'),
'htmlcomment': ('red', 'default'), 'css_color': ('magenta', 'default'),
'htmlcomment.start': ('red', 'default'),
'htmlcomment.null': ('red', 'default'),
'htmlcomment.end': ('red', 'default'),
'dimension': ('magenta', 'default'),
'percentage': ('magenta', 'default'),
'length': ('magenta', 'default'),
'real': ('magenta', 'default'),
'int': ('magenta', 'default'),
'color': ('magenta', 'default'),
'hash': ('cyan', 'default'),
'css_label': ('cyan', 'default'),
'rule': ('cyan', 'default'),
'css_keyword': ('cyan', 'default'),
'ident': ('default', 'default'),
'name': ('default', 'default'),
'delimiter': ('default', 'default'),
'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': ('cyan', 'default'),
'css_keyword.start': ('default', 'default'), 'css_keyword.start': ('default', 'default'),
'css_keyword.null': ('cyan', 'default'), 'css_keyword.null': ('cyan', 'default'),
'css_keyword.octal': ('magenta', 'default'), 'css_keyword.octal': ('magenta', 'default'),
'css_keyword.escaped': ('magenta', 'default'), 'css_keyword.escaped': ('magenta', 'default'),
'css_keyword.end': ('default', 'default'), 'css_keyword.end': ('default', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.end': ('green', 'default'),
} }
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -9,7 +9,7 @@ class JavascriptGrammar(Grammar):
RegionRule(r'comment', '/\*', Grammar, '\*/'), RegionRule(r'comment', '/\*', Grammar, '\*/'),
PatternRule(r'continuation', r'\\(?= *$)'), PatternRule(r'continuation', r'\\(?= *$)'),
PatternRule(r'js_function', r"(?<=function )[a-zA-Z_][a-zA-Z0-9_]*"), PatternRule(r'js_function', r"(?<=function )[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r'class', r"(?<=class )[a-zA-Z_][a-zA-Z0-9_]*"), PatternRule(r'js_class', r"(?<=class )[a-zA-Z_][a-zA-Z0-9_]*"),
PatternRule(r'js_reserved', r'(?:as|break|case|catch|class|const|continue|default|delete|do|else|export|extends|false|finally|for|function|if|import|in|instanceof|is|namespace|new|null|package|private|public|return|super|switch|this|throw|true|try|typeof|use|var|void|while|with)(?![a-zA-Z0-9_])'), PatternRule(r'js_reserved', r'(?:as|break|case|catch|class|const|continue|default|delete|do|else|export|extends|false|finally|for|function|if|import|in|instanceof|is|namespace|new|null|package|private|public|return|super|switch|this|throw|true|try|typeof|use|var|void|while|with)(?![a-zA-Z0-9_])'),
PatternRule(r'js_reserved', r'(?:abstract|debugger|enum|goto|implements|interface|native|protected|synchronized|throws|transient|volatile)(?![a-zA-Z0-9_])'), PatternRule(r'js_reserved', r'(?:abstract|debugger|enum|goto|implements|interface|native|protected|synchronized|throws|transient|volatile)(?![a-zA-Z0-9_])'),
@ -62,28 +62,10 @@ class Javascript(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
#'comment': ('red', 'default'),
#'comment.start': ('red', 'default'),
#'comment.null': ('red', 'default'),
#'comment.end': ('red', 'default'),
'continuation': ('red', 'default'),
'js_function': ('blue', 'default'), 'js_function': ('blue', 'default'),
'class': ('green', 'default'), 'js_class': ('green', 'default'),
'js_reserved': ('cyan', 'default'),
'js_reserved': ('cyan', 'default'), 'js_nonreserved': ('cyan', 'default'),
'js_nonreserved': ('cyan', 'default'),
#'delimiter': ('default', 'default'),
#'operator': ('default', 'default'),
#'integer': ('default', 'default'),
#'float': ('default', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.end': ('green', 'default'),
'js_regex.start': ('cyan', 'default'), 'js_regex.start': ('cyan', 'default'),
'js_regex.null': ('cyan', 'default'), 'js_regex.null': ('cyan', 'default'),
'js_regex.octal': ('magenta', 'default'), 'js_regex.octal': ('magenta', 'default'),

View File

@ -206,7 +206,6 @@ class Perl(mode.Fundamental):
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
# comments # comments
#'comment': ('red', 'default'),
'endblock.start': ('red', 'default'), 'endblock.start': ('red', 'default'),
'endblock.null': ('red', 'default'), 'endblock.null': ('red', 'default'),
'endblock.end': ('red', 'default'), 'endblock.end': ('red', 'default'),
@ -238,14 +237,14 @@ class Perl(mode.Fundamental):
'hash_key': ('green', 'default'), 'hash_key': ('green', 'default'),
'perl_function': ('cyan', 'default'), 'perl_function': ('cyan', 'default'),
'perl_builtin': ('magenta', 'default'), 'perl_builtin': ('magenta', 'default'),
'method': ('cyan', 'default'), #'method': ('cyan', 'default'),
'bareword': ('default', 'default'), #'bareword': ('default', 'default'),
'perl_label': ('cyan', 'default'), 'perl_label': ('cyan', 'default'),
'package': ('cyan', 'default'), 'package': ('cyan', 'default'),
'perl_class': ('cyan', 'default'), 'perl_class': ('cyan', 'default'),
'use': ('cyan', 'default'), 'use': ('cyan', 'default'),
'require': ('cyan', 'default'), 'require': ('cyan', 'default'),
'method': ('cyan', 'default'), #'method': ('cyan', 'default'),
# heredoc/evaldoc # heredoc/evaldoc
'heredoc.start': ('green', 'default'), 'heredoc.start': ('green', 'default'),

View File

@ -188,25 +188,15 @@ class Python(mode.Fundamental):
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'python_keyword': ('cyan', 'default'), 'python_keyword': ('cyan', 'default'),
'python_reserved': ('magenta', 'default'), 'python_reserved': ('magenta', 'default'),
'python_builtin': ('cyan', 'default'), 'python_builtin': ('cyan', 'default'),
'functionname': ('blue', 'default'), 'functionname': ('blue', 'default'),
'classname': ('green', 'default'), 'classname': ('green', 'default'),
#'string.start': ('green', 'default'),
#'string.null': ('green', 'default'),
#'string.octal': ('magenta', 'default'),
#'string.escaped': ('magenta', 'default'),
#'string.end': ('green', 'default'),
'rawstring.start': ('green', 'default'), 'rawstring.start': ('green', 'default'),
'rawstring.null': ('green', 'default'), 'rawstring.null': ('green', 'default'),
'rawstring.escaped': ('green', 'default'), 'rawstring.escaped': ('green', 'default'),
'rawstring.end': ('green', 'default'), 'rawstring.end': ('green', 'default'),
#'integer': ('default', 'default'),
#'float': ('default', 'default'),
#'imaginary': ('default', 'default'),
#'comment': ('red', 'default'),
#'continuation': ('red', 'default'),
'system_identifier': ('cyan', 'default'), 'system_identifier': ('cyan', 'default'),
} }
def __init__(self, w): def __init__(self, w):