726 |
726 |
727 def paste(self): |
727 def paste(self): |
728 """ |
728 """ |
729 Public slot to handle the paste action. |
729 Public slot to handle the paste action. |
730 """ |
730 """ |
731 lines = QApplication.clipboard().text() |
731 if self.__isCursorOnLastLine(): |
732 self.executeLines(lines) |
732 line, col = self.getCursorPosition() |
|
733 lastLine = self.text(line) |
|
734 |
|
735 # Remove if text is selected |
|
736 if self.hasSelectedText(): |
|
737 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
|
738 if self.text(lineFrom).startswith(sys.ps1): |
|
739 if indexFrom < len(sys.ps1): |
|
740 indexFrom = len(sys.ps1) |
|
741 elif self.text(lineFrom).startswith(sys.ps2): |
|
742 if indexFrom < len(sys.ps2): |
|
743 indexFrom = len(sys.ps2) |
|
744 lastLine = lastLine[:indexFrom] + lastLine[indexTo:] |
|
745 col = indexFrom |
|
746 |
|
747 self.setCursorPosition(line, 0) |
|
748 self.deleteLineRight() |
|
749 |
|
750 lines = QApplication.clipboard().text() |
|
751 lines = lastLine[:col] + lines + lastLine[col:] |
|
752 self.executeLines(lines) |
|
753 line, _ = self.getCursorPosition() |
|
754 pos = len(self.text(line)) - (len(lastLine) - col) |
|
755 self.setCursorPosition(line, pos) |
733 |
756 |
734 def __middleMouseButton(self): |
757 def __middleMouseButton(self): |
735 """ |
758 """ |
736 Private method to handle the middle mouse button press. |
759 Private method to handle the middle mouse button press. |
737 """ |
760 """ |
753 fullline = True |
776 fullline = True |
754 cmd = line[:-1] |
777 cmd = line[:-1] |
755 else: |
778 else: |
756 fullline = False |
779 fullline = False |
757 |
780 |
|
781 self.incrementalSearchActive = True |
758 self.__insertTextAtEnd(line) |
782 self.__insertTextAtEnd(line) |
759 if fullline: |
783 if fullline: |
|
784 self.incrementalSearchActive = False |
|
785 if cmd.startswith(sys.ps1): |
|
786 cmd = cmd[len(sys.ps1):] |
|
787 elif cmd.startswith(sys.ps2): |
|
788 cmd = cmd[len(sys.ps2):] |
|
789 |
760 self.__executeCommand(cmd) |
790 self.__executeCommand(cmd) |
761 if self.interruptCommandExecution: |
791 if self.interruptCommandExecution: |
762 self.__executeCommand("") |
792 self.__executeCommand("") |
763 break |
793 break |
764 |
794 |
793 @param s text to be inserted (string) |
823 @param s text to be inserted (string) |
794 """ |
824 """ |
795 line, col = self.__getEndPos() |
825 line, col = self.__getEndPos() |
796 self.setCursorPosition(line, col) |
826 self.setCursorPosition(line, col) |
797 self.insert(s) |
827 self.insert(s) |
798 self.prline, self.prcol = self.getCursorPosition() |
828 self.prline, _ = self.getCursorPosition() |
799 |
829 |
800 def __insertTextNoEcho(self, s): |
830 def __insertTextNoEcho(self, s): |
801 """ |
831 """ |
802 Private method to insert some text at the end of the buffer without |
832 Private method to insert some text at the end of the buffer without |
803 echoing it. |
833 echoing it. |