refactor mode.name() to mode.name

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-03-17 19:24:10 +00:00
parent c95ae0fd2f
commit 5eff1a2875
69 changed files with 179 additions and 189 deletions

2
MODES
View File

@ -8,7 +8,7 @@ the buffer should be highlighted, how the buffer should be indented, and any
other per-buffer configuration. The default mode ("Fundamental") provides the other per-buffer configuration. The default mode ("Fundamental") provides the
base functionality which all other modes inherit. The idea of modes is taken base functionality which all other modes inherit. The idea of modes is taken
from Emacs (although the distinction between major and minor modes does not from Emacs (although the distinction between major and minor modes does not
exist in Pmacs). exist in Pmacs--there are no minor modes).
2. Where do they come from? 2. Where do they come from?

View File

@ -787,7 +787,6 @@ class Application(object):
if slot.window is None: if slot.window is None:
return return
w = slot.window w = slot.window
modename = w.mode.name()
# draw the header # draw the header
if w.mode.header: if w.mode.header:
@ -844,8 +843,7 @@ class Application(object):
lines = w.buffer.lines lines = w.buffer.lines
count = w.mode.header count = w.mode.header
swidth = slot.width - lm - rm swidth = slot.width - lm - rm
modename = w.mode.name() lit = w.mode.name in w.buffer.highlights
lit = w.mode.name() in w.buffer.highlights
ended = False ended = False
# figure out which "physical line" is the first to be shown. note that # figure out which "physical line" is the first to be shown. note that

View File

@ -160,7 +160,7 @@ class Buffer(object):
def add_window(self, w): def add_window(self, w):
if w not in self.windows: if w not in self.windows:
self.windows.append(w) self.windows.append(w)
modename = w.mode.name() modename = w.mode.name
if modename not in self.highlights and w.mode.lexer is not None: if modename not in self.highlights and w.mode.lexer is not None:
self.highlights[modename] = highlight.Highlighter(w.mode.lexer) self.highlights[modename] = highlight.Highlighter(w.mode.lexer)
self.highlights[modename].highlight(self.lines) self.highlights[modename].highlight(self.lines)
@ -170,12 +170,12 @@ class Buffer(object):
def remove_window(self, w): def remove_window(self, w):
if w in self.windows: if w in self.windows:
self.windows.remove(w) self.windows.remove(w)
modename = w.mode.name() modename = w.mode.name
if modename in self.highlights: if w.mode.name in self.highlights:
for w2 in self.windows: for w2 in self.windows:
if w2.mode.name() == modename: if w2.mode.name == w.mode.name:
return return
del self.highlights[modename] del self.highlights[w.mode.name]
def _region_add(self, p1, p2, lines, act): def _region_add(self, p1, p2, lines, act):
move = DelMove(self, p1, p2) move = DelMove(self, p1, p2)
self.add_to_stack(move, act) self.add_to_stack(move, act)

View File

@ -896,7 +896,7 @@ class CloseTag(Method):
w.insert_string_at_cursor(self.mytag) w.insert_string_at_cursor(self.mytag)
app = w.application app = w.application
buffer = w.buffer buffer = w.buffer
highlighter = buffer.highlights[w.mode.name()] highlighter = buffer.highlights[w.mode.name]
tokens = highlighter.tokens tokens = highlighter.tokens
# REFACTOR: we have methods in window to do this now # REFACTOR: we have methods in window to do this now

View File

@ -15,7 +15,7 @@ class ShowMode(Method):
m = w.mode m = w.mode
f = Fundamental(w) f = Fundamental(w)
lines = ['%s mode' % m.modename, ''] lines = ['%s mode' % m.name, '']
seen = set() seen = set()
triples = [] triples = []
@ -53,7 +53,7 @@ class ShowBindingsBuffer(Method):
'''Dump all keybindings for current mode into a new buffer''' '''Dump all keybindings for current mode into a new buffer'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
lines = [] lines = []
mode_name = w.mode.name() mode_name = w.mode.name
lines.append('Key bindings for mode %r:' % (mode_name)) lines.append('Key bindings for mode %r:' % (mode_name))
lines.append('') lines.append('')

View File

@ -49,10 +49,9 @@ class DumpMarkers(Method):
class DumpTokens(Method): class DumpTokens(Method):
'''Dump all lexical tokens (syntax highlighting debugging)''' '''Dump all lexical tokens (syntax highlighting debugging)'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
modename = w.mode.name()
lines = [] lines = []
if modename in w.buffer.highlights: if w.mode.name in w.buffer.highlights:
tokens = w.buffer.highlights[modename].tokens tokens = w.buffer.highlights[w.mode.name].tokens
for i in range(0, len(tokens)): for i in range(0, len(tokens)):
lines.append("LINE %d" % (i + 1)) lines.append("LINE %d" % (i + 1))
group = tokens[i] group = tokens[i]
@ -77,10 +76,9 @@ class DumpTokens(Method):
class DumpAggregateTokenData(Method): class DumpAggregateTokenData(Method):
'''Dump all lexical tokens into an aggregated format''' '''Dump all lexical tokens into an aggregated format'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
name = w.mode.name()
lines = [] lines = []
if name in w.buffer.highlights: if w.mode.name in w.buffer.highlights:
tokens = w.buffer.highlights[name].tokens tokens = w.buffer.highlights[w.mode.name].tokens
for group in tokens: for group in tokens:
for token in group: for token in group:
s1 = token.name s1 = token.name

View File

@ -119,18 +119,20 @@ class SvnStatus(Method):
c = data[0] c = data[0]
status = self.column.get(c, 'Error (%s)' % c) status = self.column.get(c, 'Error (%s)' % c)
fields = data[6:].split() fields = data[6:].split()
try: if len(fields) == 4:
(rrev, lrev, lauthor, filename) = fields rrev, lrev, lauthor, filename = fields
except: w.buffer.metadata['svn-filename'] = filename
raise Exception, '%r %r' % (fields, data[6:]) w.buffer.metadata['svn-status'] = status
w.buffer.metadata['svn-lrev'] = lrev
w.buffer.metadata['svn-filename'] = filename w.buffer.metadata['svn-rrev'] = rrev
w.buffer.metadata['svn-status'] = status w.buffer.metadata['svn-author'] = lauthor
w.buffer.metadata['svn-lrev'] = lrev w.buffer.metadata['vc-info'] = '[svn:%s/%s]' % (lrev, rrev)
w.buffer.metadata['svn-rrev'] = rrev w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor))
w.buffer.metadata['svn-author'] = lauthor else:
w.buffer.metadata['svn-filename'] = path
w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor)) w.buffer.metadata['svn-status'] = status
w.buffer.metadata['vc-info'] = '[svn:%s]' % status.lower()
w.set_error('%s %s' % (path, status))
class SvnLog(Method): class SvnLog(Method):
'''display the SVN log for the current file''' '''display the SVN log for the current file'''

View File

@ -77,7 +77,7 @@ class Handler(object):
class Fundamental(Handler): class Fundamental(Handler):
'''This is the default mode''' '''This is the default mode'''
modename = "Fundamental" name = "Fundamental"
paths = [] paths = []
basenames = [] basenames = []
extensions = [] extensions = []
@ -102,7 +102,6 @@ class Fundamental(Handler):
actions = [] actions = []
_bindings = {} _bindings = {}
completers = {} completers = {}
#format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s"
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s %(perc)s %(vc-info)s" format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s %(perc)s %(vc-info)s"
header_size = 3 header_size = 3
@ -124,12 +123,12 @@ class Fundamental(Handler):
rmargin = property(_get_rmargin, _set_rmargin) rmargin = property(_get_rmargin, _set_rmargin)
def install(cls, app): def install(cls, app):
app.setmode(cls.modename.lower(), cls, paths=cls.paths, app.setmode(cls.name.lower(), cls, paths=cls.paths,
bases=cls.basenames, exts=cls.extensions, bases=cls.basenames, exts=cls.extensions,
detection=cls.detection) detection=cls.detection)
for (key, val) in cls.colors.iteritems(): for (key, val) in cls.colors.iteritems():
if key in app.token_colors: if key in app.token_colors:
s = 'token_colors: name %r conflict in %r' % (key, cls.modename) s = 'token_colors: name %r conflict in %r' % (key, cls.name)
raise Exception, s raise Exception, s
else: else:
app.token_colors[key] = val app.token_colors[key] = val
@ -290,14 +289,14 @@ class Fundamental(Handler):
# buffer settings # buffer settings
def get_setting(self, name): def get_setting(self, name):
self.window.buffer.settings.setdefault(self.modename, {}) self.window.buffer.settings.setdefault(self.name, {})
return self.window.buffer.settings[self.modename].get(name) return self.window.buffer.settings[self.name].get(name)
def init_setting(self, name, value): def init_setting(self, name, value):
self.window.buffer.settings.setdefault(self.modename, {}) self.window.buffer.settings.setdefault(self.name, {})
self.window.buffer.settings[self.modename].setdefault(name, value) self.window.buffer.settings[self.name].setdefault(name, value)
def set_setting(self, name, value): def set_setting(self, name, value):
self.window.buffer.settings.setdefault(self.modename, {}) self.window.buffer.settings.setdefault(self.name, {})
self.window.buffer.settings[self.modename][name] = value self.window.buffer.settings[self.name][name] = value
# header # header
def showing_header(self): def showing_header(self):
@ -384,10 +383,6 @@ class Fundamental(Handler):
s = ' ' * lm s = ' ' * lm
return [RenderString(s=s, attrs=color.build('default', 'default', 'bold'))] return [RenderString(s=s, attrs=color.build('default', 'default', 'bold'))]
# get mode name
def name(self):
return self.modename
def _get_flag(self): def _get_flag(self):
b = self.window.buffer b = self.window.buffer
if b.readonly(): if b.readonly():
@ -427,7 +422,7 @@ class Fundamental(Handler):
d = defaultdict(str) d = defaultdict(str)
d2 = { d2 = {
'bname': w.buffer.name(), 'bname': w.buffer.name(),
'mname': self.name(), 'mname': self.name,
'flag': self._get_flag(), 'flag': self._get_flag(),
'perc': self._get_perc(), 'perc': self._get_perc(),
'indent': self._get_indent(), 'indent': self._get_indent(),
@ -465,11 +460,11 @@ class Fundamental(Handler):
if DEBUG: if DEBUG:
raise raise
else: else:
err = "%s in mode '%s'" % (e, self.name()) err = "%s in mode '%s'" % (e, self.name)
self.window.set_error(err) self.window.set_error(err)
def region_added(self, p, newlines): def region_added(self, p, newlines):
mname = self.name() mname = self.name
if self.lexer is not None: if self.lexer is not None:
ydelta = len(newlines) - 1 ydelta = len(newlines) - 1
xdelta = len(newlines[-1]) xdelta = len(newlines[-1])

View File

@ -131,8 +131,8 @@ class AwkFilterInput(Method):
w.set_error("awk exited with status %d" % status) w.set_error("awk exited with status %d" % status)
class Awk(mode.Fundamental): class Awk(mode.Fundamental):
name = 'awk'
tabbercls = AwkTabber tabbercls = AwkTabber
modename = 'awk'
extensions = ['.awk'] extensions = ['.awk']
grammar = AwkGrammar grammar = AwkGrammar
opentokens = ('delimiter',) opentokens = ('delimiter',)

View File

@ -23,7 +23,7 @@ class BDSGrammar(Grammar):
] ]
class BDS(mode.Fundamental): class BDS(mode.Fundamental):
modename = 'bds' name = 'bds'
extensions = ['.bds'] extensions = ['.bds']
grammar = BDSGrammar grammar = BDSGrammar
colors = { colors = {

View File

@ -15,9 +15,9 @@ class BlameGrammar(Grammar):
] ]
class Blame(mode.Fundamental): class Blame(mode.Fundamental):
modename = 'Blame' name = 'Blame'
grammar = BlameGrammar grammar = BlameGrammar
colors = { colors = {
'metadata.start': ('blue', 'default', 'bold'), 'metadata.start': ('blue', 'default', 'bold'),
'metadata.username': ('cyan', 'default', 'bold'), 'metadata.username': ('cyan', 'default', 'bold'),
'metadata.end': ('green', 'default', 'bold'), 'metadata.end': ('green', 'default', 'bold'),

View File

@ -133,7 +133,7 @@ def _end(w):
assert not w.application.mini_active assert not w.application.mini_active
class Brm(mode.Fundamental): class Brm(mode.Fundamental):
modename = 'Bicycle-Repairman' name = 'Bicycle-Repairman'
actions = [ReplaceAll, ReplaceDone, ReplaceOne, SkipReplace, BrmCancel] actions = [ReplaceAll, ReplaceDone, ReplaceOne, SkipReplace, BrmCancel]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -156,7 +156,7 @@ class CMake(method.shell.Exec):
cmdname='c-make') cmdname='c-make')
class C(mode.Fundamental): class C(mode.Fundamental):
modename = 'C' name = 'C'
extensions = ['.c', '.h', '.cpp'] extensions = ['.c', '.h', '.cpp']
tabbercls = CTabber2 tabbercls = CTabber2
grammar = CGrammar grammar = CGrammar

View File

@ -33,7 +33,7 @@ class TemplateGrammar(Grammar):
] ]
class Template(mode.Fundamental): class Template(mode.Fundamental):
modename = 'Cheetah' name = 'Cheetah'
extensions = ['.tmpl'] extensions = ['.tmpl']
grammar = TemplateGrammar grammar = TemplateGrammar
commentc = '##' commentc = '##'

View File

@ -1,6 +1,6 @@
import mode import mode
class Colortext(mode.Fundamental): class Colortext(mode.Fundamental):
modename = 'Colortext' name = 'Colortext'
install = Colortext.install install = Colortext.install

View File

@ -11,7 +11,7 @@ class ConfGrammar(Grammar):
] ]
class Conf(mode.Fundamental): class Conf(mode.Fundamental):
modename = 'conf' name = 'conf'
extensions = ['.conf', '.cfg', '.cnf', '.config'] extensions = ['.conf', '.cfg', '.cnf', '.config']
grammar = ConfGrammar grammar = ConfGrammar
colors = {} colors = {}

View File

@ -3,6 +3,6 @@ from lex import Grammar, PatternRule, RegionRule
from mode.python import StringGrammar1, StringGrammar2, PythonGrammar from mode.python import StringGrammar1, StringGrammar2, PythonGrammar
class Console(mode.Fundamental): class Console(mode.Fundamental):
modename = 'Console' name = 'Console'
install = Console.install install = Console.install

View File

@ -214,9 +214,9 @@ class ConsoleGotoEnd(ConsoleBaseMethod):
subcls = method.move.GotoEnd subcls = method.move.GotoEnd
class ConsoleMini(mode.Fundamental): class ConsoleMini(mode.Fundamental):
modename = 'ConsoleMini' name = 'ConsoleMini'
grammar = PythonGrammar grammar = PythonGrammar
actions = [ConsoleExec, ConsoleClear, ConsoleCancel, ConsoleHistoryPrev, actions = [ConsoleExec, ConsoleClear, ConsoleCancel, ConsoleHistoryPrev,
ConsoleHistoryNext, ConsoleTab, ConsoleHistoryNext, ConsoleTab,
ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd] ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd]
_bindings = { _bindings = {

View File

@ -53,14 +53,14 @@ class CSSGrammar(Grammar):
] ]
class CSS(mode.Fundamental): class CSS(mode.Fundamental):
modename = 'CSS' name = 'CSS'
extensions = ['.css'] extensions = ['.css']
grammar = CSSGrammar grammar = CSSGrammar
opentokens = ('delimiter',) opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'} opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = { colors = {
'css_dimension': ('magenta', 'default', 'bold'), 'css_dimension': ('magenta', 'default', 'bold'),
'css_percentage': ('magenta', 'default', 'bold'), 'css_percentage': ('magenta', 'default', 'bold'),
'css_length': ('magenta', 'default', 'bold'), 'css_length': ('magenta', 'default', 'bold'),

View File

@ -12,10 +12,10 @@ class DiffGrammar(Grammar):
] ]
class Diff(mode.Fundamental): class Diff(mode.Fundamental):
modename = 'diff' name = 'diff'
extensions = ['.patch', '.diff'] extensions = ['.patch', '.diff']
grammar = DiffGrammar() grammar = DiffGrammar()
colors = { colors = {
'left': ('red', 'default', 'bold'), 'left': ('red', 'default', 'bold'),
'right': ('blue', 'default', 'bold'), 'right': ('blue', 'default', 'bold'),
'seperator': ('magenta', 'default', 'bold'), 'seperator': ('magenta', 'default', 'bold'),

View File

@ -163,9 +163,9 @@ class RemovePath(Method):
w.set_error("failed to delete %r" % path) w.set_error("failed to delete %r" % path)
class Dir(mode.Fundamental): class Dir(mode.Fundamental):
modename = 'Dir' name = 'Dir'
grammar = DirGrammar() grammar = DirGrammar()
colors = { colors = {
'dir_blk.start': ('cyan', 'default', 'bold'), 'dir_blk.start': ('cyan', 'default', 'bold'),
'dir_blk.dir_name': ('cyan', 'default', 'bold'), 'dir_blk.dir_name': ('cyan', 'default', 'bold'),
'dir_chr.start': ('yellow', 'default', 'bold'), 'dir_chr.start': ('yellow', 'default', 'bold'),

View File

@ -29,7 +29,7 @@ class ELispGrammar(Grammar):
] ]
class ELisp(mode.Fundamental): class ELisp(mode.Fundamental):
modename = 'ELisp' name = 'ELisp'
tabwidth = 2 tabwidth = 2
basenames = ['.emacs'] basenames = ['.emacs']
extensions = ['.el'] extensions = ['.el']

View File

@ -84,7 +84,7 @@ class ErlangTabber(tab.StackTabber):
# Interact._execute(self, w, bname='*Erl*', cmd='erl') # Interact._execute(self, w, bname='*Erl*', cmd='erl')
class Erlang(mode.Fundamental): class Erlang(mode.Fundamental):
modename = 'Erlang' name = 'Erlang'
extensions = ['.erl'] extensions = ['.erl']
tabwidth = 4 tabwidth = 4
tabbercls = ErlangTabber tabbercls = ErlangTabber

View File

@ -40,7 +40,7 @@ class ErrorGotoLine(Method):
w.set_error(errline) w.set_error(errline)
class Error(mode.Fundamental): class Error(mode.Fundamental):
modename = 'Error' name = 'Error'
actions = [ErrorGotoLine] actions = [ErrorGotoLine]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -119,7 +119,7 @@ class ForthTabber(tab.StackTabber2):
self.curr_level = 0 self.curr_level = 0
class Forth(Fundamental): class Forth(Fundamental):
modename = 'FORTH' name = 'FORTH'
extensions = ['.fs', '.fi', '.fb'] extensions = ['.fs', '.fi', '.fb']
grammar = ForthGrammar grammar = ForthGrammar
commentc = '\\ ' commentc = '\\ '

View File

@ -15,7 +15,7 @@ class FstabGrammar(Grammar):
] ]
class Fstab(mode.Fundamental): class Fstab(mode.Fundamental):
modename = 'fstab' name = 'fstab'
basenames = ['fstab'] basenames = ['fstab']
grammar = FstabGrammar grammar = FstabGrammar
colors = { colors = {

View File

@ -57,17 +57,17 @@ class HaskellTabber(tab.Tabber):
pass pass
class Haskell(mode.Fundamental): class Haskell(mode.Fundamental):
modename = 'Haskell' name = 'Haskell'
extensions = ['.hs'] extensions = ['.hs']
tabwidth = 4 tabwidth = 4
commentc = '--' commentc = '--'
#tabbercls = mode.lisp.LispTabber #tabbercls = mode.lisp.LispTabber
grammar = HaskellGrammar grammar = HaskellGrammar
opentokens = ('delimiter',) opentokens = ('delimiter',)
opentags = {'(': ')', '{': '}', '[': ']'} opentags = {'(': ')', '{': '}', '[': ']'}
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '(', '}': '{', ']': '['} closetags = {')': '(', '}': '{', ']': '['}
colors = { colors = {
'hs_constructor': ('magenta', 'default', 'bold'), 'hs_constructor': ('magenta', 'default', 'bold'),
'hs_declaration': ('blue', 'default', 'bold'), 'hs_declaration': ('blue', 'default', 'bold'),
'hs_variable': ('yellow', 'default', 'bold'), 'hs_variable': ('yellow', 'default', 'bold'),

View File

@ -215,14 +215,14 @@ class ShowAddress(Method):
w.set_error("Cursor's address is 0x%08x" % addr) w.set_error("Cursor's address is 0x%08x" % addr)
class Hex(mode.Fundamental): class Hex(mode.Fundamental):
modename = 'Hex' name = 'Hex'
config = { config = {
'hex.disinst': 'disinst', 'hex.disinst': 'disinst',
} }
lmargin = 12 lmargin = 12
rmargin = 18 rmargin = 18
_ctrans = ['.'] * 256 _ctrans = ['.'] * 256
byteorder = 'native' byteorder = 'native'
byteorders = { byteorders = {
'native': '=', 'native': '=',
'little': '<', 'little': '<',

View File

@ -73,7 +73,7 @@ class HtmlCheckSpelling(method.Method):
w.buffer.reload() w.buffer.reload()
class HTML(mode.Fundamental): class HTML(mode.Fundamental):
modename = 'HTML' name = 'HTML'
extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml'] extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml']
grammar = HTMLGrammar grammar = HTMLGrammar
colors = { colors = {

View File

@ -25,7 +25,7 @@ class MiniInsertCancel(method.Method):
w.application.close_mini_buffer() w.application.close_mini_buffer()
class InsertMini(mode.Fundamental): class InsertMini(mode.Fundamental):
modename = 'InsertMini' name = 'InsertMini'
actions = [MiniInsertLine, MiniInsertComplete, MiniInsertCancel, actions = [MiniInsertLine, MiniInsertComplete, MiniInsertCancel,
MiniInsertTab] MiniInsertTab]
def __init__(self, w): def __init__(self, w):

View File

@ -10,9 +10,9 @@ class IperlGrammar(Grammar):
PatternRule(r'iperl_reserved', r'undef'), PatternRule(r'iperl_reserved', r'undef'),
] ]
class Iperl(mode.Fundamental): class Iperl(mode.Fundamental):
modename = 'IPerl' name = 'IPerl'
grammar = IperlGrammar() grammar = IperlGrammar()
colors = { colors = {
'iperl_input.start': ('red', 'default', 'bold'), 'iperl_input.start': ('red', 'default', 'bold'),
'iperl_reserved': ('magenta', 'default', 'bold'), 'iperl_reserved': ('magenta', 'default', 'bold'),
} }

View File

@ -91,9 +91,9 @@ class IperlGotoEnd(mode.consolemini.ConsoleGotoEnd):
subbuf = '*IPerl*' subbuf = '*IPerl*'
class IperlMini(mode.Fundamental): class IperlMini(mode.Fundamental):
modename = 'IperlMini' name = 'IperlMini'
actions = [IperlExec, IperlTab, IperlStart, IperlPathStart, actions = [IperlExec, IperlTab, IperlStart, IperlPathStart,
IperlPageUp, IperlPageDown, IperlGotoBeginning, IperlGotoEnd] IperlPageUp, IperlPageDown, IperlGotoBeginning, IperlGotoEnd]
readre = re.compile('^([A-Z]+):(.*)\n$') readre = re.compile('^([A-Z]+):(.*)\n$')
def _readline(self): def _readline(self):
b = self.get_iperl() b = self.get_iperl()

View File

@ -11,9 +11,9 @@ class IpythonGrammar(Grammar):
PatternRule(r'ipython_reserved', r'undef'), PatternRule(r'ipython_reserved', r'undef'),
] ]
class Ipython(mode.Fundamental): class Ipython(mode.Fundamental):
modename = 'IPython' name = 'IPython'
grammar = IpythonGrammar() grammar = IpythonGrammar()
colors = { colors = {
'ipython_input.start': ('red', 'default', 'bold'), 'ipython_input.start': ('red', 'default', 'bold'),
'ipython_reserved': ('magenta', 'default', 'bold'), 'ipython_reserved': ('magenta', 'default', 'bold'),
} }

View File

@ -88,9 +88,9 @@ class IpythonGotoEnd(mode.consolemini.ConsoleGotoEnd):
subbuf = '*IPython*' subbuf = '*IPython*'
class IpythonMini(mode.Fundamental): class IpythonMini(mode.Fundamental):
modename = 'IpythonMini' name = 'IpythonMini'
actions = [IpythonExec, IpythonTab, IpythonStart, IpythonPathStart, actions = [IpythonExec, IpythonTab, IpythonStart, IpythonPathStart,
IpythonPageUp, IpythonPageDown, IpythonGotoBeginning, IpythonGotoEnd] IpythonPageUp, IpythonPageDown, IpythonGotoBeginning, IpythonGotoEnd]
def get_ipython(self): def get_ipython(self):
return self.window.buffer.method.main_buffer return self.window.buffer.method.main_buffer
def read_sync(self): def read_sync(self):

View File

@ -117,7 +117,7 @@ class JavaContext(context.Context):
i += 1 i += 1
class Java(mode.Fundamental): class Java(mode.Fundamental):
modename = 'Java' name = 'Java'
extensions = ['.java'] extensions = ['.java']
tabbercls = JavaTabber2 tabbercls = JavaTabber2
grammar = JavaGrammar grammar = JavaGrammar

View File

@ -75,7 +75,7 @@ class JavascriptTabber2(tab.StackTabber2):
def is_base(self, y): def is_base(self, y):
if y == 0: if y == 0:
return True return True
highlighter = self.mode.window.buffer.highlights[self.mode.name()] highlighter = self.mode.window.buffer.highlights[self.mode.name]
if not highlighter.tokens[y]: if not highlighter.tokens[y]:
return False return False
t = highlighter.tokens[y][0] t = highlighter.tokens[y][0]
@ -87,7 +87,7 @@ class JavascriptTabber2(tab.StackTabber2):
'comment.data', 'comment.null', 'comment.end') 'comment.data', 'comment.null', 'comment.end')
class Javascript(mode.Fundamental): class Javascript(mode.Fundamental):
modename = 'Javascript' name = 'Javascript'
extensions = ['.js'] extensions = ['.js']
grammar = JavascriptGrammar grammar = JavascriptGrammar
tabbercls = JavascriptTabber2 tabbercls = JavascriptTabber2

View File

@ -114,7 +114,7 @@ class LatexCheckSpelling(method.Method):
w.buffer.reload() w.buffer.reload()
class Latex(mode.Fundamental): class Latex(mode.Fundamental):
modename = 'Latex' name = 'Latex'
extensions = ['.latex', '.tex'] extensions = ['.latex', '.tex']
commentc = '%' commentc = '%'
grammar = LatexGrammar grammar = LatexGrammar

View File

@ -52,10 +52,10 @@ class LilyTabber(tab.StackTabber):
st = ('spaces', 'null',) st = ('spaces', 'null',)
class Lily(mode.Fundamental): class Lily(mode.Fundamental):
modename = 'lily' name = 'lily'
extensions = ['.ly'] extensions = ['.ly']
tabwidth = 2 tabwidth = 2
tabbercls = LilyTabber tabbercls = LilyTabber
grammar = LilyGrammar grammar = LilyGrammar
commentc = '%' commentc = '%'
colors = { colors = {

View File

@ -36,7 +36,7 @@ class LispTabber(tab.StackTabber):
return currlvl return currlvl
class Lisp(mode.Fundamental): class Lisp(mode.Fundamental):
modename = 'Lisp' name = 'Lisp'
tabwidth = 2 tabwidth = 2
tabbercls = LispTabber tabbercls = LispTabber
grammar = LispGrammar grammar = LispGrammar

View File

@ -38,7 +38,7 @@ class LuaCheckSyntax(method.Method):
app.data_buffer("*Lua-Check-Syntax*", output) app.data_buffer("*Lua-Check-Syntax*", output)
class Lua(mode.Fundamental): class Lua(mode.Fundamental):
modename = 'Lua' name = 'Lua'
extensions = ['.lua'] extensions = ['.lua']
#tabbercls = mode.lisp.LispTabber #tabbercls = mode.lisp.LispTabber
grammar = LuaGrammar grammar = LuaGrammar
@ -49,7 +49,7 @@ class Lua(mode.Fundamental):
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
colors = {} colors = {}
actions = [LuaCheckSyntax] actions = [LuaCheckSyntax]
_bindings = { _bindings = {
'close-paren': (')',), 'close-paren': (')',),
'close-brace': ('}',), 'close-brace': ('}',),
'close-bracket': (']',), 'close-bracket': (']',),

View File

@ -33,7 +33,7 @@ class MakeGrammar(Grammar):
] ]
class Make(mode.Fundamental): class Make(mode.Fundamental):
modename = 'Make' name = 'Make'
basenames = ['Makefile'] basenames = ['Makefile']
grammar = MakeGrammar grammar = MakeGrammar
commentc = '#' commentc = '#'

View File

@ -210,8 +210,8 @@ class MailListGrammar(Grammar):
] ]
class MboxMsg(mode.Fundamental): class MboxMsg(mode.Fundamental):
modename = 'MboxMsg' name = 'MboxMsg'
colors = { colors = {
'mail_pgp': ('red', 'default', 'bold'), 'mail_pgp': ('red', 'default', 'bold'),
'mail_signature.start': ('red', 'default', 'bold'), 'mail_signature.start': ('red', 'default', 'bold'),
'mail_signature.data': ('red', 'default', 'bold'), 'mail_signature.data': ('red', 'default', 'bold'),
@ -230,10 +230,10 @@ class MboxMsg(mode.Fundamental):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
class Mbox(mode.Fundamental): class Mbox(mode.Fundamental):
modename = 'Mbox' name = 'Mbox'
grammar = MailListGrammar grammar = MailListGrammar
actions = [MboxRefresh, MboxOpenPath, MboxReadMsg] actions = [MboxRefresh, MboxOpenPath, MboxReadMsg]
colors = { colors = {
'index': ('default', 'default', 'bold'), 'index': ('default', 'default', 'bold'),
'flag': ('yellow', 'default', 'bold'), 'flag': ('yellow', 'default', 'bold'),
'month': ('green', 'default', 'bold'), 'month': ('green', 'default', 'bold'),

View File

@ -38,8 +38,8 @@ class MiniTabComplete(method.Method):
use_completion_window(app, s2, candidates) use_completion_window(app, s2, candidates)
class Mini(mode.Fundamental): class Mini(mode.Fundamental):
modename = 'Mini' name = 'Mini'
actions = [MiniCallback, MiniTabComplete] actions = [MiniCallback, MiniTabComplete]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
self.add_bindings('mini-callback', ('RETURN',)) self.add_bindings('mini-callback', ('RETURN',))

View File

@ -122,10 +122,10 @@ class Mp3OpenPath(Method):
w.application.switch_buffer(b) w.application.switch_buffer(b)
class Mp3(mode.Fundamental): class Mp3(mode.Fundamental):
modename = 'Mp3' name = 'Mp3'
grammar = Mp3Grammar grammar = Mp3Grammar
actions = [Mp3Refresh, Mp3OpenPath] actions = [Mp3Refresh, Mp3OpenPath]
colors = { colors = {
'mp3_label': ('blue', 'default', 'bold'), 'mp3_label': ('blue', 'default', 'bold'),
'mp3_tag.start': ('default', 'default', 'bold'), 'mp3_tag.start': ('default', 'default', 'bold'),
'mp3_tag.data': ('green', 'default', 'bold'), 'mp3_tag.data': ('green', 'default', 'bold'),

View File

@ -24,9 +24,9 @@ class MuttInsertSpace(mode.text.TextInsertSpace):
wrapper = MuttWrapParagraph wrapper = MuttWrapParagraph
class Mutt(mode.Fundamental): class Mutt(mode.Fundamental):
modename = 'Mutt' name = 'Mutt'
grammar = MuttGrammar() grammar = MuttGrammar()
colors = { colors = {
'mutt_header': ('green', 'default', 'bold'), 'mutt_header': ('green', 'default', 'bold'),
'email': ('cyan', 'default', 'bold'), 'email': ('cyan', 'default', 'bold'),
'url': ('cyan', 'default', 'bold'), 'url': ('cyan', 'default', 'bold'),

View File

@ -26,7 +26,7 @@ class NasmGrammar(Grammar):
] ]
class Nasm(mode.Fundamental): class Nasm(mode.Fundamental):
modename = 'nasm' name = 'nasm'
extensions = ['.s'] extensions = ['.s']
grammar = NasmGrammar grammar = NasmGrammar
commentc = ';' commentc = ';'

View File

@ -48,7 +48,7 @@ class OcamlGrammar(Grammar):
] ]
class Ocaml(mode.Fundamental): class Ocaml(mode.Fundamental):
modename = 'ocaml' name = 'ocaml'
extensions = ['.mli', '.ml'] extensions = ['.mli', '.ml']
grammar = OcamlGrammar grammar = OcamlGrammar
opentokens = ('delimiter',) opentokens = ('delimiter',)

View File

@ -420,7 +420,7 @@ class PerlWrapParagraph(method.WrapParagraph):
return t.name == 'spaces' return t.name == 'spaces'
def _detect_line_type(self, w, y): def _detect_line_type(self, w, y):
h = w.buffer.highlights[w.mode.name()] h = w.buffer.highlights[w.mode.name]
ltype = None ltype = None
for t in h.tokens[y]: for t in h.tokens[y]:
fqname = t.fqname() fqname = t.fqname()
@ -442,7 +442,7 @@ class PerlWrapParagraph(method.WrapParagraph):
return ltype return ltype
def _fix_comments(self, c, w): def _fix_comments(self, c, w):
h = w.buffer.highlights[w.mode.name()] h = w.buffer.highlights[w.mode.name]
y1 = c.y y1 = c.y
y2 = c.y y2 = c.y
while y2 < len(w.buffer.lines) - 1: while y2 < len(w.buffer.lines) - 1:
@ -621,7 +621,7 @@ class PerlContext(context.Context):
i += 1 i += 1
class Perl(mode.Fundamental): class Perl(mode.Fundamental):
modename = 'Perl' name = 'Perl'
extensions = ['.pl', '.pm', '.pod'] extensions = ['.pl', '.pm', '.pod']
detection = ['perl'] detection = ['perl']
tabbercls = PerlTabber2 tabbercls = PerlTabber2

View File

@ -40,7 +40,7 @@ class PHPGrammar(Grammar):
# if y == 0: # if y == 0:
# return True # return True
# #
# highlighter = self.mode.window.buffer.highlights[self.mode.name()] # highlighter = self.mode.window.buffer.highlights[self.mode.name]
# if not highlighter.tokens[y]: # if not highlighter.tokens[y]:
# return False # return False
# #
@ -161,7 +161,7 @@ class PHPGrammar(Grammar):
# return currlvl # return currlvl
class PHP(mode.Fundamental): class PHP(mode.Fundamental):
modename = 'PHP' name = 'PHP'
extensions = ['.php'] extensions = ['.php']
#tabbercls = JavaTabber #tabbercls = JavaTabber
grammar = PHPGrammar grammar = PHPGrammar

View File

@ -19,7 +19,7 @@ class PipeInsertEsc(PipeInsertChr):
self.string = chr(27) + chr(i) self.string = chr(27) + chr(i)
class Pipe(Fundamental): class Pipe(Fundamental):
modename = 'pipe' name = 'pipe'
def __init__(self, w): def __init__(self, w):
Fundamental.__init__(self, w) Fundamental.__init__(self, w)

View File

@ -541,7 +541,7 @@ class PythonContext(context.Context):
self.namelines[k] = (curr, None) self.namelines[k] = (curr, None)
class Python(mode.Fundamental): class Python(mode.Fundamental):
modename = 'Python' name = 'Python'
extensions = ['.py'] extensions = ['.py']
detection = ['python'] detection = ['python']
tabbercls = PythonTabber tabbercls = PythonTabber
@ -580,7 +580,7 @@ class Python(mode.Fundamental):
"pythonclass": PythonClassCompleter(None), "pythonclass": PythonClassCompleter(None),
} }
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s]" format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s] %(vc-info)s"
header_size = 3 header_size = 3
def get_status_names(self): def get_status_names(self):
@ -592,7 +592,7 @@ class Python(mode.Fundamental):
# xyz # xyz
def get_header(self): def get_header(self):
fg, bg = "default", "red" fg, bg = "default", "blue"
if self.tabber is None: if self.tabber is None:
s = "Header support is not available for this mode" s = "Header support is not available for this mode"

View File

@ -133,7 +133,7 @@ def _end(w):
assert not w.application.mini_active assert not w.application.mini_active
class Replace(mode.Fundamental): class Replace(mode.Fundamental):
modename = 'Replace' name = 'Replace'
actions = [ReplaceAll, ReplaceDone, ReplaceOne, SkipReplace, CancelReplace] actions = [ReplaceAll, ReplaceDone, ReplaceOne, SkipReplace, CancelReplace]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)

View File

@ -54,7 +54,7 @@ class RstBuild(Method):
pass pass
class RST(mode.Fundamental): class RST(mode.Fundamental):
modename = 'RST' name = 'RST'
extensions = ['.rst'] extensions = ['.rst']
grammar = RSTGrammar grammar = RSTGrammar
colors = { colors = {

View File

@ -51,7 +51,7 @@ class GuileLoadFile(method.shell.Interact):
b.pipe_write('(load "%s")\n' % path) b.pipe_write('(load "%s")\n' % path)
class Scheme(mode.Fundamental): class Scheme(mode.Fundamental):
modename = 'Scheme' name = 'Scheme'
extensions = ['.scm'] extensions = ['.scm']
tabwidth = 2 tabwidth = 2
tabbercls = mode.lisp.LispTabber tabbercls = mode.lisp.LispTabber

View File

@ -116,7 +116,7 @@ def _end(w):
w.application.last_search = w.buffer.make_string() w.application.last_search = w.buffer.make_string()
class Search(mode.Fundamental): class Search(mode.Fundamental):
modename = 'Search' name = 'Search'
actions = [SearchNext, SearchPrevious, EndSearch, CancelSearch, actions = [SearchNext, SearchPrevious, EndSearch, CancelSearch,
SearchDeleteLeft, SearchDeleteLeftWord] SearchDeleteLeft, SearchDeleteLeftWord]
def __init__(self, w): def __init__(self, w):

View File

@ -129,7 +129,7 @@ class ShTabber(tab.StackTabber):
def is_base(self, y): def is_base(self, y):
if y == 0: if y == 0:
return True return True
highlighter = self.mode.window.buffer.highlights[self.mode.name()] highlighter = self.mode.window.buffer.highlights[self.mode.name]
if not highlighter.tokens[y]: if not highlighter.tokens[y]:
return False return False
t = highlighter.tokens[y][0] t = highlighter.tokens[y][0]
@ -166,15 +166,15 @@ class ShCheckSyntax(Method):
app.data_buffer("*Sh-Check-Syntax*", output) app.data_buffer("*Sh-Check-Syntax*", output)
class Sh(mode.Fundamental): class Sh(mode.Fundamental):
modename = 'sh' name = 'sh'
paths = ['/etc/profile'] paths = ['/etc/profile']
basenames = ['.bashrc', '.bash_profile', '.profile'] basenames = ['.bashrc', '.bash_profile', '.profile']
extensions = ['.bash', '.sh'] extensions = ['.bash', '.sh']
detection = ['sh', 'bash'] detection = ['sh', 'bash']
grammar = ShGrammar grammar = ShGrammar
tabbercls = ShTabber tabbercls = ShTabber
opentokens = ('delimiter', 'sh_reserved', 'case.start') opentokens = ('delimiter', 'sh_reserved', 'case.start')
opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi',
'case': 'esac'} 'case': 'esac'}
closetokens = ('delimiter', 'sh_reserved', 'case.end') closetokens = ('delimiter', 'sh_reserved', 'case.end')
closetags = {')': '(', ']': '[', '}': '{', 'done': 'do', 'fi': 'then', closetags = {')': '(', ']': '[', '}': '{', 'done': 'do', 'fi': 'then',

View File

@ -8,9 +8,9 @@ class ShellGrammar(Grammar):
PatternRule(r'shell_mesg', r'^===.*$'), PatternRule(r'shell_mesg', r'^===.*$'),
] ]
class Shell(mode.Fundamental): class Shell(mode.Fundamental):
modename = 'Shell' name = 'Shell'
grammar = ShellGrammar() grammar = ShellGrammar()
colors = { colors = {
'shell_mesg': ('green', 'default', 'bold'), 'shell_mesg': ('green', 'default', 'bold'),
'shell_input': ('cyan', 'default', 'bold'), 'shell_input': ('cyan', 'default', 'bold'),
} }

View File

@ -130,12 +130,12 @@ class OpenShell(OpenShellRaw):
w.application.open_mini_buffer('>>> ', f, self, None, 'shellmini') w.application.open_mini_buffer('>>> ', f, self, None, 'shellmini')
class ShellMini(mode.Fundamental): class ShellMini(mode.Fundamental):
modename = 'ShellMini' name = 'ShellMini'
actions = [ShellExec, ShellClear, ShellCancel, actions = [ShellExec, ShellClear, ShellCancel,
ShellHistoryPrev, ShellHistoryNext, ShellHistoryPrev, ShellHistoryNext,
ShellTab, ShellTab,
ShellPageUp, ShellPageDown, ShellGotoBeginning, ShellGotoEnd, ShellPageUp, ShellPageDown, ShellGotoBeginning, ShellGotoEnd,
OpenShell, OpenShellRaw] OpenShell, OpenShellRaw]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
self.saved_input = "" self.saved_input = ""

View File

@ -73,7 +73,7 @@ class SqlTabber(tab.StackTabber):
def is_base(self, y): def is_base(self, y):
if y == 0: if y == 0:
return True return True
highlighter = self.mode.window.buffer.highlights[self.mode.name()] highlighter = self.mode.window.buffer.highlights[self.mode.name]
if not highlighter.tokens[y]: if not highlighter.tokens[y]:
return False return False
t = highlighter.tokens[y][0] t = highlighter.tokens[y][0]
@ -113,7 +113,7 @@ class SqlTabber(tab.StackTabber):
return currlvl return currlvl
class Sql(mode.Fundamental): class Sql(mode.Fundamental):
modename = 'Sql' name = 'Sql'
extensions = ['.sql'] extensions = ['.sql']
grammar = SqlGrammar grammar = SqlGrammar
tabbercls = SqlTabber tabbercls = SqlTabber

View File

@ -54,7 +54,7 @@ class LearnWord(method.Method):
cursor = w.logical_cursor() cursor = w.logical_cursor()
word = None word = None
for token in w.buffer.highlights[w.mode.name()].tokens[cursor.y]: for token in w.buffer.highlights[w.mode.name].tokens[cursor.y]:
if (token.x <= cursor.x and if (token.x <= cursor.x and
token.end_x() > cursor.x and token.end_x() > cursor.x and
token.name == 'misspelled'): token.name == 'misspelled'):
@ -72,11 +72,11 @@ class LearnWord(method.Method):
w.left_delete() w.left_delete()
class Text(mode.Fundamental): class Text(mode.Fundamental):
modename = 'Text' name = 'Text'
extensions=['.txt'] extensions = ['.txt']
grammar = TextGrammar grammar = TextGrammar
actions = [LearnWord, TextInsertSpace, TextWrapParagraph] actions = [LearnWord, TextInsertSpace, TextWrapParagraph]
config = { config = {
'text.margin': 78, 'text.margin': 78,
} }
def __init__(self, w): def __init__(self, w):

View File

@ -13,7 +13,7 @@ class Text2Grammar(Grammar):
] ]
class Text2(mode.text.Text): class Text2(mode.text.Text):
modename = 'Text2' name = 'Text2'
grammar = Text2Grammar grammar = Text2Grammar
extensions = ['.txt'] extensions = ['.txt']
extensions = [] extensions = []

View File

@ -30,7 +30,7 @@ class TemplateGrammar(Grammar):
] ]
class Template(mode.Fundamental): class Template(mode.Fundamental):
modename = 'Template' name = 'Template'
extensions = ['.tt'] extensions = ['.tt']
grammar = TemplateGrammar grammar = TemplateGrammar
colors = { colors = {

View File

@ -2,7 +2,7 @@ import color, method, mode
from point import Point from point import Point
class Which(mode.Fundamental): class Which(mode.Fundamental):
modename = 'Which' name = 'Which'
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
old_mode = w.buffer.method.old_window.mode old_mode = w.buffer.method.old_window.mode
@ -22,7 +22,7 @@ class Which(mode.Fundamental):
if mode.DEBUG: if mode.DEBUG:
raise raise
else: else:
err = "%s in mode '%s'" % (e, self.name()) err = "%s in mode '%s'" % (e, self.name)
self.window.application.set_error(err) self.window.application.set_error(err)
self._end() self._end()
def _end(self): def _end(self):

View File

@ -113,7 +113,7 @@ class XmlCreateCdata(method.Method):
w.goto(p) w.goto(p)
class XML(mode.Fundamental): class XML(mode.Fundamental):
modename = 'XML' name = 'XML'
extensions = ['.xml', '.xml.in', '.xsl', '.xsd'] extensions = ['.xml', '.xml.in', '.xsl', '.xsd']
grammar = XMLGrammar grammar = XMLGrammar
colors = { colors = {

View File

@ -42,11 +42,11 @@ class YaccTabber(CTabber2):
end_free_tokens = {'string.end': 'string.start'} end_free_tokens = {'string.end': 'string.start'}
class Yacc(mode.Fundamental): class Yacc(mode.Fundamental):
modename = 'yacc' name = 'yacc'
extensions = ['.y'] extensions = ['.y']
grammar = YaccGrammar grammar = YaccGrammar
tabbercls = YaccTabber tabbercls = YaccTabber
colors = { colors = {
'yacc_directive': ('yellow', 'default', 'bold'), 'yacc_directive': ('yellow', 'default', 'bold'),
'yacc_section': ('yellow', 'default', 'bold'), 'yacc_section': ('yellow', 'default', 'bold'),
'yacc_delimiter': ('yellow', 'default', 'bold'), 'yacc_delimiter': ('yellow', 'default', 'bold'),

8
tab.py
View File

@ -19,11 +19,11 @@ class Tabber(object):
self.lines = {} self.lines = {}
def get_highlighter(self): def get_highlighter(self):
return self.mode.window.buffer.highlights[self.mode.name()] return self.mode.window.buffer.highlights[self.mode.name]
def get_tokens(self, y): def get_tokens(self, y):
return self.mode.window.buffer.highlights[self.mode.name()].tokens[y] return self.mode.window.buffer.highlights[self.mode.name].tokens[y]
def get_token(self, y, i): def get_token(self, y, i):
return self.mode.window.buffer.highlights[self.mode.name()].tokens[y][i] return self.mode.window.buffer.highlights[self.mode.name].tokens[y][i]
def token_is_whitespace(self, y, i): def token_is_whitespace(self, y, i):
token = self.get_token(y, i) token = self.get_token(y, i)
@ -256,7 +256,7 @@ class StackTabber2(Tabber):
fixed_indent = False fixed_indent = False
def __init__(self, m): def __init__(self, m):
self.mode = m self.mode = m
self.name = m.name() self.name = m.name
self.lines = {} self.lines = {}
self._reset() self._reset()
def region_added(self, p, newlines): def region_added(self, p, newlines):

View File

@ -54,14 +54,14 @@ def dump(x):
return '%s: %r' % (x, d) return '%s: %r' % (x, d)
def get_margin_limit(w, def_limit=80): def get_margin_limit(w, def_limit=80):
lname = '%s.margin' % w.mode.name().lower() lname = '%s.margin' % w.mode.name.lower()
if lname in w.application.config: if lname in w.application.config:
return w.application.config[lname] return w.application.config[lname]
else: else:
return w.application.config.get('margin', def_limit) return w.application.config.get('margin', def_limit)
def get_margin_color(w, def_color='blue'): def get_margin_color(w, def_color='blue'):
lname = '%s.margin_color' % w.mode.name().lower() lname = '%s.margin_color' % w.mode.name.lower()
if lname in w.application.config: if lname in w.application.config:
return w.application.config[lname] return w.application.config[lname]
else: else:

View File

@ -83,17 +83,16 @@ class Window(object):
# mode stuff # mode stuff
def set_mode(self, m): def set_mode(self, m):
self.mode = m self.mode = m
modename = m.name() if m.name not in self.buffer.highlights and m.lexer is not None:
if modename not in self.buffer.highlights and m.lexer is not None: self.buffer.highlights[m.name] = highlight.Highlighter(m.lexer)
self.buffer.highlights[modename] = highlight.Highlighter(m.lexer) self.buffer.highlights[m.name].highlight(self.buffer.lines)
self.buffer.highlights[modename].highlight(self.buffer.lines)
#self.redraw() #self.redraw()
def get_highlighter(self): def get_highlighter(self):
if self.mode.lexer is None: if self.mode.lexer is None:
return None return None
else: else:
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, char %(x)d'): def set_active_point(self, p, msg='marking on line %(y)d, char %(x)d'):
@ -721,8 +720,7 @@ class Window(object):
# 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 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() if self.mode.name in self.buffer.highlights:
if modename in self.buffer.highlights:
return self.render_line_lit(y, width) return self.render_line_lit(y, width)
else: else:
return self.render_line_raw(y, width) return self.render_line_raw(y, width)
@ -749,8 +747,7 @@ class Window(object):
r = RenderString(s='~', attrs=color.build('red', 'default')) r = RenderString(s='~', attrs=color.build('red', 'default'))
return [(r,)] return [(r,)]
modename = self.mode.name() highlighter = self.buffer.highlights[self.mode.name]
highlighter = self.buffer.highlights[modename]
line = [] line = []
lines = [] lines = []