4034 'EOL Mode: {0}'.format(eol))) |
4034 'EOL Mode: {0}'.format(eol))) |
4035 |
4035 |
4036 if zoom is None: |
4036 if zoom is None: |
4037 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4037 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4038 aw = e5App().getObject("Shell") |
4038 aw = e5App().getObject("Shell") |
4039 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4040 aw = e5App().getObject("Terminal") |
|
4041 else: |
4039 else: |
4042 aw = self.activeWindow() |
4040 aw = self.activeWindow() |
4043 if aw: |
4041 if aw: |
4044 self.sbZoom.setValue(aw.getZoom()) |
4042 self.sbZoom.setValue(aw.getZoom()) |
4045 else: |
4043 else: |
4481 |
4479 |
4482 @param old reference to the widget loosing focus (QWidget) |
4480 @param old reference to the widget loosing focus (QWidget) |
4483 @param now reference to the widget gaining focus (QWidget) |
4481 @param now reference to the widget gaining focus (QWidget) |
4484 """ |
4482 """ |
4485 from QScintilla.Shell import Shell |
4483 from QScintilla.Shell import Shell |
4486 from QScintilla.Terminal import Terminal |
4484 |
4487 |
4485 if not isinstance(now, (Editor, Shell)): |
4488 if not isinstance(now, (Editor, Shell, Terminal)): |
|
4489 self.editActGrp.setEnabled(False) |
4486 self.editActGrp.setEnabled(False) |
4490 self.copyActGrp.setEnabled(False) |
4487 self.copyActGrp.setEnabled(False) |
4491 self.viewActGrp.setEnabled(False) |
4488 self.viewActGrp.setEnabled(False) |
4492 self.sbZoom.setEnabled(False) |
4489 self.sbZoom.setEnabled(False) |
4493 else: |
4490 else: |
4494 self.sbZoom.setEnabled(True) |
4491 self.sbZoom.setEnabled(True) |
4495 self.sbZoom.setValue(now.getZoom()) |
4492 self.sbZoom.setValue(now.getZoom()) |
4496 |
4493 |
4497 if not isinstance(now, (Editor, Shell, Terminal)) and \ |
4494 if not isinstance(now, (Editor, Shell)) and \ |
4498 now is not self.quickFindtextCombo: |
4495 now is not self.quickFindtextCombo: |
4499 self.searchActGrp.setEnabled(False) |
4496 self.searchActGrp.setEnabled(False) |
4500 |
4497 |
4501 if now is self.quickFindtextCombo: |
4498 if now is self.quickFindtextCombo: |
4502 self.searchActGrp.setEnabled(True) |
4499 self.searchActGrp.setEnabled(True) |
4503 |
4500 |
4504 if isinstance(old, (Editor, Shell, Terminal)): |
4501 if not isinstance(now, (Editor, Shell)): |
4505 self.__lastFocusWidget = old |
4502 self.__lastFocusWidget = old |
4506 |
4503 |
4507 ################################################################## |
4504 ################################################################## |
4508 ## Below are the action methods for the edit menu |
4505 ## Below are the action methods for the edit menu |
4509 ################################################################## |
4506 ################################################################## |
4530 """ |
4527 """ |
4531 Private method to handle the cut action. |
4528 Private method to handle the cut action. |
4532 """ |
4529 """ |
4533 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4530 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4534 e5App().getObject("Shell").cut() |
4531 e5App().getObject("Shell").cut() |
4535 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4536 e5App().getObject("Terminal").cut() |
|
4537 else: |
4532 else: |
4538 self.activeWindow().cut() |
4533 self.activeWindow().cut() |
4539 |
4534 |
4540 def __editCopy(self): |
4535 def __editCopy(self): |
4541 """ |
4536 """ |
4542 Private method to handle the copy action. |
4537 Private method to handle the copy action. |
4543 """ |
4538 """ |
4544 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4539 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4545 e5App().getObject("Shell").copy() |
4540 e5App().getObject("Shell").copy() |
4546 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4547 e5App().getObject("Terminal").copy() |
|
4548 else: |
4541 else: |
4549 self.activeWindow().copy() |
4542 self.activeWindow().copy() |
4550 |
4543 |
4551 def __editPaste(self): |
4544 def __editPaste(self): |
4552 """ |
4545 """ |
4553 Private method to handle the paste action. |
4546 Private method to handle the paste action. |
4554 """ |
4547 """ |
4555 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4548 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4556 e5App().getObject("Shell").paste() |
4549 e5App().getObject("Shell").paste() |
4557 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4558 e5App().getObject("Terminal").paste() |
|
4559 else: |
4550 else: |
4560 self.activeWindow().paste() |
4551 self.activeWindow().paste() |
4561 |
4552 |
4562 def __editDelete(self): |
4553 def __editDelete(self): |
4563 """ |
4554 """ |
4564 Private method to handle the delete action. |
4555 Private method to handle the delete action. |
4565 """ |
4556 """ |
4566 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4557 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4567 e5App().getObject("Shell").clear() |
4558 e5App().getObject("Shell").clear() |
4568 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4569 e5App().getObject("Terminal").clear() |
|
4570 else: |
4559 else: |
4571 self.activeWindow().clear() |
4560 self.activeWindow().clear() |
4572 |
4561 |
4573 def __editJoin(self): |
4562 def __editJoin(self): |
4574 """ |
4563 """ |
5026 """ |
5015 """ |
5027 Private method to handle the zoom in action. |
5016 Private method to handle the zoom in action. |
5028 """ |
5017 """ |
5029 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5018 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5030 e5App().getObject("Shell").zoomIn() |
5019 e5App().getObject("Shell").zoomIn() |
5031 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
5032 e5App().getObject("Terminal").zoomIn() |
|
5033 else: |
5020 else: |
5034 aw = self.activeWindow() |
5021 aw = self.activeWindow() |
5035 if aw: |
5022 if aw: |
5036 aw.zoomIn() |
5023 aw.zoomIn() |
5037 self.sbZoom.setValue(aw.getZoom()) |
5024 self.sbZoom.setValue(aw.getZoom()) |
5040 """ |
5027 """ |
5041 Private method to handle the zoom out action. |
5028 Private method to handle the zoom out action. |
5042 """ |
5029 """ |
5043 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5030 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5044 e5App().getObject("Shell").zoomOut() |
5031 e5App().getObject("Shell").zoomOut() |
5045 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
5046 e5App().getObject("Terminal").zoomOut() |
|
5047 else: |
5032 else: |
5048 aw = self.activeWindow() |
5033 aw = self.activeWindow() |
5049 if aw: |
5034 if aw: |
5050 aw.zoomOut() |
5035 aw.zoomOut() |
5051 self.sbZoom.setValue(aw.getZoom()) |
5036 self.sbZoom.setValue(aw.getZoom()) |
5054 """ |
5039 """ |
5055 Private method to reset the zoom factor. |
5040 Private method to reset the zoom factor. |
5056 """ |
5041 """ |
5057 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5042 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5058 e5App().getObject("Shell").zoomTo(0) |
5043 e5App().getObject("Shell").zoomTo(0) |
5059 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
5060 e5App().getObject("Terminal").zoomTo(0) |
|
5061 else: |
5044 else: |
5062 aw = self.activeWindow() |
5045 aw = self.activeWindow() |
5063 if aw: |
5046 if aw: |
5064 aw.zoomTo(0) |
5047 aw.zoomTo(0) |
5065 self.sbZoom.setValue(aw.getZoom()) |
5048 self.sbZoom.setValue(aw.getZoom()) |
5070 |
5053 |
5071 @keyparam value zoom value to be set (integer) |
5054 @keyparam value zoom value to be set (integer) |
5072 """ |
5055 """ |
5073 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5056 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5074 aw = e5App().getObject("Shell") |
5057 aw = e5App().getObject("Shell") |
5075 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
5076 aw = e5App().getObject("Terminal") |
|
5077 else: |
5058 else: |
5078 aw = self.activeWindow() |
5059 aw = self.activeWindow() |
5079 if aw: |
5060 if aw: |
5080 if value is None: |
5061 if value is None: |
5081 from QScintilla.ZoomDialog import ZoomDialog |
5062 from QScintilla.ZoomDialog import ZoomDialog |
5092 |
5073 |
5093 @param value new zoom value (integer) |
5074 @param value new zoom value (integer) |
5094 """ |
5075 """ |
5095 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5076 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5096 aw = e5App().getObject("Shell") |
5077 aw = e5App().getObject("Shell") |
5097 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
5098 aw = e5App().getObject("Terminal") |
|
5099 else: |
5078 else: |
5100 aw = self.activeWindow() |
5079 aw = self.activeWindow() |
5101 if aw and aw == self.sender(): |
5080 if aw and aw == self.sender(): |
5102 self.sbZoom.setValue(value) |
5081 self.sbZoom.setValue(value) |
5103 |
5082 |
5672 |
5651 |
5673 self.undoAct.setEnabled(editor.isUndoAvailable()) |
5652 self.undoAct.setEnabled(editor.isUndoAvailable()) |
5674 self.redoAct.setEnabled(editor.isRedoAvailable()) |
5653 self.redoAct.setEnabled(editor.isRedoAvailable()) |
5675 self.gotoLastEditAct.setEnabled(editor.isLastEditPositionAvailable()) |
5654 self.gotoLastEditAct.setEnabled(editor.isLastEditPositionAvailable()) |
5676 |
5655 |
5677 ## self.previewAct.setEnabled(editor.isPreviewable()) |
|
5678 ## |
|
5679 lex = editor.getLexer() |
5656 lex = editor.getLexer() |
5680 if lex is not None: |
5657 if lex is not None: |
5681 self.commentAct.setEnabled(lex.canBlockComment()) |
5658 self.commentAct.setEnabled(lex.canBlockComment()) |
5682 self.uncommentAct.setEnabled(lex.canBlockComment()) |
5659 self.uncommentAct.setEnabled(lex.canBlockComment()) |
5683 self.streamCommentAct.setEnabled(lex.canStreamComment()) |
5660 self.streamCommentAct.setEnabled(lex.canStreamComment()) |
5858 @param cmd the scintilla command to be sent |
5835 @param cmd the scintilla command to be sent |
5859 """ |
5836 """ |
5860 focusWidget = QApplication.focusWidget() |
5837 focusWidget = QApplication.focusWidget() |
5861 if focusWidget == e5App().getObject("Shell"): |
5838 if focusWidget == e5App().getObject("Shell"): |
5862 e5App().getObject("Shell").editorCommand(cmd) |
5839 e5App().getObject("Shell").editorCommand(cmd) |
5863 elif focusWidget == e5App().getObject("Terminal"): |
|
5864 e5App().getObject("Terminal").editorCommand(cmd) |
|
5865 elif focusWidget == self.quickFindtextCombo: |
5840 elif focusWidget == self.quickFindtextCombo: |
5866 self.quickFindtextCombo._editor.editorCommand(cmd) |
5841 self.quickFindtextCombo._editor.editorCommand(cmd) |
5867 else: |
5842 else: |
5868 aw = self.activeWindow() |
5843 aw = self.activeWindow() |
5869 if aw: |
5844 if aw: |
5874 Private method to insert a new line below the current one even if |
5849 Private method to insert a new line below the current one even if |
5875 cursor is not at the end of the line. |
5850 cursor is not at the end of the line. |
5876 """ |
5851 """ |
5877 focusWidget = QApplication.focusWidget() |
5852 focusWidget = QApplication.focusWidget() |
5878 if focusWidget == e5App().getObject("Shell") or \ |
5853 if focusWidget == e5App().getObject("Shell") or \ |
5879 focusWidget == e5App().getObject("Terminal") or \ |
|
5880 focusWidget == self.quickFindtextCombo: |
5854 focusWidget == self.quickFindtextCombo: |
5881 return |
5855 return |
5882 else: |
5856 else: |
5883 aw = self.activeWindow() |
5857 aw = self.activeWindow() |
5884 if aw: |
5858 if aw: |
6077 |
6051 |
6078 @param txt text to be inserted (string) |
6052 @param txt text to be inserted (string) |
6079 """ |
6053 """ |
6080 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6054 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6081 e5App().getObject("Shell").insert(txt) |
6055 e5App().getObject("Shell").insert(txt) |
6082 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
6083 e5App().getObject("Terminal").insert(txt) |
|
6084 else: |
6056 else: |
6085 aw = self.activeWindow() |
6057 aw = self.activeWindow() |
6086 if aw is not None: |
6058 if aw is not None: |
6087 curline, curindex = aw.getCursorPosition() |
6059 curline, curindex = aw.getCursorPosition() |
6088 aw.insert(txt) |
6060 aw.insert(txt) |
6098 |
6070 |
6099 @param txt text to be inserted (string) |
6071 @param txt text to be inserted (string) |
6100 """ |
6072 """ |
6101 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6073 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6102 aw = e5App().getObject("Shell") |
6074 aw = e5App().getObject("Shell") |
6103 if aw.hasSelectedText(): |
|
6104 aw.removeSelectedText() |
|
6105 aw.insert(txt) |
|
6106 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
6107 aw = e5App().getObject("Terminal") |
|
6108 if aw.hasSelectedText(): |
6075 if aw.hasSelectedText(): |
6109 aw.removeSelectedText() |
6076 aw.removeSelectedText() |
6110 aw.insert(txt) |
6077 aw.insert(txt) |
6111 else: |
6078 else: |
6112 aw = self.activeWindow() |
6079 aw = self.activeWindow() |
6126 txt = "" |
6093 txt = "" |
6127 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6094 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6128 aw = e5App().getObject("Shell") |
6095 aw = e5App().getObject("Shell") |
6129 if aw.hasSelectedText(): |
6096 if aw.hasSelectedText(): |
6130 txt = aw.selectedText() |
6097 txt = aw.selectedText() |
6131 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
6132 aw = e5App().getObject("Terminal") |
|
6133 if aw.hasSelectedText(): |
|
6134 txt = aw.selectedText() |
|
6135 else: |
6098 else: |
6136 aw = self.activeWindow() |
6099 aw = self.activeWindow() |
6137 if aw is not None: |
6100 if aw is not None: |
6138 if aw.hasSelectedText(): |
6101 if aw.hasSelectedText(): |
6139 txt = aw.selectedText() |
6102 txt = aw.selectedText() |