some config/margin improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-11-12 05:00:40 +00:00
parent 9fe4fa8984
commit a22a9843fb
4 changed files with 22 additions and 8 deletions

View File

@ -188,6 +188,8 @@ class Application(object):
self.config['max_num_kills'] = 64
self.config['word_letters'] = string.letters + string.digits
self.config['default_color'] = ('default', 'default',)
self.config['margin'] = 80
self.config['margin_color'] = 'blue'
def completion_window_is_open(self):
n = self.complete_slot
@ -778,12 +780,14 @@ class Application(object):
count += 1
if w.margins_visible:
for (limit, shade) in w.margins:
shade = util.get_margin_color(w, 'blue')
limit = util.get_margin_limit(w, 80)
if limit < self.x:
for j in range(0, slot.height):
char = chr(self.win.inch(j + slot.y_offset, limit) & 255)
attr = color.build('default', shade, 'bold')
self.win.addstr(j + slot.y_offset, limit + w.mode.lmargin, char, attr)
self.win.addstr(j + slot.y_offset, limit + w.mode.lmargin,
char, attr)
def _draw_slot(self, i):
slot = self.bufferlist.slots[i]

View File

@ -77,7 +77,8 @@ class PythonGrammar(Grammar):
class PythonTabber(tab.StackTabber):
# NOTE: yield might initially seem like an endlevel name, but it's not one.
endlevel_names = ('pass', 'return', 'raise', 'break', 'continue')
# NOTE: return should be an endlevel name but for now it can't b
endlevel_names = ('pass', 'raise', 'break', 'continue')
startlevel_names = ('if', 'try', 'class', 'def', 'for', 'while', 'try')
def __init__(self, m):
tab.StackTabber.__init__(self, m)

View File

@ -47,3 +47,10 @@ def get_margin_limit(w, def_limit=80):
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()
if lname in w.application.config:
return w.application.config[lname]
else:
return w.application.config.get('margin_color', def_color)

View File

@ -17,7 +17,9 @@ from render import RenderString
# the shorter line will "set" the cursor to its position on the shorter line.
class Window(object):
margins = ((80, 'blue'),)
#margins = ((80, 'blue'),)
#margin_limit = 80
#margin_color = 'blue'
margins_visible = False
def __init__(self, b, a, height=24, width=80, mode_name=None):
self.buffer = b