--- a/eric6/QScintilla/Shell.py Sat Jan 16 16:51:23 2021 +0100 +++ b/eric6/QScintilla/Shell.py Sun Jan 17 12:40:19 2021 +0100 @@ -1075,9 +1075,12 @@ # move cursor to end of line self.moveCursorToEOL() - def paste(self): + def paste(self, lines=None): """ Public slot to handle the paste action. + + @param lines list of lines to be inserted + @type list of str """ if self.__isCursorOnLastLine(): line, col = self.getCursorPosition() @@ -1113,20 +1116,15 @@ self.setCursorPosition(line, len(prompt)) self.deleteLineRight() - lines = QApplication.clipboard().text() + if lines is None: + lines = QApplication.clipboard().text() + lines = lastLine[:col] + lines + lastLine[col:] self.executeLines(lines) line, _ = self.getCursorPosition() pos = len(self.text(line)) - (len(lastLine) - col) self.setCursorPosition(line, pos) - - def __middleMouseButton(self): - """ - Private method to handle the middle mouse button press. - """ - lines = QApplication.clipboard().text(QClipboard.Selection) - self.executeLines(lines) - + def executeLines(self, lines, historyIndex=None): """ Public method to execute a set of lines as multiple commands. @@ -1150,12 +1148,9 @@ else: line = line[indentLen:] - if line.endswith("\r\n"): + if line.endswith(("\r\n", "\r", "\n")): fullline = True - cmd = line[:-2] - elif line.endswith("\r") or line.endswith("\n"): - fullline = True - cmd = line[:-1] + cmd = line.rstrip() else: fullline = False @@ -1237,7 +1232,8 @@ """ self.setFocus() if event.button() == Qt.MidButton: - self.__middleMouseButton() + lines = QApplication.clipboard().text(QClipboard.Selection) + self.paste(lines) else: super(Shell, self).mousePressEvent(event)