示例#1
0
 def as_hex(self):
     """Format the clipboard contents as a hexdump"""
     data = ''.join([chr(c) for c in self.abData])
     return "".join([
         "{0:#x}  {1:<48}  {2}\n".format(self.abData.obj_offset + o, h,
                                         ''.join(c))
         for o, h, c in utils.Hexdump(data)
     ])
示例#2
0
    def render_row(self, item, hex_width=None, **options):
        if hex_width is None:
            hex_width = (item.options.get("hex_width") or
                         self.session.GetParameter("hexdump_width", 8))

        data = item.value
        highlights = item.highlights or []
        hex_highlights = []
        for x, y, f, b in highlights:
            hex_highlights.append((3 * x, 3 * y, f, b))

        hexcell = text.Cell(
            width=hex_width * 3, highlights=hex_highlights,
            colorizer=self.renderer.colorizer)
        datacell = text.Cell(
            width=hex_width, highlights=highlights,
            colorizer=self.renderer.colorizer)

        for _, hexdata, translated_data in utils.Hexdump(data, width=hex_width):
            hexcell.append_line(hexdata)
            datacell.append_line("".join(translated_data))

        return text.JoinedCell(hexcell, datacell)