From da994c526c0fd41e8ec57fb94f600dd97e63eaca Mon Sep 17 00:00:00 2001 From: moculus Date: Thu, 10 Apr 2008 13:46:10 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- application.py | 10 ++++++---- mode/__init__.py | 15 +++++---------- mode/hex.py | 24 +++++++++++++++++++++--- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/application.py b/application.py index bbb3109..bd41ed4 100755 --- a/application.py +++ b/application.py @@ -653,11 +653,13 @@ class Application(object): i = slot.y_offset + count if lm: - (lmargin, lattr) = w.mode.get_lmargin(y, x, ended, cont) - self.win.addstr(i, 0, lmargin, lattr) + groups = w.mode.get_lmargin(y, x, ended, cont) + for (x, lmargin, lattr) in groups: + self.win.addstr(i, x, lmargin, lattr) if rm: - (rmargin, rattr) = w.mode.get_rmargin(y, x, ended, cont) - self.win.addstr(i, slot.width - rm, rmargin, rattr) + groups = w.mode.get_rmargin(y, x, ended, cont) + for (x, rmargin, rattr) in groups: + self.win.addstr(i, slot.width - rm + x, rmargin, rattr) def _draw_slot_raw(self, i): slot = self.bufferlist.slots[i] diff --git a/mode/__init__.py b/mode/__init__.py index 5fe5875..957741a 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -223,14 +223,12 @@ class Fundamental(Handler): self.lmargin = 0 self.rmargin = 1 - def _null_margin(self, y, x, ended=False, cont=False): - return ('', color.build('default', 'default')) - def _continuation_margin(self, y, x, ended=False, cont=False): + def get_rmargin(self, y, x, ended=False, cont=False): if cont: - return ('\\', color.build('red', 'default')) + return ((0, '\\', color.build('red', 'default')),) else: - return (' ', color.build('red', 'default')) - def _line_number_margin(self, y, x=0, ended=False, cont=False): + return ((0, ' ', color.build('red', 'default')),) + def get_lmargin(self, y, x=0, ended=False, cont=False): lm = self.lmargin if ended: i = int(math.log(y, 10)) + 1 @@ -239,10 +237,7 @@ class Fundamental(Handler): s = ('% *d' % (lm - 1, y + 1))[-lm:] + ' ' else: s = ' ' * lm - return (s, color.build('default', 'default', 'bold')) - - get_lmargin = _line_number_margin - get_rmargin = _continuation_margin + return ((0, s, color.build('default', 'default', 'bold')),) # get mode name def name(self): diff --git a/mode/hex.py b/mode/hex.py index 2321aa9..0c96f53 100644 --- a/mode/hex.py +++ b/mode/hex.py @@ -42,13 +42,31 @@ class Hex(mode.Fundamental): s = ' -------- ' elif x == 0: s = '0x%08x ' % (y * 16) - return (s, color.build('cyan', 'default', 'bold')) + return ((0, s, color.build('cyan', 'default', 'bold')),) def get_rmargin(self, y, x=0, ended=False, cont=False): if ended: - s = '' + return ((0, '', 0),) else: + (cx, cy) = self.window.cursor.xy() s = string.translate(self.window.buffer.rawdata[y], self.ctrans) - return (s, color.build('green', 'default', 'bold')) + if cy == y: + i = None + if cx >= 0 and cx < 8: + i = cx // 2 + elif cx >= 9 and cx < 17: + i = (cx - 1) // 2 + elif cx >= 18 and cx < 26: + i = (cx - 2) // 2 + elif cx >= 27 and cx < 35: + i = (cx - 3) // 2 + if i is not None: + return ((0, s[0:i], color.build('green', 'default', 'bold')), + (0, s[i], color.build('green', 'default', 'bold', 'reverse')), + (0, s[i+1:], color.build('green', 'default', 'bold'))) + else: + return ((0, s, color.build('green', 'default', 'bold')),) + else: + return ((0, s, color.build('green', 'default', 'bold')),) class GotoWord(Method): '''Jump to the specified line number'''