parent
cc050512c8
commit
b2a8497c7b
29
buffer.py
29
buffer.py
|
@ -523,10 +523,37 @@ class Binary32Buffer(FileBuffer):
|
||||||
def __init__(self, path, nl='\n', name=None):
|
def __init__(self, path, nl='\n', name=None):
|
||||||
'''fb = FileBuffer(path)'''
|
'''fb = FileBuffer(path)'''
|
||||||
FileBuffer.__init__(self, path, nl, name)
|
FileBuffer.__init__(self, path, nl, name)
|
||||||
|
def cursorx_to_datax(self, cx):
|
||||||
|
if cx >= 0 and cx < 8:
|
||||||
|
return cx // 2
|
||||||
|
elif cx >= 9 and cx < 17:
|
||||||
|
return (cx - 1) // 2
|
||||||
|
elif cx >= 18 and cx < 26:
|
||||||
|
return (cx - 2) // 2
|
||||||
|
elif cx >= 27 and cx < 35:
|
||||||
|
return (cx - 3) // 2
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
def datax_to_cursorx(self, ix):
|
||||||
|
if ix >= 0 and ix < 4:
|
||||||
|
return ix * 2
|
||||||
|
elif ix >= 4 and ix < 8:
|
||||||
|
return ix * 2 + 1
|
||||||
|
elif ix >= 8 and ix < 12:
|
||||||
|
return ix * 2 + 2
|
||||||
|
elif ix >= 12 and ix < 16:
|
||||||
|
return ix * 2 + 3
|
||||||
|
else:
|
||||||
|
return None
|
||||||
def overwrite_char(self, p, c, act=ACT_NORM, force=False):
|
def overwrite_char(self, p, c, act=ACT_NORM, force=False):
|
||||||
|
ix = self.cursorx_to_datax(p.x)
|
||||||
|
if ix is None:
|
||||||
|
return
|
||||||
Buffer.overwrite_char(self, p, c, act, force)
|
Buffer.overwrite_char(self, p, c, act, force)
|
||||||
|
cx = self.datax_to_cursorx(ix)
|
||||||
|
c = chr(int(self.lines[p.y][cx:cx + 2], 16))
|
||||||
rawline = self.rawdata[p.y]
|
rawline = self.rawdata[p.y]
|
||||||
self.rawdata[p.y] = rawline[0:p.x] + c + rawline[p.x + 1:]
|
self.rawdata[p.y] = rawline[0:ix] + c + rawline[ix + 1:]
|
||||||
def read_filter(self, data):
|
def read_filter(self, data):
|
||||||
self.rawdata = []
|
self.rawdata = []
|
||||||
lines = []
|
lines = []
|
||||||
|
|
20
mode/hex.py
20
mode/hex.py
|
@ -50,21 +50,13 @@ class Hex(mode.Fundamental):
|
||||||
(cx, cy) = self.window.cursor.xy()
|
(cx, cy) = self.window.cursor.xy()
|
||||||
s = string.translate(self.window.buffer.rawdata[y], self.ctrans)
|
s = string.translate(self.window.buffer.rawdata[y], self.ctrans)
|
||||||
if cy == y:
|
if cy == y:
|
||||||
i = None
|
i = self.window.buffer.cursorx_to_datax(cx)
|
||||||
if cx >= 0 and cx < 8:
|
if i is None:
|
||||||
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')),)
|
return ((0, s, color.build('green', 'default', 'bold')),)
|
||||||
|
else:
|
||||||
|
return ((0, s[0:i], color.build('green', 'default', 'bold')),
|
||||||
|
(i, s[i], color.build('default', 'default', 'bold', 'reverse')),
|
||||||
|
(i + 1, s[i+1:], color.build('green', 'default', 'bold')))
|
||||||
else:
|
else:
|
||||||
return ((0, s, color.build('green', 'default', 'bold')),)
|
return ((0, s, color.build('green', 'default', 'bold')),)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue