more highlighting improvements

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-07-25 02:24:12 -04:00
parent a3ed5279be
commit 0ca66531c6
1 changed files with 98 additions and 95 deletions

View File

@ -139,7 +139,7 @@ class PerlGrammar(Grammar):
RegionRule('perl.string', "'", StrictStringGrammar, "'"),
RegionRule('perl.evalstring', "`", EvalGrammar, "`"),
PatternRule('perl.keyword', "(?<!->)(?:continue|do|else|elsif|eval|foreach|for|if|last|my|next|no|our|package|require|return|sub|undef|unless|until|use|while)(?![a-zA-Z0-9_])"),
PatternRule('perl.builtin', "(?<!->)(?:STDIN|STDERR|STDOUT)(?![a-zA-Z0-9_])"),
PatternRule('perl.reserved', "(?<!->)(?:STDIN|STDERR|STDOUT|__PACKAGE__)(?![a-zA-Z0-9_])"),
PatternRule('perl.hashkey', '(?<={)' + wchr2 + '+(?=})'),
PatternRule('perl.method', '(?<=->)' + word1),
PatternRule('perl.hashkey', wchr2 + '+(?= *=>)'),
@ -257,7 +257,7 @@ class PerlGrammar(Grammar):
PatternRule('perl.noperator', "-[rwxoRWXOezsfdlpSbctugkTBMAC](?!" +
wchr2 + ")"),
PatternRule('perl.operator', r"\+=|-=|\*=|/=|//=|%=|&=\|\^=|>>=|<<=|\*\*=|\\"),
PatternRule('perl.operator', r"\+\+|\+|<=>|<>|<<|<=|<|-|>>|>=|>|\*\*|\*|&&|&|\|\||\||/|\^|==|//|~|=~|!~|!=|%|!|\.|x(?![a-zA-Z_])"),
PatternRule('perl.operator', r"\+\+|\+|<=>|<>|<<|<=|<|-|>>|>=|>|\*\*|\*|&&|&|\|\||\||/|\^|==|//|~|=~|!~|!=|%|!|\.\.|\.|x(?![a-zA-Z_])"),
PatternRule('perl.noperator', "(?:xor|or|not|ne|lt|le|gt|ge|eq|cmp|and)(?![a-zA-Z_])"),
PatternRule('perl.bareword', word2),
@ -728,31 +728,33 @@ class PerlContext(context.Context):
if curr: self.namelines[i] = (curr, tuple(stack))
i += 1
# white is for delimiters, operators, numbers
default = ('default', 'default', 'bold')
# green is for strings and hash keys
low_green = ('green130', 'default', 'bold')
lit_green = ('green251', 'default', 'bold')
lo_green = ('green020', 'default', 'bold')
hi_green = ('green050', 'default', 'bold')
# cyan is for quotes, evals, regexes, subs
low_cyan = ('cyan022', 'default', 'bold')
med_cyan = ('cyan', 'default', 'bold')
lit_cyan = ('cyan255', 'default', 'bold')
lo_cyan = ('cyan022', 'default', 'bold')
hi_cyan = ('cyan255', 'default', 'bold')
# magenta is for keywords/builtins, translation, globs
low_magenta = ('magenta424', 'default', 'bold')
med_magenta = ('magenta', 'default', 'bold')
lit_magenta = ('magenta515', 'default', 'bold')
lo_magenta = ('magenta202', 'default', 'bold')
hi_magenta = ('magenta505', 'default', 'bold')
# yellow is for variables
med_yellow = ('yellow', 'default', 'bold')
lit_orange = ('yellow530', 'default', 'bold')
med_orange = ('yellow520', 'default', 'bold')
# yellow/orange are for scalars, arrays and hashes
hi_yellow = ('yellow', 'default', 'bold')
lo_yellow = ('yellow530', 'default', 'bold')
lo_orange = ('yellow520', 'default', 'bold')
# red is for comments, pods, endblocks
low_red = ('red300', 'default', 'bold')
med_red = ('red', 'default', 'bold')
lit_red = ('red500', 'default', 'bold')
lo_red = ('red300', 'default', 'bold')
hi_red = ('red500', 'default', 'bold')
# blue is unused
lo_blue = ('blue113', 'default', 'bold')
hi_blue = ('blue225', 'default', 'bold')
class Perl(Fundamental):
name = 'Perl'
@ -767,103 +769,104 @@ class Perl(Fundamental):
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
# comments
'endblock.start': low_red,
'endblock.end': lit_red,
'endblock.data': lit_red,
'endblock.null': lit_red,
'perl.comment': hi_red,
'endblock.start': lo_red,
'endblock.end': hi_red,
'endblock.data': hi_red,
'endblock.null': hi_red,
# pod
'pod.start': med_red,
'pod.end': med_red,
'pod.data': med_red,
'pod.null': med_red,
'pod.entry.start': med_magenta,
'pod.entry.end': med_magenta,
'pod.entry.data': med_magenta,
'pod.entry.null': med_magenta,
'pod.start': hi_red,
'pod.end': hi_red,
'pod.data': hi_red,
'pod.null': hi_red,
'pod.entry.start': hi_magenta,
'pod.entry.end': hi_magenta,
'pod.entry.data': hi_magenta,
'pod.entry.null': hi_magenta,
# basic stuff
'perl.sub': med_cyan,
'prototype': med_yellow,
'noperator': med_magenta,
'perl.keyword': low_magenta,
'perl.builtin': med_magenta,
#'perl.cast': med_yellow,
'perl.scalar': med_yellow,
'perl.length': med_yellow,
'perl.deref': med_yellow,
'perl.array': lit_orange,
'perl.hash': med_orange,
'perl.hashkey': lit_green,
'perl.method': med_cyan,
'perl.function': med_cyan,
'perl.builtin': med_magenta,
'perl.label': med_cyan,
'package': med_cyan,
'perl.class': med_cyan,
'perl.use': med_cyan,
'perl.require': med_cyan,
'perl.sub': hi_cyan,
'perl.prototype': hi_yellow,
'perl.noperator': hi_magenta,
'perl.keyword': hi_magenta,
'perl.builtin': hi_magenta,
'perl.reserved': hi_magenta,
'perl.scalar': hi_yellow,
'perl.length': hi_yellow,
'perl.deref': hi_yellow,
'perl.array': lo_yellow,
'perl.hash': lo_orange,
'perl.hashkey': hi_green,
'perl.method': hi_cyan,
'perl.function': hi_cyan,
'perl.label': hi_cyan,
'perl.package': hi_cyan,
'perl.class': hi_cyan,
'perl.use': hi_cyan,
'perl.require': hi_cyan,
'perl.glob': hi_magenta,
# heredoc/evaldoc
'heredoc.start': low_green,
'heredoc.end': low_green,
'heredoc.data': lit_green,
'heredoc.null': lit_green,
'heredoc.start': lo_green,
'heredoc.end': lo_green,
'heredoc.data': hi_green,
'heredoc.null': hi_green,
'evaldoc.start': low_cyan,
'evaldoc.end': low_cyan,
'evaldoc.data': lit_cyan,
'evaldoc.null': lit_cyan,
'evaldoc.start': lo_cyan,
'evaldoc.end': lo_cyan,
'evaldoc.data': hi_cyan,
'evaldoc.null': hi_cyan,
# numbers
'perl.number': default,
# strings
'perl.string.start': low_green,
'perl.string.end': low_green,
'perl.string.data': lit_green,
'perl.string.null': lit_green,
'perl.string.escaped': med_magenta,
'perl.string.deref': med_yellow,
'perl.string.start': lo_green,
'perl.string.end': lo_green,
'perl.string.data': hi_green,
'perl.string.null': hi_green,
'perl.string.escaped': hi_magenta,
'perl.string.deref': hi_yellow,
# `` strings
'evalstring.start': low_cyan,
'evalstring.end': low_cyan,
'evalstring.data': lit_cyan,
'evalstring.null': lit_cyan,
'evalstring.escaped': med_magenta,
'evalstring.deref': med_yellow,
'evalstring.start': lo_cyan,
'evalstring.end': lo_cyan,
'evalstring.data': hi_cyan,
'evalstring.null': hi_cyan,
'evalstring.escaped': hi_magenta,
'evalstring.deref': hi_yellow,
# quoted region
'perl.quoted.start': low_cyan,
'perl.quoted.end': low_cyan,
'perl.quoted.data': lit_cyan,
'perl.quoted.null': lit_cyan,
'perl.quoted.escaped': med_magenta,
'perl.quoted.deref': med_yellow,
'perl.quoted.start': lo_cyan,
'perl.quoted.end': lo_cyan,
'perl.quoted.data': hi_cyan,
'perl.quoted.null': hi_cyan,
'perl.quoted.escaped': hi_magenta,
'perl.quoted.deref': hi_yellow,
# match regex
'match.start': low_cyan,
'match.end': low_cyan,
'match.data': lit_cyan,
'match.null': lit_cyan,
'match.start': lo_cyan,
'match.end': lo_cyan,
'match.data': hi_cyan,
'match.null': hi_cyan,
# replace regex
'replace.start': low_cyan,
'replace.middle0': low_cyan,
'replace.middle1': low_cyan,
'replace.end': low_cyan,
'replace.data': lit_cyan,
'replace.null': lit_cyan,
'replace.escaped': med_magenta,
'replace.deref': med_yellow,
'replace.start': lo_cyan,
'replace.middle0': lo_cyan,
'replace.middle1': lo_cyan,
'replace.end': lo_cyan,
'replace.data': hi_cyan,
'replace.null': hi_cyan,
'replace.escaped': hi_magenta,
'replace.deref': hi_yellow,
# translate regex
'translate.start': low_magenta,
'translate.middle0': low_magenta,
'translate.end': low_magenta,
'translate.data': lit_magenta,
'translate.null': lit_magenta,
# xyz
'perl.glob': med_magenta,
'translate.start': lo_magenta,
'translate.middle0': lo_magenta,
'translate.end': lo_magenta,
'translate.data': hi_magenta,
'translate.null': hi_magenta,
}
config = {}
lconfig = {'perl.libs': []}