HexEdit/HexEditWidget.py

changeset 5587
ea526b78ee6c
parent 5389
9b1c800daff3
child 5624
cdd346d8858b
equal deleted inserted replaced
5586:0e5421d679e7 5587:ea526b78ee6c
7 Module implementing an editor for binary data. 7 Module implementing an editor for binary data.
8 """ 8 """
9 9
10 from __future__ import unicode_literals, division 10 from __future__ import unicode_literals, division
11 try: 11 try:
12 chr = unichr # __IGNORE_EXCEPTION__ 12 chr = unichr # __IGNORE_EXCEPTION__ __IGNORE_WARNING_M131__
13 except NameError: 13 except NameError:
14 pass 14 pass
15 15
16 import math 16 import math
17 17
704 @type bytearray or QByteArray 704 @type bytearray or QByteArray
705 """ 705 """
706 self.__undoStack.insertByteArray(pos, bytearray(byteArray)) 706 self.__undoStack.insertByteArray(pos, bytearray(byteArray))
707 self.__refresh() 707 self.__refresh()
708 708
709 def replaceByteArray(self, pos, len, byteArray): 709 def replaceByteArray(self, pos, length, byteArray):
710 """ 710 """
711 Public method to replace bytes. 711 Public method to replace bytes.
712 712
713 @param pos position to replace the bytes at 713 @param pos position to replace the bytes at
714 @type int 714 @type int
715 @param len amount of bytes to replace 715 @param length amount of bytes to replace
716 @type int 716 @type int
717 @param byteArray bytes to replace with 717 @param byteArray bytes to replace with
718 @type bytearray or QByteArray 718 @type bytearray or QByteArray
719 """ 719 """
720 self.__undoStack.overwriteByteArray(pos, len, bytearray(byteArray)) 720 self.__undoStack.overwriteByteArray(pos, length, bytearray(byteArray))
721 self.__refresh() 721 self.__refresh()
722 722
723 def cursorPositionFromPoint(self, point): 723 def cursorPositionFromPoint(self, point):
724 """ 724 """
725 Public method to calculate a cursor position from a graphics position. 725 Public method to calculate a cursor position from a graphics position.
1424 pxPosY - self.__pxCharHeight + 1424 pxPosY - self.__pxCharHeight +
1425 self.__pxSelectionSub, 1425 self.__pxSelectionSub,
1426 3 * self.__pxCharWidth, 1426 3 * self.__pxCharWidth,
1427 self.__pxCharHeight) 1427 self.__pxCharHeight)
1428 painter.fillRect(r, c) 1428 painter.fillRect(r, c)
1429 hex = chr(self.__hexDataShown[(bPosLine + colIdx) * 2]) + \ 1429 hexStr = \
1430 chr(self.__hexDataShown[(bPosLine + colIdx) * 2]) + \
1430 chr(self.__hexDataShown[(bPosLine + colIdx) * 2 + 1]) 1431 chr(self.__hexDataShown[(bPosLine + colIdx) * 2 + 1])
1431 painter.drawText(pxPosX, pxPosY, hex) 1432 painter.drawText(pxPosX, pxPosY, hexStr)
1432 pxPosX += 3 * self.__pxCharWidth 1433 pxPosX += 3 * self.__pxCharWidth
1433 1434
1434 # render ascii value 1435 # render ascii value
1435 if self.__asciiArea: 1436 if self.__asciiArea:
1436 by = self.__dataShown[bPosLine + colIdx] 1437 by = self.__dataShown[bPosLine + colIdx]

eric ide

mercurial