--- a/eric6/HexEdit/HexEditWidget.py Sat Sep 21 16:04:17 2019 +0200 +++ b/eric6/HexEdit/HexEditWidget.py Sat Sep 21 17:41:22 2019 +0200 @@ -9,10 +9,12 @@ import math -from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer, QRect, \ - QBuffer, QIODevice -from PyQt5.QtGui import QBrush, QPen, QColor, QFont, QPalette, QKeySequence, \ - QPainter +from PyQt5.QtCore import ( + pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer, QRect, QBuffer, QIODevice +) +from PyQt5.QtGui import ( + QBrush, QPen, QColor, QFont, QPalette, QKeySequence, QPainter +) from PyQt5.QtWidgets import QAbstractScrollArea, QApplication from .HexEditChunks import HexEditChunks @@ -727,11 +729,15 @@ if (point.x() >= self.__pxPosHexX) and ( point.x() < (self.__pxPosHexX + (1 + self.HEXCHARS_PER_LINE) * self.__pxCharWidth)): - x = (point.x() - self.__pxPosHexX - self.__pxCharWidth // 2) // \ + x = ( + (point.x() - self.__pxPosHexX - self.__pxCharWidth // 2) // self.__pxCharWidth + ) x = (x // 3) * 2 + x % 3 - y = ((point.y() - 3) // self.__pxCharHeight) * 2 * \ + y = ( + ((point.y() - 3) // self.__pxCharHeight) * 2 * self.BYTES_PER_LINE + ) result = self.__bPosFirst * 2 + x + y return result @@ -997,9 +1003,11 @@ """ Public method to extend the selection to the end of line. """ - pos = self.__cursorPosition - \ - (self.__cursorPosition % (2 * self.BYTES_PER_LINE)) + \ + pos = ( + self.__cursorPosition - + (self.__cursorPosition % (2 * self.BYTES_PER_LINE)) + 2 * self.BYTES_PER_LINE + ) self.setCursorPosition(pos) self.__setSelection(pos) @@ -1007,8 +1015,10 @@ """ Public method to extend the selection to the start of line. """ - pos = self.__cursorPosition - \ + pos = ( + self.__cursorPosition - (self.__cursorPosition % (2 * self.BYTES_PER_LINE)) + ) self.setCursorPosition(pos) self.__setSelection(pos) @@ -1032,9 +1042,11 @@ """ Public method to extend the selection one page down. """ - pos = self.__cursorPosition + \ - ((self.viewport().height() // self.__pxCharHeight) - 1) * \ + pos = ( + self.__cursorPosition + + ((self.viewport().height() // self.__pxCharHeight) - 1) * 2 * self.BYTES_PER_LINE + ) self.setCursorPosition(pos) self.__setSelection(pos) @@ -1042,9 +1054,11 @@ """ Public method to extend the selection one page up. """ - pos = self.__cursorPosition - \ - ((self.viewport().height() // self.__pxCharHeight) - 1) * \ + pos = ( + self.__cursorPosition - + ((self.viewport().height() // self.__pxCharHeight) - 1) * 2 * self.BYTES_PER_LINE + ) self.setCursorPosition(pos) self.__setSelection(pos) @@ -1226,8 +1240,10 @@ # Edit commands elif evt.matches(QKeySequence.Copy): self.copy() - elif evt.key() == Qt.Key_Insert and \ - evt.modifiers() == Qt.NoModifier: + elif ( + evt.key() == Qt.Key_Insert and + evt.modifiers() == Qt.NoModifier + ): self.setOverwriteMode(not self.overwriteMode()) self.setCursorPosition(self.__cursorPosition) @@ -1238,8 +1254,10 @@ self.paste() elif evt.matches(QKeySequence.Delete): self.deleteByte() - elif evt.key() == Qt.Key_Backspace and \ - evt.modifiers() == Qt.NoModifier: + elif ( + evt.key() == Qt.Key_Backspace and + evt.modifiers() == Qt.NoModifier + ): self.deleteByteBack() elif evt.matches(QKeySequence.Undo): self.undo() @@ -1333,8 +1351,10 @@ """ painter = QPainter(self.viewport()) - if evt.rect() != self.__cursorRect and \ - evt.rect() != self.__cursorRectAscii: + if ( + evt.rect() != self.__cursorRect and + evt.rect() != self.__cursorRectAscii + ): pxOfsX = self.horizontalScrollBar().value() pxPosStartY = self.__pxCharHeight @@ -1387,14 +1407,18 @@ bPosLine = row * self.BYTES_PER_LINE colIdx = 0 - while bPosLine + colIdx < len(self.__dataShown) and \ - colIdx < self.BYTES_PER_LINE: + while ( + bPosLine + colIdx < len(self.__dataShown) and + colIdx < self.BYTES_PER_LINE + ): c = self.viewport().palette().color(QPalette.Base) painter.setPen(colStandard) posBa = self.__bPosFirst + bPosLine + colIdx - if self.getSelectionBegin() <= posBa and \ - self.getSelectionEnd() > posBa: + if ( + self.getSelectionBegin() <= posBa and + self.getSelectionEnd() > posBa + ): c = self.__selectionBrush.color() painter.setPen(self.__selectionPen) elif self.__highlighting: @@ -1420,9 +1444,10 @@ 3 * self.__pxCharWidth, self.__pxCharHeight) painter.fillRect(r, c) - hexStr = \ - chr(self.__hexDataShown[(bPosLine + colIdx) * 2]) + \ + hexStr = ( + chr(self.__hexDataShown[(bPosLine + colIdx) * 2]) + chr(self.__hexDataShown[(bPosLine + colIdx) * 2 + 1]) + ) painter.drawText(pxPosX, pxPosY, hexStr) pxPosX += 3 * self.__pxCharWidth @@ -1650,8 +1675,11 @@ else: self.__pxPosHexX = self.__pxGapAdrHex self.__pxPosAdrX = self.__pxGapAdr - self.__pxPosAsciiX = self.__pxPosHexX + \ - self.HEXCHARS_PER_LINE * self.__pxCharWidth + self.__pxGapHexAscii + self.__pxPosAsciiX = ( + self.__pxPosHexX + + self.HEXCHARS_PER_LINE * self.__pxCharWidth + + self.__pxGapHexAscii + ) # set horizontal scrollbar pxWidth = self.__pxPosAsciiX @@ -1662,8 +1690,9 @@ self.horizontalScrollBar().setPageStep(self.viewport().width()) # set vertical scrollbar - self.__rowsShown = \ + self.__rowsShown = ( (self.viewport().height() - 4) // self.__pxCharHeight + ) lineCount = (self.__chunks.size() // self.BYTES_PER_LINE) + 1 self.verticalScrollBar().setRange(0, lineCount - self.__rowsShown) self.verticalScrollBar().setPageStep(self.__rowsShown) @@ -1671,8 +1700,9 @@ # do the rest value = self.verticalScrollBar().value() self.__bPosFirst = value * self.BYTES_PER_LINE - self.__bPosLast = \ + self.__bPosLast = ( self.__bPosFirst + self.__rowsShown * self.BYTES_PER_LINE - 1 + ) if self.__bPosLast >= self.__chunks.size(): self.__bPosLast = self.__chunks.size() - 1 self.__readBuffers()