bug fixes and new margins

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-04-07 19:27:35 +00:00
parent 560bf76984
commit 08d9a815e4
3 changed files with 14 additions and 15 deletions

View File

@ -142,7 +142,8 @@ class Application(object):
# window/slot height/width # window/slot height/width
height = self.y - 2 height = self.y - 2
width = self.x - 1 #width = self.x - 1
width = self.x
# run user custom code here # run user custom code here
self.rcerror = None self.rcerror = None
@ -558,7 +559,7 @@ class Application(object):
(x, y) = w.first.xy() (x, y) = w.first.xy()
(vy, vx) = (None, None) (vy, vx) = (None, None)
while count < slot.height: while count < slot.height:
if p.y == y and p.x >= x and p.x <= x + swidth: if p.y == y and p.x >= x and p.x < x + swidth:
(vy, vx) = (slot.y_offset + count, p.x - x + w.mode.lmargin) (vy, vx) = (slot.y_offset + count, p.x - x + w.mode.lmargin)
break break
if x + swidth >= len(w.buffer.lines[y]): if x + swidth >= len(w.buffer.lines[y]):
@ -689,7 +690,6 @@ class Application(object):
x = 0 x = 0
y += 1 y += 1
else: else:
self.win.addstr(slot.y_offset + count, slot.width, '\\', redattr)
x += swidth x += swidth
# move on to the next physical line # move on to the next physical line
@ -738,7 +738,6 @@ class Application(object):
if token_wrap: if token_wrap:
self._draw_line_margins(slot, count, w, y, x) self._draw_line_margins(slot, count, w, y, x)
self.win.addstr(k, slot.width, '\\', redattr)
x += swidth x += swidth
count += 1 count += 1
if token_done: if token_done:

View File

@ -3165,4 +3165,3 @@ sub __add_misc_data
} }
1; 1;

View File

@ -215,12 +215,13 @@ class Fundamental(Handler):
def enable_line_numbers(self): def enable_line_numbers(self):
self.show_line_numbers = True self.show_line_numbers = True
self.lmargin = 4 l = len(self.window.buffer.lines)
self.get_lmargin = self._line_number_margin self.lmargin = int(math.log(l, 10)) + 3
self.rmargin = 0
def disable_line_numbers(self): def disable_line_numbers(self):
self.show_line_numbers = False self.show_line_numbers = False
self.lmargin = 0 self.lmargin = 0
self.get_lmargin = self._null_margin self.rmargin = 1
def get_rmargin(self, y, x, ended=False, cont=False): def get_rmargin(self, y, x, ended=False, cont=False):
return ('', color.build('default', 'default')) return ('', color.build('default', 'default'))
@ -228,20 +229,20 @@ class Fundamental(Handler):
return ('', color.build('default', 'default')) return ('', color.build('default', 'default'))
def _continuation_margin(self, y, x, ended=False, cont=False): def _continuation_margin(self, y, x, ended=False, cont=False):
if cont: if cont:
return ('\\', color.build('green', 'default')) return ('\\', color.build('red', 'default'))
else: else:
return ('x', color.build('green', 'default')) return (' ', color.build('red', 'default'))
def _line_number_margin(self, y, x=0, ended=False, cont=False): def _line_number_margin(self, y, x=0, ended=False, cont=False):
lm = self.lmargin
if ended: if ended:
i = int(math.log(y, 10)) + 1 i = int(math.log(y, 10)) + 1
s = ('% 3s' % ('-' * i))[-3:] + ' ' s = ('% *s' % (lm - 1, '-' * i))[-lm:] + ' '
elif x == 0: elif x == 0:
s = ('% 3d' % (y + 1))[-3:] + ' ' s = ('% *d' % (lm - 1, y + 1))[-lm:] + ' '
else: else:
s = ' ' s = ' ' * lm
return (s, color.build('default', 'default', 'bold')) return (s, color.build('default', 'default', 'bold'))
get_lmargin = _null_margin get_lmargin = _line_number_margin
#get_rmargin = _null_margin
get_rmargin = _continuation_margin get_rmargin = _continuation_margin
# get mode name # get mode name