diff --git a/mode/__init__.py b/mode/__init__.py index 458ac25..0ab1551 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -466,6 +466,7 @@ class Fundamental(Handler): def region_added(self, p, newlines): mname = self.name + if self.lexer is not None: ydelta = len(newlines) - 1 xdelta = len(newlines[-1]) @@ -487,12 +488,11 @@ class Fundamental(Handler): ghist.setdefault(name, {}) ghist[name][newp] = self.ghist[name][gp] self.ghist = ghist + if self.tabber is not None: self.tabber.region_added(p, newlines) if self.context is not None: self.context.region_added(p, newlines) - if self.lmargin != 0: - self.enable_line_numbers() def region_removed(self, p1, p2): if self.lexer is not None: @@ -522,7 +522,5 @@ class Fundamental(Handler): self.tabber.region_removed(p1, p2) if self.context is not None: self.context.region_removed(p1, p2) - if self.lmargin != 0: - self.enable_line_numbers() install = Fundamental.install diff --git a/mode/hex.py b/mode/hex.py index d2223df..c9e8255 100644 --- a/mode/hex.py +++ b/mode/hex.py @@ -122,10 +122,17 @@ class HexOverwriteChar(Method): hb = w.application.methods['hex-backward'] (cx, cy) = w.cursor.xy() ix = b.cursorx_to_datax(cy, cx) + if ix is None: + return + lm1 = w.mode.lmargin cx2 = w.buffer.datax_to_cursorx(ix) w.goto(Point(cx2, cy)) + lm2 = w.mode.lmargin w.overwrite_char_at_cursor(self.part1) + lm3 = w.mode.lmargin w.overwrite_char_at_cursor(self.part2) + lm4 = w.mode.lmargin + w.set_error('%r/%r/%r/%r' % (lm1, lm2, lm3, lm4)) elif self.char not in string.hexdigits: return else: @@ -219,8 +226,8 @@ class Hex(mode.Fundamental): config = { 'hex.disinst': 'disinst', } - lmargin = 12 - rmargin = 18 + #lmargin = 12 + #rmargin = 18 _ctrans = ['.'] * 256 byteorder = 'native' byteorders = { @@ -240,8 +247,8 @@ class Hex(mode.Fundamental): HexOverwriteCharSpace, HexOverwriteCharTab, HexOverwriteCharNewline, HexGotoBeginning, HexGotoEnd] - header = 1 - header_size = 1 + #header = 1 + #header_size = 1 hlo = color.build('red', 'default') hhi = color.build('default', 'red') format = "%(flag)s %(bname)-18s (%(mname)s) {%(symbolic)s} %(cursor)s %(perc)s" @@ -272,6 +279,11 @@ class Hex(mode.Fundamental): mode.Fundamental.__init__(self, w) self.bindings = {} + self.lmargin = 12 + self.rmargin = 18 + self.header = 1 + self.footer = 0 + self.add_bindings('center-view', ('C-l',)) self.add_bindings('next-line', ('C-n', 'D_ARROW',)) self.add_bindings('previous-line', ('C-p', 'U_ARROW',)) diff --git a/render.py b/render.py index a5f992e..4fb1d21 100644 --- a/render.py +++ b/render.py @@ -35,7 +35,8 @@ class RenderString(object): s = '%-*s' % (x2 - x, self.string) else: s = self.string + assert self.x + x != 115 cwin.addstr(self.y + y, self.x + x, s, self.attrs) except: - v = (y, self.x, x, self.string, self.attrs) - raise Exception, "cwin.addstr(%d, %d + %d, %r, %r) failed" % v + v = (self.y, y, self.x, x, self.string, self.attrs) + raise Exception, "cwin.addstr(%d + %d, %d + %d, %r, %r) failed" % v