From 8a77dafb42af0e708437dda21af4497e4cc84eda Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 1 Feb 2009 03:34:43 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- application.py | 1 - buffer/__init__.py | 3 +++ mode/__init__.py | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/application.py b/application.py index e8d67a8..2003dec 100755 --- a/application.py +++ b/application.py @@ -709,7 +709,6 @@ class Application(object): p = w.logical_cursor() blen = len(w.buffer.lines) - #count = 0 count = w.mode.header #XYZ (x, y) = w.first.xy() (vy, vx) = (None, None) diff --git a/buffer/__init__.py b/buffer/__init__.py index 6501077..727a1e0 100644 --- a/buffer/__init__.py +++ b/buffer/__init__.py @@ -67,6 +67,7 @@ class Buffer(object): self.nl = '\n' self.modified = False self.highlights = {} + self.settings = {} self.indentlvl = 4 self.writetabs = False @@ -161,6 +162,8 @@ class Buffer(object): 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) + if modename not in self.settings: + self.settings[modename] = {} def remove_window(self, w): if w in self.windows: diff --git a/mode/__init__.py b/mode/__init__.py index 5fa97c3..3fb59fa 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -100,11 +100,19 @@ class Fundamental(Handler): completers = {} format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s" - # margins - header = 0 - footer = 0 - lmargin = 0 - rmargin = 1 + ## margins + def get_header(self): return self.get_setting('header') + def set_header(self, value): return self.set_setting('header', value) + header = property(get_header, set_header) + def get_footer(self): return self.get_setting('footer') + def set_footer(self, value): return self.set_setting('footer', value) + footer = property(get_footer, set_footer) + def get_lmargin(self): return self.get_setting('lmargin') + def set_lmargin(self, value): return self.set_setting('lmargin', value) + lmargin = property(get_lmargin, set_lmargin) + def get_rmargin(self): return self.get_setting('rmargin') + def set_rmargin(self, value): return self.set_setting('rmargin', value) + rmargin = property(get_rmargin, set_rmargin) def install(cls, app): app.setmode(cls.modename.lower(), cls, paths=cls.paths, @@ -148,6 +156,12 @@ class Fundamental(Handler): self.window = w Handler.__init__(self) + #xyz + self.init_setting('lmargin', 0) + self.init_setting('rmargin', 1) + self.init_setting('header', 0) + self.init_setting('footer', 0) + # first let's add all the "default" actions self.add_bindings('start-of-line', ('C-a', 'HOME',)) self.add_bindings('end-of-line', ('C-e', 'END',)) @@ -258,6 +272,17 @@ class Fundamental(Handler): if self.tabbercls: self.tabber = self.tabbercls(self) + # buffer settings + def get_setting(self, name): + self.window.buffer.settings.setdefault(self.modename, {}) + return self.window.buffer.settings[self.modename].get(name) + def init_setting(self, name, value): + self.window.buffer.settings.setdefault(self.modename, {}) + self.window.buffer.settings[self.modename].setdefault(name, value) + def set_setting(self, name, value): + self.window.buffer.settings.setdefault(self.modename, {}) + self.window.buffer.settings[self.modename][name] = value + # header def showing_header(self): return self.header != 0