1131 buf = buf.replace(sys.ps2, "") |
1131 buf = buf.replace(sys.ps2, "") |
1132 self.prompt = buf |
1132 self.prompt = buf |
1133 # move cursor to end of line |
1133 # move cursor to end of line |
1134 self.moveCursorToEOL() |
1134 self.moveCursorToEOL() |
1135 |
1135 |
|
1136 @pyqtSlot() |
1136 def paste(self, lines=None): |
1137 def paste(self, lines=None): |
1137 """ |
1138 """ |
1138 Public slot to handle the paste action. |
1139 Public slot to handle the paste action. |
1139 |
1140 |
1140 @param lines list of lines to be inserted |
1141 @param lines list of lines to be inserted |
1555 if txt: |
1556 if txt: |
1556 line, col = self.__getEndPos() |
1557 line, col = self.__getEndPos() |
1557 self.setCursorPosition(line, col) |
1558 self.setCursorPosition(line, col) |
1558 self.insert(txt) |
1559 self.insert(txt) |
1559 |
1560 |
1560 def __QScintillaLeftCommand(self, method, allLinesAllowed=False): |
1561 def __QScintillaLeftCommand(self, method): |
1561 """ |
1562 """ |
1562 Private method to handle a QScintilla command working to the left. |
1563 Private method to handle a QScintilla command working to the left. |
1563 |
1564 |
1564 @param method shell method to execute |
1565 @param method shell method to execute |
1565 @type int |
1566 @type int |
1566 @param allLinesAllowed flag indicating that the command may be executed |
1567 """ |
1567 on any line |
1568 line, col = self.getCursorPosition() |
1568 @type bool |
1569 if col > 0: |
1569 """ |
|
1570 if self.__isCursorOnLastLine() or allLinesAllowed: |
|
1571 line, col = self.getCursorPosition() |
|
1572 if self.text(line).startswith(sys.ps1): |
|
1573 if col > len(sys.ps1): |
|
1574 method() |
|
1575 elif self.text(line).startswith(sys.ps2): |
|
1576 if col > len(sys.ps2): |
|
1577 method() |
|
1578 elif col > 0: |
|
1579 method() |
|
1580 else: |
|
1581 method() |
1570 method() |
|
1571 |
|
1572 # adjust cursor position |
|
1573 line, col = self.getCursorPosition() |
|
1574 if self.text(line).startswith(sys.ps1) and col < len(sys.ps1): |
|
1575 self.setCursorPosition(line, len(sys.ps1)) |
|
1576 elif self.text(line).startswith(sys.ps2) and col < len(sys.ps2): |
|
1577 self.setCursorPosition(line, len(sys.ps2)) |
1582 |
1578 |
1583 def __QScintillaCharLeft(self): |
1579 def __QScintillaCharLeft(self): |
1584 """ |
1580 """ |
1585 Private method to handle the Cursor Left command. |
1581 Private method to handle the Cursor Left command. |
1586 """ |
1582 """ |
1597 Private method to handle a QScintilla command working to the right. |
1593 Private method to handle a QScintilla command working to the right. |
1598 |
1594 |
1599 @param method shell method to execute |
1595 @param method shell method to execute |
1600 @type function |
1596 @type function |
1601 """ |
1597 """ |
1602 # TODO: check this! |
1598 method() |
|
1599 |
|
1600 # adjust cursor position |
|
1601 line, col = self.getCursorPosition() |
|
1602 if self.text(line).startswith(sys.ps1) and col < len(sys.ps1): |
|
1603 self.setCursorPosition(line, len(sys.ps1)) |
|
1604 elif self.text(line).startswith(sys.ps2) and col < len(sys.ps2): |
|
1605 self.setCursorPosition(line, len(sys.ps2)) |
|
1606 |
|
1607 def __QScintillaCharRight(self): |
|
1608 """ |
|
1609 Private method to handle the Cursor Right command. |
|
1610 """ |
|
1611 self.__QScintillaRightCommand(self.moveCursorRight) |
|
1612 |
|
1613 def __QScintillaWordRight(self): |
|
1614 """ |
|
1615 Private method to handle the Cursor Word Right command. |
|
1616 """ |
|
1617 self.__QScintillaRightCommand(self.moveCursorWordRight) |
|
1618 |
|
1619 def __QScintillaDeleteWordRight(self): |
|
1620 """ |
|
1621 Private method to handle the Delete Word Right command. |
|
1622 """ |
|
1623 # delete is only allowed on the last line |
1603 if self.__isCursorOnLastLine(): |
1624 if self.__isCursorOnLastLine(): |
1604 method() |
1625 self.__QScintillaRightCommand(self.deleteWordRight) |
1605 else: |
|
1606 method() |
|
1607 |
|
1608 def __QScintillaCharRight(self): |
|
1609 """ |
|
1610 Private method to handle the Cursor Right command. |
|
1611 """ |
|
1612 self.__QScintillaRightCommand(self.moveCursorRight) |
|
1613 |
|
1614 def __QScintillaWordRight(self): |
|
1615 """ |
|
1616 Private method to handle the Cursor Word Right command. |
|
1617 """ |
|
1618 self.__QScintillaRightCommand(self.moveCursorWordRight) |
|
1619 |
|
1620 def __QScintillaDeleteWordRight(self): |
|
1621 """ |
|
1622 Private method to handle the Delete Word Right command. |
|
1623 """ |
|
1624 self.__QScintillaRightCommand(self.deleteWordRight) |
|
1625 |
1626 |
1626 def __QScintillaDeleteLineRight(self): |
1627 def __QScintillaDeleteLineRight(self): |
1627 """ |
1628 """ |
1628 Private method to handle the Delete Line Right command. |
1629 Private method to handle the Delete Line Right command. |
1629 """ |
1630 """ |
1630 self.__QScintillaRightCommand(self.deleteLineRight) |
1631 # delete is only allowed on the last line |
|
1632 if self.__isCursorOnLastLine(): |
|
1633 self.__QScintillaRightCommand(self.deleteLineRight) |
1631 |
1634 |
1632 def __QScintillaVCHome(self, cmd): |
1635 def __QScintillaVCHome(self, cmd): |
1633 """ |
1636 """ |
1634 Private method to handle the Home key. |
1637 Private method to handle the Home key. |
1635 |
1638 |
1636 @param cmd QScintilla command |
1639 @param cmd QScintilla command |
1637 @type int |
1640 @type int |
1638 """ |
1641 """ |
1639 if self.isListActive(): |
1642 if self.isListActive(): |
1640 self.SendScintilla(cmd) |
1643 self.SendScintilla(cmd) |
1641 elif self.__isCursorOnLastLine(): |
1644 else: |
1642 line, col = self.getCursorPosition() |
1645 line, col = self.getCursorPosition() |
1643 if self.text(line).startswith(sys.ps1): |
1646 if self.text(line).startswith(sys.ps1): |
1644 col = len(sys.ps1) |
1647 col = len(sys.ps1) |
1645 elif self.text(line).startswith(sys.ps2): |
1648 elif self.text(line).startswith(sys.ps2): |
1646 col = len(sys.ps2) |
1649 col = len(sys.ps2) |
1655 @param cmd QScintilla command |
1658 @param cmd QScintilla command |
1656 @type int |
1659 @type int |
1657 """ |
1660 """ |
1658 if self.isListActive(): |
1661 if self.isListActive(): |
1659 self.SendScintilla(cmd) |
1662 self.SendScintilla(cmd) |
1660 elif self.__isCursorOnLastLine(): |
1663 else: |
1661 self.moveCursorToEOL() |
1664 self.moveCursorToEOL() |
1662 |
1665 |
1663 def __QScintillaCursorCommand(self, cmd): |
1666 def __QScintillaCursorCommand(self, cmd): |
1664 """ |
1667 """ |
1665 Private method to handle the cursor commands. |
1668 Private method to handle the cursor commands. |
1810 |
1813 |
1811 def __QScintillaCharLeftExtend(self): |
1814 def __QScintillaCharLeftExtend(self): |
1812 """ |
1815 """ |
1813 Private method to handle the Extend Selection Left command. |
1816 Private method to handle the Extend Selection Left command. |
1814 """ |
1817 """ |
1815 self.__QScintillaLeftCommand(self.extendSelectionLeft, True) |
1818 self.__QScintillaLeftCommand(self.extendSelectionLeft) |
1816 |
1819 |
1817 def __QScintillaWordLeftExtend(self): |
1820 def __QScintillaWordLeftExtend(self): |
1818 """ |
1821 """ |
1819 Private method to handle the Extend Selection Left one word command. |
1822 Private method to handle the Extend Selection Left one word command. |
1820 """ |
1823 """ |
1821 self.__QScintillaLeftCommand(self.extendSelectionWordLeft, True) |
1824 self.__QScintillaLeftCommand(self.extendSelectionWordLeft) |
1822 |
1825 |
1823 def __QScintillaVCHomeExtend(self): |
1826 def __QScintillaVCHomeExtend(self): |
1824 """ |
1827 """ |
1825 Private method to handle the Extend Selection to start of line command. |
1828 Private method to handle the Extend Selection to start of line command. |
1826 """ |
1829 """ |