diff --git a/buffer.py b/buffer.py index 6718f95..32f6fe5 100644 --- a/buffer.py +++ b/buffer.py @@ -523,15 +523,19 @@ class Binary32Buffer(FileBuffer): def __init__(self, path, nl='\n', name=None): '''fb = FileBuffer(path)''' FileBuffer.__init__(self, path, nl, name) - def cursorx_to_datax(self, cx): + def cursorx_to_datax(self, cy, cx): if cx >= 0 and cx < 8: - return cx // 2 + ix = cx // 2 elif cx >= 9 and cx < 17: - return (cx - 1) // 2 + ix = (cx - 1) // 2 elif cx >= 18 and cx < 26: - return (cx - 2) // 2 + ix = (cx - 2) // 2 elif cx >= 27 and cx < 35: - return (cx - 3) // 2 + ix = (cx - 3) // 2 + else: + return None + if ix < len(self.rawdata[cy]): + return ix else: return None def datax_to_cursorx(self, ix): @@ -546,7 +550,7 @@ class Binary32Buffer(FileBuffer): else: return None def overwrite_char(self, p, c, act=ACT_NORM, force=False): - ix = self.cursorx_to_datax(p.x) + ix = self.cursorx_to_datax(p.y, p.x) if ix is None: return Buffer.overwrite_char(self, p, c, act, force) diff --git a/mode/hex.py b/mode/hex.py index bdd1e1e..e86c25b 100644 --- a/mode/hex.py +++ b/mode/hex.py @@ -50,7 +50,8 @@ class Hex(mode.Fundamental): (cx, cy) = self.window.cursor.xy() s = string.translate(self.window.buffer.rawdata[y], self.ctrans) if cy == y: - i = self.window.buffer.cursorx_to_datax(cx) + i = self.window.buffer.cursorx_to_datax(cy, cx) + if i is None: return ((0, s, color.build('green', 'default', 'bold')),) elif i < len(s) - 1: