32 from QScintilla.APIsManager import APIsManager |
32 from QScintilla.APIsManager import APIsManager |
33 from QScintilla.SpellChecker import SpellChecker |
33 from QScintilla.SpellChecker import SpellChecker |
34 import QScintilla.Lexers |
34 import QScintilla.Lexers |
35 import QScintilla.Exporters |
35 import QScintilla.Exporters |
36 from QScintilla.Shell import Shell |
36 from QScintilla.Shell import Shell |
37 from QScintilla.Terminal import Terminal |
|
38 from QScintilla.SpellingDictionaryEditDialog import SpellingDictionaryEditDialog |
37 from QScintilla.SpellingDictionaryEditDialog import SpellingDictionaryEditDialog |
39 |
38 |
40 import Utilities |
39 import Utilities |
41 |
40 |
42 import UI.PixmapCache |
41 import UI.PixmapCache |
4431 Public method to handle the global change of focus. |
4430 Public method to handle the global change of focus. |
4432 |
4431 |
4433 @param old reference to the widget loosing focus (QWidget) |
4432 @param old reference to the widget loosing focus (QWidget) |
4434 @param now reference to the widget gaining focus (QWidget) |
4433 @param now reference to the widget gaining focus (QWidget) |
4435 """ |
4434 """ |
4436 if not isinstance(now, (Editor, Shell, Terminal)): |
4435 if not isinstance(now, (Editor, Shell)): |
4437 self.editActGrp.setEnabled(False) |
4436 self.editActGrp.setEnabled(False) |
4438 self.copyActGrp.setEnabled(False) |
4437 self.copyActGrp.setEnabled(False) |
4439 self.viewActGrp.setEnabled(False) |
4438 self.viewActGrp.setEnabled(False) |
4440 |
4439 |
4441 if not isinstance(now, (Editor, Shell, Terminal)) and \ |
4440 if not isinstance(now, (Editor, Shell)) and \ |
4442 now is not self.quickFindtextCombo: |
4441 now is not self.quickFindtextCombo: |
4443 self.searchActGrp.setEnabled(False) |
4442 self.searchActGrp.setEnabled(False) |
4444 |
4443 |
4445 if now is self.quickFindtextCombo: |
4444 if now is self.quickFindtextCombo: |
4446 self.searchActGrp.setEnabled(True) |
4445 self.searchActGrp.setEnabled(True) |
4447 |
4446 |
4448 if isinstance(old, (Editor, Shell, Terminal)): |
4447 if isinstance(old, (Editor, Shell)): |
4449 self.__lastFocusWidget = old |
4448 self.__lastFocusWidget = old |
4450 |
4449 |
4451 ################################################################## |
4450 ################################################################## |
4452 ## Below are the action methods for the edit menu |
4451 ## Below are the action methods for the edit menu |
4453 ################################################################## |
4452 ################################################################## |
4474 """ |
4473 """ |
4475 Private method to handle the cut action. |
4474 Private method to handle the cut action. |
4476 """ |
4475 """ |
4477 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4476 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4478 e5App().getObject("Shell").cut() |
4477 e5App().getObject("Shell").cut() |
4479 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4480 e5App().getObject("Terminal").cut() |
|
4481 else: |
4478 else: |
4482 self.activeWindow().cut() |
4479 self.activeWindow().cut() |
4483 |
4480 |
4484 def __editCopy(self): |
4481 def __editCopy(self): |
4485 """ |
4482 """ |
4486 Private method to handle the copy action. |
4483 Private method to handle the copy action. |
4487 """ |
4484 """ |
4488 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4485 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4489 e5App().getObject("Shell").copy() |
4486 e5App().getObject("Shell").copy() |
4490 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4491 e5App().getObject("Terminal").copy() |
|
4492 else: |
4487 else: |
4493 self.activeWindow().copy() |
4488 self.activeWindow().copy() |
4494 |
4489 |
4495 def __editPaste(self): |
4490 def __editPaste(self): |
4496 """ |
4491 """ |
4497 Private method to handle the paste action. |
4492 Private method to handle the paste action. |
4498 """ |
4493 """ |
4499 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4494 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4500 e5App().getObject("Shell").paste() |
4495 e5App().getObject("Shell").paste() |
4501 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4502 e5App().getObject("Terminal").paste() |
|
4503 else: |
4496 else: |
4504 self.activeWindow().paste() |
4497 self.activeWindow().paste() |
4505 |
4498 |
4506 def __editDelete(self): |
4499 def __editDelete(self): |
4507 """ |
4500 """ |
4508 Private method to handle the delete action. |
4501 Private method to handle the delete action. |
4509 """ |
4502 """ |
4510 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4503 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4511 e5App().getObject("Shell").clear() |
4504 e5App().getObject("Shell").clear() |
4512 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4513 e5App().getObject("Terminal").clear() |
|
4514 else: |
4505 else: |
4515 self.activeWindow().clear() |
4506 self.activeWindow().clear() |
4516 |
4507 |
4517 def __editJoin(self): |
4508 def __editJoin(self): |
4518 """ |
4509 """ |
4967 """ |
4958 """ |
4968 Private method to handle the zoom in action. |
4959 Private method to handle the zoom in action. |
4969 """ |
4960 """ |
4970 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4961 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4971 e5App().getObject("Shell").zoomIn() |
4962 e5App().getObject("Shell").zoomIn() |
4972 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4973 e5App().getObject("Terminal").zoomIn() |
|
4974 else: |
4963 else: |
4975 aw = self.activeWindow() |
4964 aw = self.activeWindow() |
4976 if aw: |
4965 if aw: |
4977 aw.zoomIn() |
4966 aw.zoomIn() |
4978 |
4967 |
4980 """ |
4969 """ |
4981 Private method to handle the zoom out action. |
4970 Private method to handle the zoom out action. |
4982 """ |
4971 """ |
4983 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4972 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4984 e5App().getObject("Shell").zoomOut() |
4973 e5App().getObject("Shell").zoomOut() |
4985 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4986 e5App().getObject("Terminal").zoomOut() |
|
4987 else: |
4974 else: |
4988 aw = self.activeWindow() |
4975 aw = self.activeWindow() |
4989 if aw: |
4976 if aw: |
4990 aw.zoomOut() |
4977 aw.zoomOut() |
4991 |
4978 |
4993 """ |
4980 """ |
4994 Private method to reset the zoom factor. |
4981 Private method to reset the zoom factor. |
4995 """ |
4982 """ |
4996 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4983 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4997 e5App().getObject("Shell").zoomTo(0) |
4984 e5App().getObject("Shell").zoomTo(0) |
4998 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
4999 e5App().getObject("Terminal").zoomTo(0) |
|
5000 else: |
4985 else: |
5001 aw = self.activeWindow() |
4986 aw = self.activeWindow() |
5002 if aw: |
4987 if aw: |
5003 aw.zoomTo(0) |
4988 aw.zoomTo(0) |
5004 |
4989 |
5006 """ |
4991 """ |
5007 Private method to handle the zoom action. |
4992 Private method to handle the zoom action. |
5008 """ |
4993 """ |
5009 if QApplication.focusWidget() == e5App().getObject("Shell"): |
4994 if QApplication.focusWidget() == e5App().getObject("Shell"): |
5010 aw = e5App().getObject("Shell") |
4995 aw = e5App().getObject("Shell") |
5011 elif QApplication.focusWidget() == e5App().getObject("Terminal"): |
|
5012 aw = e5App().getObject("Terminal") |
|
5013 else: |
4996 else: |
5014 aw = self.activeWindow() |
4997 aw = self.activeWindow() |
5015 if aw: |
4998 if aw: |
5016 dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) |
4999 dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) |
5017 if dlg.exec_() == QDialog.Accepted: |
5000 if dlg.exec_() == QDialog.Accepted: |
5774 @param cmd the scintilla command to be sent |
5757 @param cmd the scintilla command to be sent |
5775 """ |
5758 """ |
5776 focusWidget = QApplication.focusWidget() |
5759 focusWidget = QApplication.focusWidget() |
5777 if focusWidget == e5App().getObject("Shell"): |
5760 if focusWidget == e5App().getObject("Shell"): |
5778 e5App().getObject("Shell").editorCommand(cmd) |
5761 e5App().getObject("Shell").editorCommand(cmd) |
5779 elif focusWidget == e5App().getObject("Terminal"): |
|
5780 e5App().getObject("Terminal").editorCommand(cmd) |
|
5781 elif focusWidget == self.quickFindtextCombo: |
5762 elif focusWidget == self.quickFindtextCombo: |
5782 self.quickFindtextCombo._editor.editorCommand(cmd) |
5763 self.quickFindtextCombo._editor.editorCommand(cmd) |
5783 else: |
5764 else: |
5784 aw = self.activeWindow() |
5765 aw = self.activeWindow() |
5785 if aw: |
5766 if aw: |
5790 Private method to insert a new line below the current one even if |
5771 Private method to insert a new line below the current one even if |
5791 cursor is not at the end of the line. |
5772 cursor is not at the end of the line. |
5792 """ |
5773 """ |
5793 focusWidget = QApplication.focusWidget() |
5774 focusWidget = QApplication.focusWidget() |
5794 if focusWidget == e5App().getObject("Shell") or \ |
5775 if focusWidget == e5App().getObject("Shell") or \ |
5795 focusWidget == e5App().getObject("Terminal") or \ |
|
5796 focusWidget == self.quickFindtextCombo: |
5776 focusWidget == self.quickFindtextCombo: |
5797 return |
5777 return |
5798 else: |
5778 else: |
5799 aw = self.activeWindow() |
5779 aw = self.activeWindow() |
5800 if aw: |
5780 if aw: |
5990 |
5970 |
5991 @param txt text to be inserted (string) |
5971 @param txt text to be inserted (string) |
5992 """ |
5972 """ |
5993 if self.__lastFocusWidget == e5App().getObject("Shell"): |
5973 if self.__lastFocusWidget == e5App().getObject("Shell"): |
5994 e5App().getObject("Shell").insert(txt) |
5974 e5App().getObject("Shell").insert(txt) |
5995 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
5996 e5App().getObject("Terminal").insert(txt) |
|
5997 else: |
5975 else: |
5998 aw = self.activeWindow() |
5976 aw = self.activeWindow() |
5999 if aw is not None: |
5977 if aw is not None: |
6000 curline, curindex = aw.getCursorPosition() |
5978 curline, curindex = aw.getCursorPosition() |
6001 aw.insert(txt) |
5979 aw.insert(txt) |
6011 |
5989 |
6012 @param txt text to be inserted (string) |
5990 @param txt text to be inserted (string) |
6013 """ |
5991 """ |
6014 if self.__lastFocusWidget == e5App().getObject("Shell"): |
5992 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6015 aw = e5App().getObject("Shell") |
5993 aw = e5App().getObject("Shell") |
6016 if aw.hasSelectedText(): |
|
6017 aw.removeSelectedText() |
|
6018 aw.insert(txt) |
|
6019 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
6020 aw = e5App().getObject("Terminal") |
|
6021 if aw.hasSelectedText(): |
5994 if aw.hasSelectedText(): |
6022 aw.removeSelectedText() |
5995 aw.removeSelectedText() |
6023 aw.insert(txt) |
5996 aw.insert(txt) |
6024 else: |
5997 else: |
6025 aw = self.activeWindow() |
5998 aw = self.activeWindow() |
6039 txt = "" |
6012 txt = "" |
6040 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6013 if self.__lastFocusWidget == e5App().getObject("Shell"): |
6041 aw = e5App().getObject("Shell") |
6014 aw = e5App().getObject("Shell") |
6042 if aw.hasSelectedText(): |
6015 if aw.hasSelectedText(): |
6043 txt = aw.selectedText() |
6016 txt = aw.selectedText() |
6044 elif self.__lastFocusWidget == e5App().getObject("Terminal"): |
|
6045 aw = e5App().getObject("Terminal") |
|
6046 if aw.hasSelectedText(): |
|
6047 txt = aw.selectedText() |
|
6048 else: |
6017 else: |
6049 aw = self.activeWindow() |
6018 aw = self.activeWindow() |
6050 if aw is not None: |
6019 if aw is not None: |
6051 if aw.hasSelectedText(): |
6020 if aw.hasSelectedText(): |
6052 txt = aw.selectedText() |
6021 txt = aw.selectedText() |