From d75b3bd6a16c297f93c94282a7cec1ce69e4a60f Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 16 Mar 2008 14:53:35 +0000 Subject: [PATCH] improving token names --HG-- branch : pmacs2 --- application.py | 26 +++++++++++--- code_examples/Reporting2.pm | 4 +-- mode/c.py | 34 ++++-------------- mode/css.py | 70 +++++++++++++------------------------ mode/javascript.py | 26 +++----------- mode/perl.py | 7 ++-- mode/python.py | 16 ++------- 7 files changed, 65 insertions(+), 118 deletions(-) diff --git a/application.py b/application.py index 3abcf21..aa5fa4b 100755 --- a/application.py +++ b/application.py @@ -50,12 +50,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'), + '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.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 if curses.has_colors(): diff --git a/code_examples/Reporting2.pm b/code_examples/Reporting2.pm index b44a66d..f36f048 100644 --- a/code_examples/Reporting2.pm +++ b/code_examples/Reporting2.pm @@ -7,7 +7,7 @@ sub foo { unless 9 && 3; } -#@@:heredoc:mode.sql.Sql +#@@:heredoc:sql my $s = <'), - NocasePatternRule(r'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'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'real', r'[+-]?[0-9]*\.[0-9]+'), - NocasePatternRule(r'int', r'[+-]?[0-9]+'), - NocasePatternRule(r'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})'), + RegionRule(r'comment', ''), + NocasePatternRule(r'css_dimension', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)[-a-z_][-a-z0-9_]*'), + NocasePatternRule(r'css_percentage', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)%%'), + NocasePatternRule(r'css_length', r'[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)(?:em|ex|px|in|cm|mm|pt|pc)'), + NocasePatternRule(r'css_hash', r'#[-a-z0-9_]+'), + NocasePatternRule(r'css_real', r'[+-]?[0-9]*\.[0-9]+'), + NocasePatternRule(r'css_int', r'[+-]?[0-9]+'), + NocasePatternRule(r'css_rule', r'@(?:page|media|import)'), + 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)'), NocaseRegionRule(r'css_keyword', '(?:(?<=url)|(?<=rgb)|(?<=counter))\(', KeywordGrammar, '\)'), NocasePatternRule(r'css_label', r"\.?[-a-zA-Z0-9_]+(?= *{)"), - NocasePatternRule(r'ident', r"-?[a-z_][-a-z0-9_]*"), - NocasePatternRule(r'name', r"[-a-z0-9_]+"), + NocasePatternRule(r'css_ident', r"-?[a-z_][-a-z0-9_]*"), + NocasePatternRule(r'css_name', r"[-a-z0-9_]+"), NocasePatternRule(r'delimiter', r'[:;,{}()\[\]]|~=|\|=|='), RegionRule(r'string', "'", StringGrammar, r"'"), RegionRule(r'string', '"', StringGrammar, r'"'), @@ -50,45 +50,25 @@ class CSS(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - #'comment': ('red', 'default'), - #'comment.start': ('red', 'default'), - #'comment.null': ('red', 'default'), - #'comment.end': ('red', 'default'), - - 'htmlcomment': ('red', '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_dimension': ('magenta', 'default'), + 'css_percentage': ('magenta', 'default'), + 'css_length': ('magenta', 'default'), + 'css_real': ('magenta', 'default'), + 'css_int': ('magenta', 'default'), + 'css_color': ('magenta', '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.start': ('default', 'default'), 'css_keyword.null': ('cyan', 'default'), 'css_keyword.octal': ('magenta', 'default'), 'css_keyword.escaped': ('magenta', '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): mode.Fundamental.__init__(self, w) diff --git a/mode/javascript.py b/mode/javascript.py index 3c857fe..e0be60f 100644 --- a/mode/javascript.py +++ b/mode/javascript.py @@ -9,7 +9,7 @@ class JavascriptGrammar(Grammar): RegionRule(r'comment', '/\*', Grammar, '\*/'), PatternRule(r'continuation', r'\\(?= *$)'), 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'(?: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',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - #'comment': ('red', 'default'), - #'comment.start': ('red', 'default'), - #'comment.null': ('red', 'default'), - #'comment.end': ('red', 'default'), - 'continuation': ('red', 'default'), 'js_function': ('blue', 'default'), - 'class': ('green', 'default'), - - 'js_reserved': ('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_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'), diff --git a/mode/perl.py b/mode/perl.py index c0e66aa..2ede335 100644 --- a/mode/perl.py +++ b/mode/perl.py @@ -206,7 +206,6 @@ class Perl(mode.Fundamental): closetags = {')': '(', ']': '[', '}': '{'} colors = { # comments - #'comment': ('red', 'default'), 'endblock.start': ('red', 'default'), 'endblock.null': ('red', 'default'), 'endblock.end': ('red', 'default'), @@ -238,14 +237,14 @@ class Perl(mode.Fundamental): 'hash_key': ('green', 'default'), 'perl_function': ('cyan', 'default'), 'perl_builtin': ('magenta', 'default'), - 'method': ('cyan', 'default'), - 'bareword': ('default', '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'), + #'method': ('cyan', 'default'), # heredoc/evaldoc 'heredoc.start': ('green', 'default'), diff --git a/mode/python.py b/mode/python.py index cecf3ee..56644b1 100644 --- a/mode/python.py +++ b/mode/python.py @@ -188,25 +188,15 @@ class Python(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - 'python_keyword': ('cyan', 'default'), - 'python_reserved': ('magenta', 'default'), - 'python_builtin': ('cyan', 'default'), + 'python_keyword': ('cyan', 'default'), + 'python_reserved': ('magenta', 'default'), + 'python_builtin': ('cyan', 'default'), 'functionname': ('blue', '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.null': ('green', 'default'), 'rawstring.escaped': ('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'), } def __init__(self, w):