hex mode fixes

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-03-06 16:39:47 +00:00
parent fc1dc11edf
commit 318d35c436
4 changed files with 46 additions and 14 deletions

View File

@ -796,7 +796,10 @@ class Application(object):
rstrs = w.mode.get_header()
assert len(rstrs) >= w.mode.header
for j in range(0, w.mode.header):
rstrs[j].draw(self.win, slot.y_offset + j, slot.x_offset, slot.width)
k = 0
for rstr in rstrs[j]:
rstr.draw(self.win, slot.y_offset + j, slot.x_offset + k, slot.width)
k += len(rstr.string)
# draw the actual slot
self._draw_slot(i)

View File

@ -332,9 +332,9 @@ class Fundamental(Handler):
if self.tabber is None:
s = "Header support is not available for this mode"
hs = [RenderString(s=s, attrs=color.build(fg, bg))]
hs = [[RenderString(s=s, attrs=color.build(fg, bg))]]
while len(hs) < 3:
hs.insert(0, RenderString(s='', attrs=color.build(fg, bg)))
hs.insert(0, [RenderString(s='', attrs=color.build(fg, bg))])
return hs
w = self.window
@ -358,14 +358,14 @@ class Fundamental(Handler):
if ws and marker.level > ws:
continue
s = w.buffer.lines[marker.y][:w.width - 1]
hs.insert(0, RenderString(s=s, attrs=color.build(fg, bg)))
hs.insert(0, [RenderString(s=s, attrs=color.build(fg, bg))])
while len(hs) < 3:
hs.insert(0, RenderString(s='', attrs=color.build(fg, bg)))
hs.insert(0, [RenderString(s='', attrs=color.build(fg, bg))])
return hs
def get_footer(self):
fg, bg = "default", "red"
return [RenderString(s='footer', attrs=color.build(fg, bg))]
return [[RenderString(s='footer', attrs=color.build(fg, bg))]]
def get_rmargin(self, w, y, x, ended=False, cont=False):
c, fg, bg = " ", "red", "default"
if cont:

View File

@ -162,6 +162,14 @@ class HexToggleSymbolic(Method):
w.set_error("Symbolic editing enabled")
else:
w.set_error("Symbolic editing disabled")
class HexLiteral(Method):
def _execute(self, w, **vargs):
w.mode.symbolic_edit = False
w.set_error("Symbolic editing disabled")
class HexSymbolic(Method):
def _execute(self, w, **vargs):
w.mode.symbolic_edit = True
w.set_error("Symbolic editing enabled")
class ShowX86Instruction(Method):
''''''
@ -228,16 +236,37 @@ class Hex(mode.Fundamental):
ctrans = ''.join(_ctrans)
actions = [HexForward, HexBackward, HexForwardWord, HexBackwardWord,
HexStartOfLine, HexEndOfLine, ShowAddress, ShowX86Instruction,
GotoAddress, HexSetByteOrder, HexToggleSymbolic,
GotoAddress, HexSetByteOrder, HexToggleSymbolic, HexSymbolic, HexLiteral,
HexOverwriteCharSpace, HexOverwriteCharTab,
HexOverwriteCharNewline, HexGotoBeginning, HexGotoEnd]
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"
def get_status_names(self):
names = mode.Fundamental.get_status_names(self)
if self.symbolic_edit:
names['symbolic'] = 'symbolic'
else:
names['symbolic'] = 'literal'
return names
def get_header(self):
s = ' 87654321 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff' \
'%*s0123456789abcdef ' % (self.window.width - 48, '')
return [RenderString(s=s, attrs=color.build('red', 'default'))]
s0 = ' 87654321 '
s1 = '00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff'
s2 = ' ' * (self.window.width - 48)
s3 = '0123456789abcdef '
def lo(s): return RenderString(s=s, attrs=self.hlo)
def hi(s): return RenderString(s=s, attrs=self.hhi)
if self.symbolic_edit:
return [[lo(s0), lo(s1), lo(s2), hi(s3)]]
else:
return [[lo(s0), hi(s1), lo(s2), lo(s3)]]
def __init__(self, w):
mode.Fundamental.__init__(self, w)

View File

@ -584,9 +584,9 @@ class Python(mode.Fundamental):
if self.tabber is None:
s = "Header support is not available for this mode"
hs = [RenderString(s=s, attrs=color.build(fg, bg))]
hs = [[RenderString(s=s, attrs=color.build(fg, bg))]]
while len(hs) < 3:
hs.insert(0, RenderString(s='', attrs=color.build(fg, bg)))
hs.insert(0, [RenderString(s='', attrs=color.build(fg, bg))])
return hs
w = self.window
@ -610,9 +610,9 @@ class Python(mode.Fundamental):
if ws and marker.level > ws:
continue
s = w.buffer.lines[marker.y][:w.width - 1]
hs.insert(0, RenderString(s=s, attrs=color.build(fg, bg)))
hs.insert(0, [RenderString(s=s, attrs=color.build(fg, bg))])
while len(hs) < 3:
hs.insert(0, RenderString(s='', attrs=color.build(fg, bg)))
hs.insert(0, [RenderString(s='', attrs=color.build(fg, bg))])
return hs
def __init__(self, w):