9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import sys |
12 import sys |
13 is_Py2 = sys.version_info[0] == 2 |
13 is_Py2 = sys.version_info[0] == 2 |
|
14 # TODO: use unichr for Python2 |
14 |
15 |
15 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer, QRect, \ |
16 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer, QRect, \ |
16 QBuffer, QIODevice |
17 QBuffer, QIODevice |
17 from PyQt5.QtGui import QBrush, QPen, QColor, QFont, QPalette, QKeySequence, \ |
18 from PyQt5.QtGui import QBrush, QPen, QColor, QFont, QPalette, QKeySequence, \ |
18 QPainter |
19 QPainter |
379 self.__blink = True |
380 self.__blink = True |
380 self.viewport().update(self.__cursorRect) |
381 self.viewport().update(self.__cursorRect) |
381 if self.__asciiArea: |
382 if self.__asciiArea: |
382 self.viewport().update(self.__cursorRectAscii) |
383 self.viewport().update(self.__cursorRectAscii) |
383 self.currentAddressChanged.emit(self.__bPosCurrent) |
384 self.currentAddressChanged.emit(self.__bPosCurrent) |
|
385 |
|
386 def cursorBytePosition(self): |
|
387 """ |
|
388 Public method to get the cursor position in bytes. |
|
389 |
|
390 @return cursor position in bytes |
|
391 @rtype int |
|
392 """ |
|
393 return self.__bPosCurrent |
|
394 |
|
395 def setCursorBytePosition(self, pos): |
|
396 """ |
|
397 Public method to set the cursor position in bytes. |
|
398 |
|
399 @param pos cursor position in bytes |
|
400 @type int |
|
401 """ |
|
402 self.setCursorPosition(pos * 2) |
|
403 |
|
404 def goto(self, offset, fromCursor=False, backwards=False, |
|
405 extendSelection=False): |
|
406 """ |
|
407 Public method to move the cursor. |
|
408 |
|
409 @param offset offset to move to |
|
410 @type int |
|
411 @param fromCursor flag indicating a move relative to the current cursor |
|
412 @type bool |
|
413 @param backwards flag indicating a backwards move |
|
414 @type bool |
|
415 @param extendSelection flag indicating to extend the selection |
|
416 @type bool |
|
417 """ |
|
418 if fromCursor: |
|
419 if backwards: |
|
420 newPos = self.cursorBytePosition() - offset |
|
421 else: |
|
422 newPos = self.cursorBytePosition() + offset |
|
423 else: |
|
424 if backwards: |
|
425 newPos = self.__chunks.size() - offset |
|
426 else: |
|
427 newPos = offset |
|
428 |
|
429 self.setCursorBytePosition(newPos) |
|
430 if extendSelection: |
|
431 self.__setSelection(self.__cursorPosition) |
|
432 else: |
|
433 self.__resetSelection(self.__cursorPosition) |
|
434 |
|
435 self.__refresh() |
384 |
436 |
385 def data(self): |
437 def data(self): |
386 """ |
438 """ |
387 Public method to get the binary data. |
439 Public method to get the binary data. |
388 |
440 |
1449 painter.setBackgroundMode(Qt.TransparentMode) |
1501 painter.setBackgroundMode(Qt.TransparentMode) |
1450 painter.setPen( |
1502 painter.setPen( |
1451 self.viewport().palette().color(QPalette.WindowText)) |
1503 self.viewport().palette().color(QPalette.WindowText)) |
1452 |
1504 |
1453 # paint cursor |
1505 # paint cursor |
1454 if self.__blink and not self.__readOnly and self.hasFocus(): |
1506 if self.__blink and not self.__readOnly and self.isActiveWindow(): |
1455 painter.fillRect( |
1507 painter.fillRect( |
1456 self.__cursorRect, self.palette().color(QPalette.WindowText)) |
1508 self.__cursorRect, self.palette().color(QPalette.WindowText)) |
1457 else: |
1509 else: |
1458 if self.__hexDataShown: |
1510 if self.__hexDataShown: |
1459 try: |
1511 try: |