21 from Globals import recentNameFiles, isMacPlatform |
21 from Globals import recentNameFiles, isMacPlatform |
22 |
22 |
23 import Preferences |
23 import Preferences |
24 |
24 |
25 from QScintilla.Editor import Editor |
25 from QScintilla.Editor import Editor |
26 from QScintilla.EditorAssembly import EditorAssembly |
|
27 from QScintilla.APIsManager import APIsManager |
|
28 from QScintilla.SpellChecker import SpellChecker |
|
29 import QScintilla.Lexers |
|
30 import QScintilla.Exporters |
|
31 from QScintilla.Shell import Shell |
|
32 from QScintilla.Terminal import Terminal |
|
33 |
26 |
34 import Utilities |
27 import Utilities |
35 |
28 |
36 import UI.PixmapCache |
29 import UI.PixmapCache |
37 import UI.Config |
30 import UI.Config |
151 self.autosaveTimer.setObjectName("AutosaveTimer") |
144 self.autosaveTimer.setObjectName("AutosaveTimer") |
152 self.autosaveTimer.setSingleShot(True) |
145 self.autosaveTimer.setSingleShot(True) |
153 self.autosaveTimer.timeout.connect(self.__autosave) |
146 self.autosaveTimer.timeout.connect(self.__autosave) |
154 |
147 |
155 # initialize the APIs manager |
148 # initialize the APIs manager |
|
149 from QScintilla.APIsManager import APIsManager |
156 self.apisManager = APIsManager(parent=self) |
150 self.apisManager = APIsManager(parent=self) |
157 |
151 |
158 self.__cooperationClient = None |
152 self.__cooperationClient = None |
159 |
153 |
160 self.__lastFocusWidget = None |
154 self.__lastFocusWidget = None |
714 """ |
708 """ |
715 Private method used to setup the Exporters sub menu. |
709 Private method used to setup the Exporters sub menu. |
716 """ |
710 """ |
717 menu = QMenu(QApplication.translate('ViewManager', "Export as")) |
711 menu = QMenu(QApplication.translate('ViewManager', "Export as")) |
718 |
712 |
|
713 import QScintilla.Exporters |
719 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
714 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
720 exporters = sorted(list(supportedExporters.keys())) |
715 exporters = sorted(list(supportedExporters.keys())) |
721 for exporter in exporters: |
716 for exporter in exporters: |
722 act = menu.addAction(supportedExporters[exporter]) |
717 act = menu.addAction(supportedExporters[exporter]) |
723 act.setData(exporter) |
718 act.setData(exporter) |
3585 |
3580 |
3586 def __enableSpellingActions(self): |
3581 def __enableSpellingActions(self): |
3587 """ |
3582 """ |
3588 Private method to set the enabled state of the spelling actions. |
3583 Private method to set the enabled state of the spelling actions. |
3589 """ |
3584 """ |
|
3585 from QScintilla.SpellChecker import SpellChecker |
3590 spellingAvailable = SpellChecker.isAvailable() |
3586 spellingAvailable = SpellChecker.isAvailable() |
3591 |
3587 |
3592 self.spellCheckAct.setEnabled(len(self.editors) != 0 and spellingAvailable) |
3588 self.spellCheckAct.setEnabled(len(self.editors) != 0 and spellingAvailable) |
3593 self.autoSpellCheckAct.setEnabled(spellingAvailable) |
3589 self.autoSpellCheckAct.setEnabled(spellingAvailable) |
3594 |
3590 |
3652 if prog is None: |
3648 if prog is None: |
3653 # set the cwd of the dialog based on the following search criteria: |
3649 # set the cwd of the dialog based on the following search criteria: |
3654 # 1: Directory of currently active editor |
3650 # 1: Directory of currently active editor |
3655 # 2: Directory of currently active project |
3651 # 2: Directory of currently active project |
3656 # 3: CWD |
3652 # 3: CWD |
|
3653 import QScintilla.Lexers |
3657 filter = self._getOpenFileFilter() |
3654 filter = self._getOpenFileFilter() |
3658 progs = E5FileDialog.getOpenFileNamesAndFilter( |
3655 progs = E5FileDialog.getOpenFileNamesAndFilter( |
3659 self.ui, |
3656 self.ui, |
3660 QApplication.translate('ViewManager', "Open files"), |
3657 QApplication.translate('ViewManager', "Open files"), |
3661 self._getOpenStartDir(), |
3658 self._getOpenStartDir(), |
3896 @param filetype type of the source file (string) |
3893 @param filetype type of the source file (string) |
3897 @param fn filename of this view |
3894 @param fn filename of this view |
3898 @return reference to the new editor object (Editor.Editor) and the new |
3895 @return reference to the new editor object (Editor.Editor) and the new |
3899 edito assembly object (EditorAssembly.EditorAssembly) |
3896 edito assembly object (EditorAssembly.EditorAssembly) |
3900 """ |
3897 """ |
|
3898 from QScintilla.EditorAssembly import EditorAssembly |
3901 assembly = EditorAssembly(self.dbs, fn, self, filetype=filetype, editor=caller, |
3899 assembly = EditorAssembly(self.dbs, fn, self, filetype=filetype, editor=caller, |
3902 tv=e5App().getObject("TaskViewer")) |
3900 tv=e5App().getObject("TaskViewer")) |
3903 editor = assembly.getEditor() |
3901 editor = assembly.getEditor() |
3904 self.editors.append(editor) |
3902 self.editors.append(editor) |
3905 self.__connectEditor(editor) |
3903 self.__connectEditor(editor) |
3999 encoding = '' |
3997 encoding = '' |
4000 self.sbEnc.setText(encoding) |
3998 self.sbEnc.setText(encoding) |
4001 |
3999 |
4002 if language is None: |
4000 if language is None: |
4003 language = '' |
4001 language = '' |
|
4002 import QScintilla.Lexers |
4004 pixmap = QScintilla.Lexers.getLanguageIcon(language, True) |
4003 pixmap = QScintilla.Lexers.getLanguageIcon(language, True) |
4005 self.sbLang.setPixmap(pixmap) |
4004 self.sbLang.setPixmap(pixmap) |
4006 if pixmap.isNull(): |
4005 if pixmap.isNull(): |
4007 self.sbLang.setText(language) |
4006 self.sbLang.setText(language) |
4008 self.sbLang.setToolTip("") |
4007 self.sbLang.setToolTip("") |
4091 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
4090 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
4092 for editor in self.editors: |
4091 for editor in self.editors: |
4093 if Utilities.samepath(fn, editor.getFileName()): |
4092 if Utilities.samepath(fn, editor.getFileName()): |
4094 break |
4093 break |
4095 else: |
4094 else: |
|
4095 from QScintilla.EditorAssembly import EditorAssembly |
4096 assembly = EditorAssembly(self.dbs, fn, self, filetype=filetype, |
4096 assembly = EditorAssembly(self.dbs, fn, self, filetype=filetype, |
4097 tv=e5App().getObject("TaskViewer")) |
4097 tv=e5App().getObject("TaskViewer")) |
4098 editor = assembly.getEditor() |
4098 editor = assembly.getEditor() |
4099 self.editors.append(editor) |
4099 self.editors.append(editor) |
4100 self.__connectEditor(editor) |
4100 self.__connectEditor(editor) |
4266 |
4266 |
4267 def newEditor(self): |
4267 def newEditor(self): |
4268 """ |
4268 """ |
4269 Public slot to generate a new empty editor. |
4269 Public slot to generate a new empty editor. |
4270 """ |
4270 """ |
|
4271 from QScintilla.EditorAssembly import EditorAssembly |
4271 assembly = EditorAssembly(self.dbs, None, self, |
4272 assembly = EditorAssembly(self.dbs, None, self, |
4272 tv=e5App().getObject("TaskViewer")) |
4273 tv=e5App().getObject("TaskViewer")) |
4273 editor = assembly.getEditor() |
4274 editor = assembly.getEditor() |
4274 self.editors.append(editor) |
4275 self.editors.append(editor) |
4275 self.__connectEditor(editor) |
4276 self.__connectEditor(editor) |
4462 Public method to handle the global change of focus. |
4463 Public method to handle the global change of focus. |
4463 |
4464 |
4464 @param old reference to the widget loosing focus (QWidget) |
4465 @param old reference to the widget loosing focus (QWidget) |
4465 @param now reference to the widget gaining focus (QWidget) |
4466 @param now reference to the widget gaining focus (QWidget) |
4466 """ |
4467 """ |
|
4468 from QScintilla.Shell import Shell |
|
4469 from QScintilla.Terminal import Terminal |
|
4470 |
4467 if not isinstance(now, (Editor, Shell, Terminal)): |
4471 if not isinstance(now, (Editor, Shell, Terminal)): |
4468 self.editActGrp.setEnabled(False) |
4472 self.editActGrp.setEnabled(False) |
4469 self.copyActGrp.setEnabled(False) |
4473 self.copyActGrp.setEnabled(False) |
4470 self.viewActGrp.setEnabled(False) |
4474 self.viewActGrp.setEnabled(False) |
4471 self.sbZoom.setEnabled(False) |
4475 self.sbZoom.setEnabled(False) |
5461 |
5465 |
5462 def __editUserPWL(self): |
5466 def __editUserPWL(self): |
5463 """ |
5467 """ |
5464 Private slot to edit the user word list. |
5468 Private slot to edit the user word list. |
5465 """ |
5469 """ |
|
5470 from QScintilla.SpellChecker import SpellChecker |
5466 pwl = SpellChecker.getUserDictionaryPath() |
5471 pwl = SpellChecker.getUserDictionaryPath() |
5467 self.__editSpellingDictionary(pwl) |
5472 self.__editSpellingDictionary(pwl) |
5468 |
5473 |
5469 def __editUserPEL(self): |
5474 def __editUserPEL(self): |
5470 """ |
5475 """ |
5471 Private slot to edit the user exception list. |
5476 Private slot to edit the user exception list. |
5472 """ |
5477 """ |
|
5478 from QScintilla.SpellChecker import SpellChecker |
5473 pel = SpellChecker.getUserDictionaryPath(True) |
5479 pel = SpellChecker.getUserDictionaryPath(True) |
5474 self.__editSpellingDictionary(pel) |
5480 self.__editSpellingDictionary(pel) |
5475 |
5481 |
5476 def __editSpellingDictionary(self, dictionaryFile): |
5482 def __editSpellingDictionary(self, dictionaryFile): |
5477 """ |
5483 """ |
5924 """ |
5930 """ |
5925 if self.activeWindow() is not None and \ |
5931 if self.activeWindow() is not None and \ |
5926 self.activeWindow().getFileName(): |
5932 self.activeWindow().getFileName(): |
5927 ext = os.path.splitext(self.activeWindow().getFileName())[1] |
5933 ext = os.path.splitext(self.activeWindow().getFileName())[1] |
5928 rx = QRegExp(".*\*\.{0}[ )].*".format(ext[1:])) |
5934 rx = QRegExp(".*\*\.{0}[ )].*".format(ext[1:])) |
|
5935 import QScintilla.Lexers |
5929 filters = QScintilla.Lexers.getOpenFileFiltersList() |
5936 filters = QScintilla.Lexers.getOpenFileFiltersList() |
5930 index = -1 |
5937 index = -1 |
5931 for i in range(len(filters)): |
5938 for i in range(len(filters)): |
5932 if rx.exactMatch(filters[i]): |
5939 if rx.exactMatch(filters[i]): |
5933 index = i |
5940 index = i |