diff --git a/IDEAS b/IDEAS index 437d293..dbf3905 100644 --- a/IDEAS +++ b/IDEAS @@ -18,7 +18,7 @@ efficient. Move modes into buffers and out of windows. This should reduce the memory footprint a little bit, as well as fixing some weird bugs and making some -interfaces more consistent. +interfaces more consistent. 2008/09/21: diff --git a/MODES b/MODES index 125f90d..8bd1421 100644 --- a/MODES +++ b/MODES @@ -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 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 -exist in Pmacs). +exist in Pmacs--there are no minor modes). 2. Where do they come from? diff --git a/application.py b/application.py index 74de7b8..7450b58 100755 --- a/application.py +++ b/application.py @@ -787,7 +787,6 @@ class Application(object): if slot.window is None: return w = slot.window - modename = w.mode.name() # draw the header if w.mode.header: @@ -844,8 +843,7 @@ class Application(object): lines = w.buffer.lines count = w.mode.header 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 # figure out which "physical line" is the first to be shown. note that diff --git a/buffer/__init__.py b/buffer/__init__.py index a51f976..36c9c6d 100644 --- a/buffer/__init__.py +++ b/buffer/__init__.py @@ -160,7 +160,7 @@ class Buffer(object): def add_window(self, w): if w not in self.windows: 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: self.highlights[modename] = highlight.Highlighter(w.mode.lexer) self.highlights[modename].highlight(self.lines) @@ -170,12 +170,12 @@ class Buffer(object): def remove_window(self, w): if w in self.windows: self.windows.remove(w) - modename = w.mode.name() - if modename in self.highlights: + modename = w.mode.name + if w.mode.name in self.highlights: for w2 in self.windows: - if w2.mode.name() == modename: + if w2.mode.name == w.mode.name: return - del self.highlights[modename] + del self.highlights[w.mode.name] def _region_add(self, p1, p2, lines, act): move = DelMove(self, p1, p2) self.add_to_stack(move, act) diff --git a/method/__init__.py b/method/__init__.py index 6a1ff82..ca0cefd 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -896,7 +896,7 @@ class CloseTag(Method): w.insert_string_at_cursor(self.mytag) app = w.application buffer = w.buffer - highlighter = buffer.highlights[w.mode.name()] + highlighter = buffer.highlights[w.mode.name] tokens = highlighter.tokens # REFACTOR: we have methods in window to do this now diff --git a/method/help.py b/method/help.py index 54ae152..3656bb7 100644 --- a/method/help.py +++ b/method/help.py @@ -15,7 +15,7 @@ class ShowMode(Method): m = w.mode f = Fundamental(w) - lines = ['%s mode' % m.modename, ''] + lines = ['%s mode' % m.name, ''] seen = set() triples = [] @@ -53,7 +53,7 @@ class ShowBindingsBuffer(Method): '''Dump all keybindings for current mode into a new buffer''' def _execute(self, w, **vargs): lines = [] - mode_name = w.mode.name() + mode_name = w.mode.name lines.append('Key bindings for mode %r:' % (mode_name)) lines.append('') diff --git a/method/introspect.py b/method/introspect.py index 797966e..ee4dde5 100644 --- a/method/introspect.py +++ b/method/introspect.py @@ -49,10 +49,9 @@ class DumpMarkers(Method): class DumpTokens(Method): '''Dump all lexical tokens (syntax highlighting debugging)''' def _execute(self, w, **vargs): - modename = w.mode.name() lines = [] - if modename in w.buffer.highlights: - tokens = w.buffer.highlights[modename].tokens + if w.mode.name in w.buffer.highlights: + tokens = w.buffer.highlights[w.mode.name].tokens for i in range(0, len(tokens)): lines.append("LINE %d" % (i + 1)) group = tokens[i] @@ -77,10 +76,9 @@ class DumpTokens(Method): class DumpAggregateTokenData(Method): '''Dump all lexical tokens into an aggregated format''' def _execute(self, w, **vargs): - name = w.mode.name() lines = [] - if name in w.buffer.highlights: - tokens = w.buffer.highlights[name].tokens + if w.mode.name in w.buffer.highlights: + tokens = w.buffer.highlights[w.mode.name].tokens for group in tokens: for token in group: s1 = token.name diff --git a/method/svn.py b/method/svn.py index 49881a0..63b622e 100644 --- a/method/svn.py +++ b/method/svn.py @@ -119,18 +119,20 @@ class SvnStatus(Method): c = data[0] status = self.column.get(c, 'Error (%s)' % c) fields = data[6:].split() - try: - (rrev, lrev, lauthor, filename) = fields - except: - raise Exception, '%r %r' % (fields, data[6:]) - - w.buffer.metadata['svn-filename'] = filename - w.buffer.metadata['svn-status'] = status - w.buffer.metadata['svn-lrev'] = lrev - w.buffer.metadata['svn-rrev'] = rrev - w.buffer.metadata['svn-author'] = lauthor - - w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor)) + if len(fields) == 4: + rrev, lrev, lauthor, filename = fields + w.buffer.metadata['svn-filename'] = filename + w.buffer.metadata['svn-status'] = status + w.buffer.metadata['svn-lrev'] = lrev + w.buffer.metadata['svn-rrev'] = rrev + w.buffer.metadata['svn-author'] = lauthor + w.buffer.metadata['vc-info'] = '[svn:%s/%s]' % (lrev, rrev) + w.set_error('%s %s %s/%s [%s]' % (filename, status, rrev, lrev, lauthor)) + else: + w.buffer.metadata['svn-filename'] = path + 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): '''display the SVN log for the current file''' diff --git a/mode/__init__.py b/mode/__init__.py index 6a7cd31..bb4d5ad 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -77,7 +77,7 @@ class Handler(object): class Fundamental(Handler): '''This is the default mode''' - modename = "Fundamental" + name = "Fundamental" paths = [] basenames = [] extensions = [] @@ -102,7 +102,6 @@ class Fundamental(Handler): actions = [] _bindings = {} 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" header_size = 3 @@ -124,12 +123,12 @@ class Fundamental(Handler): rmargin = property(_get_rmargin, _set_rmargin) 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, detection=cls.detection) for (key, val) in cls.colors.iteritems(): 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 else: app.token_colors[key] = val @@ -290,14 +289,14 @@ class Fundamental(Handler): # buffer settings def get_setting(self, name): - self.window.buffer.settings.setdefault(self.modename, {}) - return self.window.buffer.settings[self.modename].get(name) + self.window.buffer.settings.setdefault(self.name, {}) + return self.window.buffer.settings[self.name].get(name) def init_setting(self, name, value): - self.window.buffer.settings.setdefault(self.modename, {}) - self.window.buffer.settings[self.modename].setdefault(name, value) + self.window.buffer.settings.setdefault(self.name, {}) + self.window.buffer.settings[self.name].setdefault(name, value) def set_setting(self, name, value): - self.window.buffer.settings.setdefault(self.modename, {}) - self.window.buffer.settings[self.modename][name] = value + self.window.buffer.settings.setdefault(self.name, {}) + self.window.buffer.settings[self.name][name] = value # header def showing_header(self): @@ -384,10 +383,6 @@ class Fundamental(Handler): s = ' ' * lm return [RenderString(s=s, attrs=color.build('default', 'default', 'bold'))] - # get mode name - def name(self): - return self.modename - def _get_flag(self): b = self.window.buffer if b.readonly(): @@ -427,7 +422,7 @@ class Fundamental(Handler): d = defaultdict(str) d2 = { 'bname': w.buffer.name(), - 'mname': self.name(), + 'mname': self.name, 'flag': self._get_flag(), 'perc': self._get_perc(), 'indent': self._get_indent(), @@ -465,11 +460,11 @@ class Fundamental(Handler): if DEBUG: raise else: - err = "%s in mode '%s'" % (e, self.name()) + err = "%s in mode '%s'" % (e, self.name) self.window.set_error(err) def region_added(self, p, newlines): - mname = self.name() + mname = self.name if self.lexer is not None: ydelta = len(newlines) - 1 xdelta = len(newlines[-1]) diff --git a/mode/awk.py b/mode/awk.py index 181eff0..a70de33 100644 --- a/mode/awk.py +++ b/mode/awk.py @@ -131,8 +131,8 @@ class AwkFilterInput(Method): w.set_error("awk exited with status %d" % status) class Awk(mode.Fundamental): + name = 'awk' tabbercls = AwkTabber - modename = 'awk' extensions = ['.awk'] grammar = AwkGrammar opentokens = ('delimiter',) diff --git a/mode/bds.py b/mode/bds.py index 186c37b..809c418 100644 --- a/mode/bds.py +++ b/mode/bds.py @@ -23,7 +23,7 @@ class BDSGrammar(Grammar): ] class BDS(mode.Fundamental): - modename = 'bds' + name = 'bds' extensions = ['.bds'] grammar = BDSGrammar colors = { diff --git a/mode/blame.py b/mode/blame.py index 65a8f7e..83f3a21 100644 --- a/mode/blame.py +++ b/mode/blame.py @@ -15,9 +15,9 @@ class BlameGrammar(Grammar): ] class Blame(mode.Fundamental): - modename = 'Blame' + name = 'Blame' grammar = BlameGrammar - colors = { + colors = { 'metadata.start': ('blue', 'default', 'bold'), 'metadata.username': ('cyan', 'default', 'bold'), 'metadata.end': ('green', 'default', 'bold'), diff --git a/mode/brm.py b/mode/brm.py index 0c0563a..0a31fa8 100644 --- a/mode/brm.py +++ b/mode/brm.py @@ -133,7 +133,7 @@ def _end(w): assert not w.application.mini_active class Brm(mode.Fundamental): - modename = 'Bicycle-Repairman' + name = 'Bicycle-Repairman' actions = [ReplaceAll, ReplaceDone, ReplaceOne, SkipReplace, BrmCancel] def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/c.py b/mode/c.py index 65acc41..ce83393 100644 --- a/mode/c.py +++ b/mode/c.py @@ -156,7 +156,7 @@ class CMake(method.shell.Exec): cmdname='c-make') class C(mode.Fundamental): - modename = 'C' + name = 'C' extensions = ['.c', '.h', '.cpp'] tabbercls = CTabber2 grammar = CGrammar diff --git a/mode/cheetah.py b/mode/cheetah.py index 268e0f2..0bab017 100644 --- a/mode/cheetah.py +++ b/mode/cheetah.py @@ -33,7 +33,7 @@ class TemplateGrammar(Grammar): ] class Template(mode.Fundamental): - modename = 'Cheetah' + name = 'Cheetah' extensions = ['.tmpl'] grammar = TemplateGrammar commentc = '##' diff --git a/mode/colortext.py b/mode/colortext.py index 72f6854..793ffcf 100644 --- a/mode/colortext.py +++ b/mode/colortext.py @@ -1,6 +1,6 @@ import mode class Colortext(mode.Fundamental): - modename = 'Colortext' + name = 'Colortext' install = Colortext.install diff --git a/mode/conf.py b/mode/conf.py index 5297ad2..c4266c6 100644 --- a/mode/conf.py +++ b/mode/conf.py @@ -11,7 +11,7 @@ class ConfGrammar(Grammar): ] class Conf(mode.Fundamental): - modename = 'conf' + name = 'conf' extensions = ['.conf', '.cfg', '.cnf', '.config'] grammar = ConfGrammar colors = {} diff --git a/mode/console.py b/mode/console.py index 3ede815..f4e6126 100644 --- a/mode/console.py +++ b/mode/console.py @@ -3,6 +3,6 @@ from lex import Grammar, PatternRule, RegionRule from mode.python import StringGrammar1, StringGrammar2, PythonGrammar class Console(mode.Fundamental): - modename = 'Console' + name = 'Console' install = Console.install diff --git a/mode/consolemini.py b/mode/consolemini.py index 7d5e790..121f155 100644 --- a/mode/consolemini.py +++ b/mode/consolemini.py @@ -214,9 +214,9 @@ class ConsoleGotoEnd(ConsoleBaseMethod): subcls = method.move.GotoEnd class ConsoleMini(mode.Fundamental): - modename = 'ConsoleMini' - grammar = PythonGrammar - actions = [ConsoleExec, ConsoleClear, ConsoleCancel, ConsoleHistoryPrev, + name = 'ConsoleMini' + grammar = PythonGrammar + actions = [ConsoleExec, ConsoleClear, ConsoleCancel, ConsoleHistoryPrev, ConsoleHistoryNext, ConsoleTab, ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd] _bindings = { diff --git a/mode/css.py b/mode/css.py index 2b9e6d7..4f920aa 100644 --- a/mode/css.py +++ b/mode/css.py @@ -53,14 +53,14 @@ class CSSGrammar(Grammar): ] class CSS(mode.Fundamental): - modename = 'CSS' - extensions = ['.css'] - grammar = CSSGrammar + name = 'CSS' + extensions = ['.css'] + grammar = CSSGrammar opentokens = ('delimiter',) opentags = {'(': ')', '[': ']', '{': '}'} closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} - colors = { + colors = { 'css_dimension': ('magenta', 'default', 'bold'), 'css_percentage': ('magenta', 'default', 'bold'), 'css_length': ('magenta', 'default', 'bold'), diff --git a/mode/diff.py b/mode/diff.py index 6dfd222..dd8871d 100644 --- a/mode/diff.py +++ b/mode/diff.py @@ -12,10 +12,10 @@ class DiffGrammar(Grammar): ] class Diff(mode.Fundamental): - modename = 'diff' - extensions = ['.patch', '.diff'] - grammar = DiffGrammar() - colors = { + name = 'diff' + extensions = ['.patch', '.diff'] + grammar = DiffGrammar() + colors = { 'left': ('red', 'default', 'bold'), 'right': ('blue', 'default', 'bold'), 'seperator': ('magenta', 'default', 'bold'), diff --git a/mode/dir.py b/mode/dir.py index 9732059..709048f 100644 --- a/mode/dir.py +++ b/mode/dir.py @@ -163,9 +163,9 @@ class RemovePath(Method): w.set_error("failed to delete %r" % path) class Dir(mode.Fundamental): - modename = 'Dir' + name = 'Dir' grammar = DirGrammar() - colors = { + colors = { 'dir_blk.start': ('cyan', 'default', 'bold'), 'dir_blk.dir_name': ('cyan', 'default', 'bold'), 'dir_chr.start': ('yellow', 'default', 'bold'), diff --git a/mode/elisp.py b/mode/elisp.py index e238648..4e54661 100644 --- a/mode/elisp.py +++ b/mode/elisp.py @@ -29,7 +29,7 @@ class ELispGrammar(Grammar): ] class ELisp(mode.Fundamental): - modename = 'ELisp' + name = 'ELisp' tabwidth = 2 basenames = ['.emacs'] extensions = ['.el'] diff --git a/mode/erlang.py b/mode/erlang.py index d5f0396..8e82500 100644 --- a/mode/erlang.py +++ b/mode/erlang.py @@ -84,7 +84,7 @@ class ErlangTabber(tab.StackTabber): # Interact._execute(self, w, bname='*Erl*', cmd='erl') class Erlang(mode.Fundamental): - modename = 'Erlang' + name = 'Erlang' extensions = ['.erl'] tabwidth = 4 tabbercls = ErlangTabber diff --git a/mode/error.py b/mode/error.py index d3bd470..ad60fcd 100644 --- a/mode/error.py +++ b/mode/error.py @@ -40,7 +40,7 @@ class ErrorGotoLine(Method): w.set_error(errline) class Error(mode.Fundamental): - modename = 'Error' + name = 'Error' actions = [ErrorGotoLine] def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/forth.py b/mode/forth.py index 0b2bdc5..93483e6 100644 --- a/mode/forth.py +++ b/mode/forth.py @@ -119,7 +119,7 @@ class ForthTabber(tab.StackTabber2): self.curr_level = 0 class Forth(Fundamental): - modename = 'FORTH' + name = 'FORTH' extensions = ['.fs', '.fi', '.fb'] grammar = ForthGrammar commentc = '\\ ' diff --git a/mode/fstab.py b/mode/fstab.py index 44ce7bc..c34f807 100644 --- a/mode/fstab.py +++ b/mode/fstab.py @@ -15,7 +15,7 @@ class FstabGrammar(Grammar): ] class Fstab(mode.Fundamental): - modename = 'fstab' + name = 'fstab' basenames = ['fstab'] grammar = FstabGrammar colors = { diff --git a/mode/haskell.py b/mode/haskell.py index 99a7faa..4b75471 100644 --- a/mode/haskell.py +++ b/mode/haskell.py @@ -57,17 +57,17 @@ class HaskellTabber(tab.Tabber): pass class Haskell(mode.Fundamental): - modename = 'Haskell' - extensions = ['.hs'] - tabwidth = 4 - commentc = '--' - #tabbercls = mode.lisp.LispTabber - grammar = HaskellGrammar + name = 'Haskell' + extensions = ['.hs'] + tabwidth = 4 + commentc = '--' + #tabbercls = mode.lisp.LispTabber + grammar = HaskellGrammar opentokens = ('delimiter',) opentags = {'(': ')', '{': '}', '[': ']'} closetokens = ('delimiter',) closetags = {')': '(', '}': '{', ']': '['} - colors = { + colors = { 'hs_constructor': ('magenta', 'default', 'bold'), 'hs_declaration': ('blue', 'default', 'bold'), 'hs_variable': ('yellow', 'default', 'bold'), diff --git a/mode/hex.py b/mode/hex.py index 7925ace..d2223df 100644 --- a/mode/hex.py +++ b/mode/hex.py @@ -215,14 +215,14 @@ class ShowAddress(Method): w.set_error("Cursor's address is 0x%08x" % addr) class Hex(mode.Fundamental): - modename = 'Hex' + name = 'Hex' config = { 'hex.disinst': 'disinst', } - lmargin = 12 - rmargin = 18 - _ctrans = ['.'] * 256 - byteorder = 'native' + lmargin = 12 + rmargin = 18 + _ctrans = ['.'] * 256 + byteorder = 'native' byteorders = { 'native': '=', 'little': '<', diff --git a/mode/html.py b/mode/html.py index ddeb7ab..ed9f159 100644 --- a/mode/html.py +++ b/mode/html.py @@ -73,7 +73,7 @@ class HtmlCheckSpelling(method.Method): w.buffer.reload() class HTML(mode.Fundamental): - modename = 'HTML' + name = 'HTML' extensions = ['.html', '.htm', '.shtml', '.shtm', '.xhtml'] grammar = HTMLGrammar colors = { diff --git a/mode/insertmini.py b/mode/insertmini.py index 783aa67..d178b4d 100644 --- a/mode/insertmini.py +++ b/mode/insertmini.py @@ -25,7 +25,7 @@ class MiniInsertCancel(method.Method): w.application.close_mini_buffer() class InsertMini(mode.Fundamental): - modename = 'InsertMini' + name = 'InsertMini' actions = [MiniInsertLine, MiniInsertComplete, MiniInsertCancel, MiniInsertTab] def __init__(self, w): diff --git a/mode/iperl.py b/mode/iperl.py index 74a468b..bbc78ac 100644 --- a/mode/iperl.py +++ b/mode/iperl.py @@ -10,9 +10,9 @@ class IperlGrammar(Grammar): PatternRule(r'iperl_reserved', r'undef'), ] class Iperl(mode.Fundamental): - modename = 'IPerl' + name = 'IPerl' grammar = IperlGrammar() - colors = { + colors = { 'iperl_input.start': ('red', 'default', 'bold'), 'iperl_reserved': ('magenta', 'default', 'bold'), } diff --git a/mode/iperlmini.py b/mode/iperlmini.py index 2425fbc..e3e0069 100644 --- a/mode/iperlmini.py +++ b/mode/iperlmini.py @@ -91,9 +91,9 @@ class IperlGotoEnd(mode.consolemini.ConsoleGotoEnd): subbuf = '*IPerl*' class IperlMini(mode.Fundamental): - modename = 'IperlMini' - actions = [IperlExec, IperlTab, IperlStart, IperlPathStart, - IperlPageUp, IperlPageDown, IperlGotoBeginning, IperlGotoEnd] + name = 'IperlMini' + actions = [IperlExec, IperlTab, IperlStart, IperlPathStart, + IperlPageUp, IperlPageDown, IperlGotoBeginning, IperlGotoEnd] readre = re.compile('^([A-Z]+):(.*)\n$') def _readline(self): b = self.get_iperl() diff --git a/mode/ipython.py b/mode/ipython.py index 8dd3cee..d87eae0 100644 --- a/mode/ipython.py +++ b/mode/ipython.py @@ -11,9 +11,9 @@ class IpythonGrammar(Grammar): PatternRule(r'ipython_reserved', r'undef'), ] class Ipython(mode.Fundamental): - modename = 'IPython' + name = 'IPython' grammar = IpythonGrammar() - colors = { + colors = { 'ipython_input.start': ('red', 'default', 'bold'), 'ipython_reserved': ('magenta', 'default', 'bold'), } diff --git a/mode/ipythonmini.py b/mode/ipythonmini.py index fcb97b5..2247d75 100644 --- a/mode/ipythonmini.py +++ b/mode/ipythonmini.py @@ -88,9 +88,9 @@ class IpythonGotoEnd(mode.consolemini.ConsoleGotoEnd): subbuf = '*IPython*' class IpythonMini(mode.Fundamental): - modename = 'IpythonMini' - actions = [IpythonExec, IpythonTab, IpythonStart, IpythonPathStart, - IpythonPageUp, IpythonPageDown, IpythonGotoBeginning, IpythonGotoEnd] + name = 'IpythonMini' + actions = [IpythonExec, IpythonTab, IpythonStart, IpythonPathStart, + IpythonPageUp, IpythonPageDown, IpythonGotoBeginning, IpythonGotoEnd] def get_ipython(self): return self.window.buffer.method.main_buffer def read_sync(self): diff --git a/mode/java.py b/mode/java.py index 9484a82..ff136ed 100644 --- a/mode/java.py +++ b/mode/java.py @@ -117,7 +117,7 @@ class JavaContext(context.Context): i += 1 class Java(mode.Fundamental): - modename = 'Java' + name = 'Java' extensions = ['.java'] tabbercls = JavaTabber2 grammar = JavaGrammar diff --git a/mode/javascript.py b/mode/javascript.py index 6b33fb5..e9babee 100644 --- a/mode/javascript.py +++ b/mode/javascript.py @@ -75,7 +75,7 @@ class JavascriptTabber2(tab.StackTabber2): def is_base(self, y): if y == 0: 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]: return False t = highlighter.tokens[y][0] @@ -87,7 +87,7 @@ class JavascriptTabber2(tab.StackTabber2): 'comment.data', 'comment.null', 'comment.end') class Javascript(mode.Fundamental): - modename = 'Javascript' + name = 'Javascript' extensions = ['.js'] grammar = JavascriptGrammar tabbercls = JavascriptTabber2 diff --git a/mode/latex.py b/mode/latex.py index 286d562..0f574ce 100644 --- a/mode/latex.py +++ b/mode/latex.py @@ -114,7 +114,7 @@ class LatexCheckSpelling(method.Method): w.buffer.reload() class Latex(mode.Fundamental): - modename = 'Latex' + name = 'Latex' extensions = ['.latex', '.tex'] commentc = '%' grammar = LatexGrammar diff --git a/mode/lily.py b/mode/lily.py index 305935e..d414f1c 100644 --- a/mode/lily.py +++ b/mode/lily.py @@ -52,10 +52,10 @@ class LilyTabber(tab.StackTabber): st = ('spaces', 'null',) class Lily(mode.Fundamental): - modename = 'lily' + name = 'lily' extensions = ['.ly'] - tabwidth = 2 - tabbercls = LilyTabber + tabwidth = 2 + tabbercls = LilyTabber grammar = LilyGrammar commentc = '%' colors = { diff --git a/mode/lisp.py b/mode/lisp.py index c19cd9f..0aa8640 100644 --- a/mode/lisp.py +++ b/mode/lisp.py @@ -36,7 +36,7 @@ class LispTabber(tab.StackTabber): return currlvl class Lisp(mode.Fundamental): - modename = 'Lisp' + name = 'Lisp' tabwidth = 2 tabbercls = LispTabber grammar = LispGrammar diff --git a/mode/lua.py b/mode/lua.py index e250318..6384d83 100644 --- a/mode/lua.py +++ b/mode/lua.py @@ -38,7 +38,7 @@ class LuaCheckSyntax(method.Method): app.data_buffer("*Lua-Check-Syntax*", output) class Lua(mode.Fundamental): - modename = 'Lua' + name = 'Lua' extensions = ['.lua'] #tabbercls = mode.lisp.LispTabber grammar = LuaGrammar @@ -49,7 +49,7 @@ class Lua(mode.Fundamental): closetags = {')': '(', ']': '[', '}': '{'} colors = {} actions = [LuaCheckSyntax] - _bindings = { + _bindings = { 'close-paren': (')',), 'close-brace': ('}',), 'close-bracket': (']',), diff --git a/mode/make.py b/mode/make.py index 6188816..b4963f6 100644 --- a/mode/make.py +++ b/mode/make.py @@ -33,7 +33,7 @@ class MakeGrammar(Grammar): ] class Make(mode.Fundamental): - modename = 'Make' + name = 'Make' basenames = ['Makefile'] grammar = MakeGrammar commentc = '#' diff --git a/mode/mbox.py b/mode/mbox.py index 5ebdb90..be259ad 100644 --- a/mode/mbox.py +++ b/mode/mbox.py @@ -210,8 +210,8 @@ class MailListGrammar(Grammar): ] class MboxMsg(mode.Fundamental): - modename = 'MboxMsg' - colors = { + name = 'MboxMsg' + colors = { 'mail_pgp': ('red', 'default', 'bold'), 'mail_signature.start': ('red', 'default', 'bold'), 'mail_signature.data': ('red', 'default', 'bold'), @@ -230,10 +230,10 @@ class MboxMsg(mode.Fundamental): mode.Fundamental.__init__(self, w) class Mbox(mode.Fundamental): - modename = 'Mbox' - grammar = MailListGrammar - actions = [MboxRefresh, MboxOpenPath, MboxReadMsg] - colors = { + name = 'Mbox' + grammar = MailListGrammar + actions = [MboxRefresh, MboxOpenPath, MboxReadMsg] + colors = { 'index': ('default', 'default', 'bold'), 'flag': ('yellow', 'default', 'bold'), 'month': ('green', 'default', 'bold'), diff --git a/mode/mini.py b/mode/mini.py index 3b605be..a87707b 100644 --- a/mode/mini.py +++ b/mode/mini.py @@ -38,8 +38,8 @@ class MiniTabComplete(method.Method): use_completion_window(app, s2, candidates) class Mini(mode.Fundamental): - modename = 'Mini' - actions = [MiniCallback, MiniTabComplete] + name = 'Mini' + actions = [MiniCallback, MiniTabComplete] def __init__(self, w): mode.Fundamental.__init__(self, w) self.add_bindings('mini-callback', ('RETURN',)) diff --git a/mode/mp3.py b/mode/mp3.py index e1f6149..6cc2283 100644 --- a/mode/mp3.py +++ b/mode/mp3.py @@ -122,10 +122,10 @@ class Mp3OpenPath(Method): w.application.switch_buffer(b) class Mp3(mode.Fundamental): - modename = 'Mp3' - grammar = Mp3Grammar - actions = [Mp3Refresh, Mp3OpenPath] - colors = { + name = 'Mp3' + grammar = Mp3Grammar + actions = [Mp3Refresh, Mp3OpenPath] + colors = { 'mp3_label': ('blue', 'default', 'bold'), 'mp3_tag.start': ('default', 'default', 'bold'), 'mp3_tag.data': ('green', 'default', 'bold'), diff --git a/mode/mutt.py b/mode/mutt.py index 954c614..6e4a413 100644 --- a/mode/mutt.py +++ b/mode/mutt.py @@ -24,9 +24,9 @@ class MuttInsertSpace(mode.text.TextInsertSpace): wrapper = MuttWrapParagraph class Mutt(mode.Fundamental): - modename = 'Mutt' - grammar = MuttGrammar() - colors = { + name = 'Mutt' + grammar = MuttGrammar() + colors = { 'mutt_header': ('green', 'default', 'bold'), 'email': ('cyan', 'default', 'bold'), 'url': ('cyan', 'default', 'bold'), diff --git a/mode/nasm.py b/mode/nasm.py index e2160db..9d451d3 100644 --- a/mode/nasm.py +++ b/mode/nasm.py @@ -26,7 +26,7 @@ class NasmGrammar(Grammar): ] class Nasm(mode.Fundamental): - modename = 'nasm' + name = 'nasm' extensions = ['.s'] grammar = NasmGrammar commentc = ';' diff --git a/mode/ocaml.py b/mode/ocaml.py index 910af7e..4211f82 100644 --- a/mode/ocaml.py +++ b/mode/ocaml.py @@ -48,7 +48,7 @@ class OcamlGrammar(Grammar): ] class Ocaml(mode.Fundamental): - modename = 'ocaml' + name = 'ocaml' extensions = ['.mli', '.ml'] grammar = OcamlGrammar opentokens = ('delimiter',) diff --git a/mode/perl.py b/mode/perl.py index 88de60a..19f35dd 100644 --- a/mode/perl.py +++ b/mode/perl.py @@ -420,7 +420,7 @@ class PerlWrapParagraph(method.WrapParagraph): return t.name == 'spaces' def _detect_line_type(self, w, y): - h = w.buffer.highlights[w.mode.name()] + h = w.buffer.highlights[w.mode.name] ltype = None for t in h.tokens[y]: fqname = t.fqname() @@ -442,7 +442,7 @@ class PerlWrapParagraph(method.WrapParagraph): return ltype def _fix_comments(self, c, w): - h = w.buffer.highlights[w.mode.name()] + h = w.buffer.highlights[w.mode.name] y1 = c.y y2 = c.y while y2 < len(w.buffer.lines) - 1: @@ -621,7 +621,7 @@ class PerlContext(context.Context): i += 1 class Perl(mode.Fundamental): - modename = 'Perl' + name = 'Perl' extensions = ['.pl', '.pm', '.pod'] detection = ['perl'] tabbercls = PerlTabber2 diff --git a/mode/php.py b/mode/php.py index bcc9c49..8cdcef1 100644 --- a/mode/php.py +++ b/mode/php.py @@ -40,7 +40,7 @@ class PHPGrammar(Grammar): # if y == 0: # 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]: # return False # @@ -161,7 +161,7 @@ class PHPGrammar(Grammar): # return currlvl class PHP(mode.Fundamental): - modename = 'PHP' + name = 'PHP' extensions = ['.php'] #tabbercls = JavaTabber grammar = PHPGrammar diff --git a/mode/pipe.py b/mode/pipe.py index 83349d8..0d91622 100644 --- a/mode/pipe.py +++ b/mode/pipe.py @@ -19,7 +19,7 @@ class PipeInsertEsc(PipeInsertChr): self.string = chr(27) + chr(i) class Pipe(Fundamental): - modename = 'pipe' + name = 'pipe' def __init__(self, w): Fundamental.__init__(self, w) diff --git a/mode/python.py b/mode/python.py index d5f0562..3f5db41 100644 --- a/mode/python.py +++ b/mode/python.py @@ -541,7 +541,7 @@ class PythonContext(context.Context): self.namelines[k] = (curr, None) class Python(mode.Fundamental): - modename = 'Python' + name = 'Python' extensions = ['.py'] detection = ['python'] tabbercls = PythonTabber @@ -580,7 +580,7 @@ class Python(mode.Fundamental): "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 def get_status_names(self): @@ -592,7 +592,7 @@ class Python(mode.Fundamental): # xyz def get_header(self): - fg, bg = "default", "red" + fg, bg = "default", "blue" if self.tabber is None: s = "Header support is not available for this mode" diff --git a/mode/replace.py b/mode/replace.py index 1ce6817..e9bd1fc 100644 --- a/mode/replace.py +++ b/mode/replace.py @@ -133,7 +133,7 @@ def _end(w): assert not w.application.mini_active class Replace(mode.Fundamental): - modename = 'Replace' + name = 'Replace' actions = [ReplaceAll, ReplaceDone, ReplaceOne, SkipReplace, CancelReplace] def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/rst.py b/mode/rst.py index 61a9567..86da544 100644 --- a/mode/rst.py +++ b/mode/rst.py @@ -54,7 +54,7 @@ class RstBuild(Method): pass class RST(mode.Fundamental): - modename = 'RST' + name = 'RST' extensions = ['.rst'] grammar = RSTGrammar colors = { diff --git a/mode/scheme.py b/mode/scheme.py index 1aa97d6..9736379 100644 --- a/mode/scheme.py +++ b/mode/scheme.py @@ -51,7 +51,7 @@ class GuileLoadFile(method.shell.Interact): b.pipe_write('(load "%s")\n' % path) class Scheme(mode.Fundamental): - modename = 'Scheme' + name = 'Scheme' extensions = ['.scm'] tabwidth = 2 tabbercls = mode.lisp.LispTabber diff --git a/mode/search.py b/mode/search.py index e5bc025..8437b68 100644 --- a/mode/search.py +++ b/mode/search.py @@ -116,7 +116,7 @@ def _end(w): w.application.last_search = w.buffer.make_string() class Search(mode.Fundamental): - modename = 'Search' + name = 'Search' actions = [SearchNext, SearchPrevious, EndSearch, CancelSearch, SearchDeleteLeft, SearchDeleteLeftWord] def __init__(self, w): diff --git a/mode/sh.py b/mode/sh.py index d53e68b..1fce106 100644 --- a/mode/sh.py +++ b/mode/sh.py @@ -129,7 +129,7 @@ class ShTabber(tab.StackTabber): def is_base(self, y): if y == 0: 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]: return False t = highlighter.tokens[y][0] @@ -166,15 +166,15 @@ class ShCheckSyntax(Method): app.data_buffer("*Sh-Check-Syntax*", output) class Sh(mode.Fundamental): - modename = 'sh' - paths = ['/etc/profile'] - basenames = ['.bashrc', '.bash_profile', '.profile'] - extensions = ['.bash', '.sh'] - detection = ['sh', 'bash'] - grammar = ShGrammar - tabbercls = ShTabber - opentokens = ('delimiter', 'sh_reserved', 'case.start') - opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', + name = 'sh' + paths = ['/etc/profile'] + basenames = ['.bashrc', '.bash_profile', '.profile'] + extensions = ['.bash', '.sh'] + detection = ['sh', 'bash'] + grammar = ShGrammar + tabbercls = ShTabber + opentokens = ('delimiter', 'sh_reserved', 'case.start') + opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', 'case': 'esac'} closetokens = ('delimiter', 'sh_reserved', 'case.end') closetags = {')': '(', ']': '[', '}': '{', 'done': 'do', 'fi': 'then', diff --git a/mode/shell.py b/mode/shell.py index 2ac6535..4b4ca6e 100644 --- a/mode/shell.py +++ b/mode/shell.py @@ -8,9 +8,9 @@ class ShellGrammar(Grammar): PatternRule(r'shell_mesg', r'^===.*$'), ] class Shell(mode.Fundamental): - modename = 'Shell' + name = 'Shell' grammar = ShellGrammar() - colors = { + colors = { 'shell_mesg': ('green', 'default', 'bold'), 'shell_input': ('cyan', 'default', 'bold'), } diff --git a/mode/shellmini.py b/mode/shellmini.py index c9949b7..bb7bd25 100644 --- a/mode/shellmini.py +++ b/mode/shellmini.py @@ -130,12 +130,12 @@ class OpenShell(OpenShellRaw): w.application.open_mini_buffer('>>> ', f, self, None, 'shellmini') class ShellMini(mode.Fundamental): - modename = 'ShellMini' - actions = [ShellExec, ShellClear, ShellCancel, - ShellHistoryPrev, ShellHistoryNext, - ShellTab, - ShellPageUp, ShellPageDown, ShellGotoBeginning, ShellGotoEnd, - OpenShell, OpenShellRaw] + name = 'ShellMini' + actions = [ShellExec, ShellClear, ShellCancel, + ShellHistoryPrev, ShellHistoryNext, + ShellTab, + ShellPageUp, ShellPageDown, ShellGotoBeginning, ShellGotoEnd, + OpenShell, OpenShellRaw] def __init__(self, w): mode.Fundamental.__init__(self, w) self.saved_input = "" diff --git a/mode/sql.py b/mode/sql.py index 0eaa84c..250433a 100644 --- a/mode/sql.py +++ b/mode/sql.py @@ -73,7 +73,7 @@ class SqlTabber(tab.StackTabber): def is_base(self, y): if y == 0: 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]: return False t = highlighter.tokens[y][0] @@ -113,7 +113,7 @@ class SqlTabber(tab.StackTabber): return currlvl class Sql(mode.Fundamental): - modename = 'Sql' + name = 'Sql' extensions = ['.sql'] grammar = SqlGrammar tabbercls = SqlTabber diff --git a/mode/text.py b/mode/text.py index 912c66b..2ebafc9 100644 --- a/mode/text.py +++ b/mode/text.py @@ -54,7 +54,7 @@ class LearnWord(method.Method): cursor = w.logical_cursor() 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 token.end_x() > cursor.x and token.name == 'misspelled'): @@ -72,11 +72,11 @@ class LearnWord(method.Method): w.left_delete() class Text(mode.Fundamental): - modename = 'Text' - extensions=['.txt'] - grammar = TextGrammar - actions = [LearnWord, TextInsertSpace, TextWrapParagraph] - config = { + name = 'Text' + extensions = ['.txt'] + grammar = TextGrammar + actions = [LearnWord, TextInsertSpace, TextWrapParagraph] + config = { 'text.margin': 78, } def __init__(self, w): diff --git a/mode/text2.py b/mode/text2.py index 5d7dd3f..35c38bc 100644 --- a/mode/text2.py +++ b/mode/text2.py @@ -13,7 +13,7 @@ class Text2Grammar(Grammar): ] class Text2(mode.text.Text): - modename = 'Text2' + name = 'Text2' grammar = Text2Grammar extensions = ['.txt'] extensions = [] diff --git a/mode/tt.py b/mode/tt.py index 3b998c2..d709da0 100644 --- a/mode/tt.py +++ b/mode/tt.py @@ -30,7 +30,7 @@ class TemplateGrammar(Grammar): ] class Template(mode.Fundamental): - modename = 'Template' + name = 'Template' extensions = ['.tt'] grammar = TemplateGrammar colors = { diff --git a/mode/which.py b/mode/which.py index 27850d8..58576ec 100644 --- a/mode/which.py +++ b/mode/which.py @@ -2,7 +2,7 @@ import color, method, mode from point import Point class Which(mode.Fundamental): - modename = 'Which' + name = 'Which' def __init__(self, w): mode.Fundamental.__init__(self, w) old_mode = w.buffer.method.old_window.mode @@ -22,7 +22,7 @@ class Which(mode.Fundamental): if mode.DEBUG: raise else: - err = "%s in mode '%s'" % (e, self.name()) + err = "%s in mode '%s'" % (e, self.name) self.window.application.set_error(err) self._end() def _end(self): diff --git a/mode/xml.py b/mode/xml.py index eca2b72..2d96e43 100644 --- a/mode/xml.py +++ b/mode/xml.py @@ -113,7 +113,7 @@ class XmlCreateCdata(method.Method): w.goto(p) class XML(mode.Fundamental): - modename = 'XML' + name = 'XML' extensions = ['.xml', '.xml.in', '.xsl', '.xsd'] grammar = XMLGrammar colors = { diff --git a/mode/yacc.py b/mode/yacc.py index 52e3e54..56c21a4 100644 --- a/mode/yacc.py +++ b/mode/yacc.py @@ -42,11 +42,11 @@ class YaccTabber(CTabber2): end_free_tokens = {'string.end': 'string.start'} class Yacc(mode.Fundamental): - modename = 'yacc' + name = 'yacc' extensions = ['.y'] grammar = YaccGrammar tabbercls = YaccTabber - colors = { + colors = { 'yacc_directive': ('yellow', 'default', 'bold'), 'yacc_section': ('yellow', 'default', 'bold'), 'yacc_delimiter': ('yellow', 'default', 'bold'), diff --git a/tab.py b/tab.py index ad3db6b..3d1024f 100644 --- a/tab.py +++ b/tab.py @@ -19,11 +19,11 @@ class Tabber(object): self.lines = {} 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): - 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): - 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): token = self.get_token(y, i) @@ -256,7 +256,7 @@ class StackTabber2(Tabber): fixed_indent = False def __init__(self, m): self.mode = m - self.name = m.name() + self.name = m.name self.lines = {} self._reset() def region_added(self, p, newlines): diff --git a/util.py b/util.py index 01aa21a..70363a8 100644 --- a/util.py +++ b/util.py @@ -54,14 +54,14 @@ def dump(x): return '%s: %r' % (x, d) 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: return w.application.config[lname] else: return w.application.config.get('margin', def_limit) 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: return w.application.config[lname] else: diff --git a/window.py b/window.py index dee5aba..a428b95 100644 --- a/window.py +++ b/window.py @@ -83,17 +83,16 @@ class Window(object): # mode stuff def set_mode(self, m): self.mode = m - modename = m.name() - if modename not in self.buffer.highlights and m.lexer is not None: - self.buffer.highlights[modename] = highlight.Highlighter(m.lexer) - self.buffer.highlights[modename].highlight(self.buffer.lines) + if m.name not in self.buffer.highlights and m.lexer is not None: + self.buffer.highlights[m.name] = highlight.Highlighter(m.lexer) + self.buffer.highlights[m.name].highlight(self.buffer.lines) #self.redraw() def get_highlighter(self): if self.mode.lexer is None: return None 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 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 # (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: + if self.mode.name in self.buffer.highlights: return self.render_line_lit(y, width) else: return self.render_line_raw(y, width) @@ -749,8 +747,7 @@ class Window(object): r = RenderString(s='~', attrs=color.build('red', 'default')) return [(r,)] - modename = self.mode.name() - highlighter = self.buffer.highlights[modename] + highlighter = self.buffer.highlights[self.mode.name] line = [] lines = []