QScintilla/Shell.py

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

eric ide

mercurial