7 Module implementing a stand alone shell window. |
7 Module implementing a stand alone shell window. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import QCoreApplication, QPoint, QSize, QSignalMapper |
12 from PyQt5.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper |
13 from PyQt5.QtGui import QKeySequence |
13 from PyQt5.QtGui import QKeySequence |
14 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QAction, \ |
14 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QAction, \ |
15 QWhatsThis |
15 QWhatsThis, QDialog |
16 from PyQt5.Qsci import QsciScintilla |
16 from PyQt5.Qsci import QsciScintilla |
17 |
17 |
18 from E5Gui.E5MainWindow import E5MainWindow |
18 from E5Gui.E5MainWindow import E5MainWindow |
19 from E5Gui.E5Action import E5Action, createActionGroup |
19 from E5Gui.E5Action import E5Action, createActionGroup |
20 from E5Gui.E5Application import e5App |
20 from E5Gui.E5Application import e5App |
21 from E5Gui.E5ZoomWidget import E5ZoomWidget |
21 from E5Gui.E5ZoomWidget import E5ZoomWidget |
22 from E5Gui import E5MessageBox |
22 from E5Gui import E5MessageBox |
23 |
23 |
|
24 import UI.Config |
24 import UI.PixmapCache |
25 import UI.PixmapCache |
25 import Preferences |
26 import Preferences |
26 |
27 |
27 from Globals import isMacPlatform |
28 from Globals import isMacPlatform |
28 |
29 |
56 |
57 |
57 # initialize the APIs manager |
58 # initialize the APIs manager |
58 self.__apisManager = APIsManager(parent=self) |
59 self.__apisManager = APIsManager(parent=self) |
59 |
60 |
60 # initialize the debug server and shell widgets |
61 # initialize the debug server and shell widgets |
61 self.__debugServer = DebugServer() |
62 self.__debugServer = DebugServer(preventPassiveDebugging=True) |
62 self.__shell = Shell(self.__debugServer, self, True, self) |
63 self.__shell = Shell(self.__debugServer, self, True, self) |
63 self.__searchWidget = SearchWidget(self.__shell, self) |
64 self.__searchWidget = SearchWidget(self.__shell, self, showLine=True) |
64 |
65 |
65 centralWidget = QWidget() |
66 centralWidget = QWidget() |
66 layout = QVBoxLayout() |
67 layout = QVBoxLayout() |
67 layout.setContentsMargins(1, 1, 1, 1) |
68 layout.setContentsMargins(1, 1, 1, 1) |
68 layout.addWidget(self.__shell) |
69 layout.addWidget(self.__shell) |
69 layout.addWidget(self.__searchWidget) |
70 layout.addWidget(self.__searchWidget) |
70 centralWidget.setLayout(layout) |
71 centralWidget.setLayout(layout) |
71 self.setCentralWidget(centralWidget) |
72 self.setCentralWidget(centralWidget) |
72 self.__searchWidget.hide() |
73 self.__searchWidget.hide() |
73 |
74 |
74 |
|
75 self.__searchWidget.searchNext.connect(self.__shell.searchNext) |
75 self.__searchWidget.searchNext.connect(self.__shell.searchNext) |
76 self.__searchWidget.searchPrevious.connect(self.__shell.searchPrev) |
76 self.__searchWidget.searchPrevious.connect(self.__shell.searchPrev) |
77 self.__shell.searchStringFound.connect( |
77 self.__shell.searchStringFound.connect( |
78 self.__searchWidget.searchStringFound) |
78 self.__searchWidget.searchStringFound) |
79 |
79 |
80 self.__shell.zoomValueChanged.connect(self.__zoomValueChanged) |
80 self.__shell.zoomValueChanged.connect(self.__zoomValueChanged) |
81 |
81 |
82 self.__createActions() |
82 self.__createActions() |
83 ## self.__createMenus() |
83 self.__createMenus() |
84 ## self.__createToolBars() |
84 self.__createToolBars() |
85 self.__createStatusBar() |
85 self.__createStatusBar() |
86 |
86 |
87 self.__readSettings() |
87 self.__readSettings() |
88 |
88 |
89 # now start the debug client |
89 # now start the debug client |
200 ## """<b>New Window</b>""" |
202 ## """<b>New Window</b>""" |
201 ## """<p>This opens a new instance of the eric6 IDE.</p>""" |
203 ## """<p>This opens a new instance of the eric6 IDE.</p>""" |
202 ## )) |
204 ## )) |
203 ## self.newWindowAct.triggered.connect(self.__newWindow) |
205 ## self.newWindowAct.triggered.connect(self.__newWindow) |
204 ## self.fileActions.append(self.newWindowAct) |
206 ## self.fileActions.append(self.newWindowAct) |
|
207 |
|
208 self.restartAct = E5Action( |
|
209 self.tr('Restart'), |
|
210 UI.PixmapCache.getIcon("restart.png"), |
|
211 self.tr('Restart'), |
|
212 0, 0, self, 'shell_restart') |
|
213 self.restartAct.setStatusTip(self.tr( |
|
214 'Restart the shell')) |
|
215 self.restartAct.setWhatsThis(self.tr( |
|
216 """<b>Restart</b>""" |
|
217 """<p>Restart the shell for the currently selected language.</p>""" |
|
218 )) |
|
219 self.restartAct.triggered.connect(self.__doRestart) |
|
220 self.fileActions.append(self.restartAct) |
|
221 |
|
222 self.clearRestartAct = E5Action( |
|
223 self.tr('Restart and Clear'), |
|
224 UI.PixmapCache.getIcon("restartDelete.png"), |
|
225 self.tr('Restart and Clear'), |
|
226 Qt.Key_F4, 0, self, 'shell_clear_restart') |
|
227 self.clearRestartAct.setStatusTip(self.tr( |
|
228 'Clear the window and restart the shell')) |
|
229 self.clearRestartAct.setWhatsThis(self.tr( |
|
230 """<b>Restart and Clear</b>""" |
|
231 """<p>Clear the shell window and restart the shell for the""" |
|
232 """ currently selected language.</p>""" |
|
233 )) |
|
234 self.clearRestartAct.triggered.connect(self.__doClearRestart) |
|
235 self.fileActions.append(self.clearRestartAct) |
205 |
236 |
206 def __createEditActions(self): |
237 def __createEditActions(self): |
207 """ |
238 """ |
208 Private method defining the user interface actions for the edit |
239 Private method defining the user interface actions for the edit |
209 commands. |
240 commands. |
269 """ the current editor.</p>""" |
300 """ the current editor.</p>""" |
270 )) |
301 )) |
271 self.pasteAct.triggered.connect(self.__shell.paste) |
302 self.pasteAct.triggered.connect(self.__shell.paste) |
272 self.editActions.append(self.pasteAct) |
303 self.editActions.append(self.pasteAct) |
273 |
304 |
274 self.deleteAct = E5Action( |
305 self.clearAct = E5Action( |
275 QCoreApplication.translate('ViewManager', 'Clear'), |
306 QCoreApplication.translate('ViewManager', 'Clear'), |
276 UI.PixmapCache.getIcon("editDelete.png"), |
307 UI.PixmapCache.getIcon("editDelete.png"), |
277 QCoreApplication.translate('ViewManager', 'Clear'), |
308 QCoreApplication.translate('ViewManager', 'Clear'), |
278 QKeySequence(QCoreApplication.translate( |
309 QKeySequence(QCoreApplication.translate( |
279 'ViewManager', "Alt+Shift+C", "Edit|Clear")), |
310 'ViewManager', "Alt+Shift+C", "Edit|Clear")), |
280 0, |
311 0, |
281 self.copyActGrp, 'vm_edit_clear') |
312 self.copyActGrp, 'vm_edit_clear') |
282 self.deleteAct.setStatusTip(QCoreApplication.translate( |
313 self.clearAct.setStatusTip(QCoreApplication.translate( |
283 'ViewManager', 'Clear all text')) |
314 'ViewManager', 'Clear all text')) |
284 self.deleteAct.setWhatsThis(QCoreApplication.translate( |
315 self.clearAct.setWhatsThis(QCoreApplication.translate( |
285 'ViewManager', |
316 'ViewManager', |
286 """<b>Clear</b>""" |
317 """<b>Clear</b>""" |
287 """<p>Delete all text of the current editor.</p>""" |
318 """<p>Delete all text of the current editor.</p>""" |
288 )) |
319 )) |
289 self.deleteAct.triggered.connect(self.__shell.clear) |
320 self.clearAct.triggered.connect(self.__shell.clear) |
290 self.editActions.append(self.deleteAct) |
321 self.editActions.append(self.clearAct) |
291 |
322 |
292 self.cutAct.setEnabled(False) |
323 self.cutAct.setEnabled(False) |
293 self.copyAct.setEnabled(False) |
324 self.copyAct.setEnabled(False) |
294 self.__shell.copyAvailable.connect(self.cutAct.setEnabled) |
325 self.__shell.copyAvailable.connect(self.cutAct.setEnabled) |
295 self.__shell.copyAvailable.connect(self.copyAct.setEnabled) |
326 self.__shell.copyAvailable.connect(self.copyAct.setEnabled) |
686 UI.PixmapCache.getIcon("findNext.png"), |
717 UI.PixmapCache.getIcon("findNext.png"), |
687 QCoreApplication.translate('ViewManager', 'Search &next'), |
718 QCoreApplication.translate('ViewManager', 'Search &next'), |
688 QKeySequence(QCoreApplication.translate( |
719 QKeySequence(QCoreApplication.translate( |
689 'ViewManager', "F3", "Search|Search next")), |
720 'ViewManager', "F3", "Search|Search next")), |
690 0, |
721 0, |
691 self.searchActGrp, 'vm_search_next') |
722 self, 'vm_search_next') |
692 self.searchNextAct.setStatusTip(QCoreApplication.translate( |
723 self.searchNextAct.setStatusTip(QCoreApplication.translate( |
693 'ViewManager', 'Search next occurrence of text')) |
724 'ViewManager', 'Search next occurrence of text')) |
694 self.searchNextAct.setWhatsThis(QCoreApplication.translate( |
725 self.searchNextAct.setWhatsThis(QCoreApplication.translate( |
695 'ViewManager', |
726 'ViewManager', |
696 """<b>Search next</b>""" |
727 """<b>Search next</b>""" |
707 UI.PixmapCache.getIcon("findPrev.png"), |
738 UI.PixmapCache.getIcon("findPrev.png"), |
708 QCoreApplication.translate('ViewManager', 'Search &previous'), |
739 QCoreApplication.translate('ViewManager', 'Search &previous'), |
709 QKeySequence(QCoreApplication.translate( |
740 QKeySequence(QCoreApplication.translate( |
710 'ViewManager', "Shift+F3", "Search|Search previous")), |
741 'ViewManager', "Shift+F3", "Search|Search previous")), |
711 0, |
742 0, |
712 self.searchActGrp, 'vm_search_previous') |
743 self, 'vm_search_previous') |
713 self.searchPrevAct.setStatusTip(QCoreApplication.translate( |
744 self.searchPrevAct.setStatusTip(QCoreApplication.translate( |
714 'ViewManager', 'Search previous occurrence of text')) |
745 'ViewManager', 'Search previous occurrence of text')) |
715 self.searchPrevAct.setWhatsThis(QCoreApplication.translate( |
746 self.searchPrevAct.setWhatsThis(QCoreApplication.translate( |
716 'ViewManager', |
747 'ViewManager', |
717 """<b>Search previous</b>""" |
748 """<b>Search previous</b>""" |
804 """<p>Zoom the text. This opens a dialog where the""" |
834 """<p>Zoom the text. This opens a dialog where the""" |
805 """ desired size can be entered.</p>""" |
835 """ desired size can be entered.</p>""" |
806 )) |
836 )) |
807 self.zoomToAct.triggered.connect(self.__zoom) |
837 self.zoomToAct.triggered.connect(self.__zoom) |
808 self.viewActions.append(self.zoomToAct) |
838 self.viewActions.append(self.zoomToAct) |
|
839 |
|
840 def __createHistoryActions(self): |
|
841 """ |
|
842 Private method defining the user interface actions for the history |
|
843 commands. |
|
844 """ |
|
845 self.showHistoryAct = E5Action( |
|
846 self.tr('Show History'), |
|
847 UI.PixmapCache.getIcon("history.png"), |
|
848 self.tr('&Show History...'), |
|
849 0, 0, |
|
850 self, 'shell_show_history') |
|
851 self.showHistoryAct.setStatusTip(self.tr( |
|
852 "Show the shell history in a dialog")) |
|
853 self.showHistoryAct.triggered.connect(self.__shell.showHistory) |
|
854 |
|
855 self.clearHistoryAct = E5Action( |
|
856 self.tr('Clear History'), |
|
857 UI.PixmapCache.getIcon("historyClear.png"), |
|
858 self.tr('&Clear History...'), |
|
859 0, 0, |
|
860 self, 'shell_clear_history') |
|
861 self.clearHistoryAct.setStatusTip(self.tr( |
|
862 "Clear the shell history")) |
|
863 self.clearHistoryAct.triggered.connect(self.__shell.clearHistory) |
|
864 |
|
865 self.selectHistoryAct = E5Action( |
|
866 self.tr('Select History Entry'), |
|
867 self.tr('Select History &Entry'), |
|
868 0, 0, |
|
869 self, 'shell_select_history') |
|
870 self.selectHistoryAct.setStatusTip(self.tr( |
|
871 "Select an entry of the shell history")) |
|
872 self.selectHistoryAct.triggered.connect(self.__shell.selectHistory) |
809 |
873 |
810 def __createHelpActions(self): |
874 def __createHelpActions(self): |
811 """ |
875 """ |
812 Private method to create the Help actions. |
876 Private method to create the Help actions. |
813 """ |
877 """ |
949 |
1030 |
950 def __about(self): |
1031 def __about(self): |
951 """ |
1032 """ |
952 Private slot to show a little About message. |
1033 Private slot to show a little About message. |
953 """ |
1034 """ |
954 # TODO: change this text |
|
955 E5MessageBox.about( |
1035 E5MessageBox.about( |
956 self, |
1036 self, |
957 self.tr("About eric6 Mini Editor"), |
1037 self.tr("About eric6 Shell Window"), |
958 self.tr( |
1038 self.tr( |
959 "The eric6 Mini Editor is an editor component" |
1039 "The eric6 Shell is a standalone shell window." |
960 " based on QScintilla. It may be used for simple" |
1040 " It uses the same backend as the debugger of" |
961 " editing tasks, that don't need the power of" |
1041 " the full IDE, but is executed independently.")) |
962 " a full blown editor.")) |
|
963 |
1042 |
964 def __aboutQt(self): |
1043 def __aboutQt(self): |
965 """ |
1044 """ |
966 Private slot to handle the About Qt dialog. |
1045 Private slot to handle the About Qt dialog. |
967 """ |
1046 """ |
968 E5MessageBox.aboutQt(self, "eric6 Shell windindow") |
1047 E5MessageBox.aboutQt(self, "eric6 Shell Window") |
969 |
1048 |
970 def __whatsThis(self): |
1049 def __whatsThis(self): |
971 """ |
1050 """ |
972 Private slot called in to enter Whats This mode. |
1051 Private slot called in to enter Whats This mode. |
973 """ |
1052 """ |
974 QWhatsThis.enterWhatsThisMode() |
1053 QWhatsThis.enterWhatsThisMode() |
|
1054 |
|
1055 ################################################################## |
|
1056 ## Below are the main menu handling methods |
|
1057 ################################################################## |
|
1058 |
|
1059 def __createMenus(self): |
|
1060 """ |
|
1061 Private method to create the menus of the menu bar. |
|
1062 """ |
|
1063 self.__fileMenu = self.menuBar().addMenu(self.tr("&File")) |
|
1064 self.__fileMenu.setTearOffEnabled(True) |
|
1065 ## self.__fileMenu.addAction(self.newAct) |
|
1066 ## self.__fileMenu.addSeparator() |
|
1067 self.__fileMenu.addAction(self.restartAct) |
|
1068 self.__fileMenu.addAction(self.clearRestartAct) |
|
1069 self.__fileMenu.addSeparator() |
|
1070 self.__fileMenu.addAction(self.exitAct) |
|
1071 |
|
1072 self.__editMenu = self.menuBar().addMenu(self.tr("&Edit")) |
|
1073 self.__editMenu.setTearOffEnabled(True) |
|
1074 self.__editMenu.addAction(self.cutAct) |
|
1075 self.__editMenu.addAction(self.copyAct) |
|
1076 self.__editMenu.addAction(self.pasteAct) |
|
1077 self.__editMenu.addAction(self.clearAct) |
|
1078 self.__editMenu.addSeparator() |
|
1079 self.__editMenu.addAction(self.searchAct) |
|
1080 self.__editMenu.addAction(self.searchNextAct) |
|
1081 self.__editMenu.addAction(self.searchPrevAct) |
|
1082 |
|
1083 self.__viewMenu = self.menuBar().addMenu(self.tr("&View")) |
|
1084 self.__viewMenu.setTearOffEnabled(True) |
|
1085 self.__viewMenu.addAction(self.zoomInAct) |
|
1086 self.__viewMenu.addAction(self.zoomOutAct) |
|
1087 self.__viewMenu.addAction(self.zoomResetAct) |
|
1088 self.__viewMenu.addAction(self.zoomToAct) |
|
1089 |
|
1090 self.__historyMenu = self.menuBar().addMenu(self.tr("Histor&y")) |
|
1091 self.__historyMenu.setTearOffEnabled(True) |
|
1092 self.__historyMenu.addAction(self.selectHistoryAct) |
|
1093 self.__historyMenu.addAction(self.showHistoryAct) |
|
1094 self.__historyMenu.addAction(self.clearHistoryAct) |
|
1095 |
|
1096 self.__startMenu = self.menuBar().addMenu(self.tr("&Start")) |
|
1097 self.__startMenu.aboutToShow.connect(self.__showLanguageMenu) |
|
1098 self.__startMenu.triggered.connect(self.__startShell) |
|
1099 |
|
1100 self.menuBar().addSeparator() |
|
1101 |
|
1102 self.__helpMenu = self.menuBar().addMenu(self.tr("&Help")) |
|
1103 self.__helpMenu.setTearOffEnabled(True) |
|
1104 self.__helpMenu.addAction(self.aboutAct) |
|
1105 self.__helpMenu.addAction(self.aboutQtAct) |
|
1106 self.__helpMenu.addSeparator() |
|
1107 self.__helpMenu.addAction(self.whatsThisAct) |
|
1108 |
|
1109 def __showLanguageMenu(self): |
|
1110 """ |
|
1111 Private slot to prepare the language menu. |
|
1112 """ |
|
1113 self.__startMenu.clear() |
|
1114 clientLanguages = self.__debugServer.getSupportedLanguages( |
|
1115 shellOnly=True) |
|
1116 for language in sorted(clientLanguages): |
|
1117 act = self.__startMenu.addAction(language) |
|
1118 act.setData(language) |
|
1119 |
|
1120 def __startShell(self, action): |
|
1121 """ |
|
1122 Private slot to start a shell according to the action triggered. |
|
1123 |
|
1124 @param action menu action that was triggered (QAction) |
|
1125 """ |
|
1126 language = action.data() |
|
1127 self.__debugServer.startClient(False, language) |
|
1128 |
|
1129 ################################################################## |
|
1130 ## Below are the toolbar handling methods |
|
1131 ################################################################## |
|
1132 |
|
1133 def __createToolBars(self): |
|
1134 """ |
|
1135 Private method to create the various toolbars. |
|
1136 """ |
|
1137 filetb = self.addToolBar(self.tr("File")) |
|
1138 filetb.setIconSize(UI.Config.ToolBarIconSize) |
|
1139 ## filetb.addAction(self.newAct) |
|
1140 filetb.addSeparator() |
|
1141 filetb.addAction(self.restartAct) |
|
1142 filetb.addAction(self.clearRestartAct) |
|
1143 filetb.addSeparator() |
|
1144 filetb.addAction(self.exitAct) |
|
1145 |
|
1146 edittb = self.addToolBar(self.tr("Edit")) |
|
1147 edittb.setIconSize(UI.Config.ToolBarIconSize) |
|
1148 edittb.addAction(self.cutAct) |
|
1149 edittb.addAction(self.copyAct) |
|
1150 edittb.addAction(self.pasteAct) |
|
1151 edittb.addAction(self.clearAct) |
|
1152 |
|
1153 findtb = self.addToolBar(self.tr("Find")) |
|
1154 findtb.setIconSize(UI.Config.ToolBarIconSize) |
|
1155 findtb.addAction(self.searchAct) |
|
1156 findtb.addAction(self.searchNextAct) |
|
1157 findtb.addAction(self.searchPrevAct) |
|
1158 |
|
1159 viewtb = self.addToolBar(self.tr("View")) |
|
1160 viewtb.setIconSize(UI.Config.ToolBarIconSize) |
|
1161 viewtb.addAction(self.zoomInAct) |
|
1162 viewtb.addAction(self.zoomOutAct) |
|
1163 viewtb.addAction(self.zoomResetAct) |
|
1164 viewtb.addAction(self.zoomToAct) |
|
1165 |
|
1166 historytb = self.addToolBar(self.tr("History")) |
|
1167 historytb.setIconSize(UI.Config.ToolBarIconSize) |
|
1168 historytb.addAction(self.showHistoryAct) |
|
1169 historytb.addAction(self.clearHistoryAct) |
|
1170 |
|
1171 helptb = self.addToolBar(self.tr("Help")) |
|
1172 helptb.setIconSize(UI.Config.ToolBarIconSize) |
|
1173 helptb.addAction(self.whatsThisAct) |
975 |
1174 |
976 ################################################################## |
1175 ################################################################## |
977 ## Below are the status bar handling methods |
1176 ## Below are the status bar handling methods |
978 ################################################################## |
1177 ################################################################## |
979 |
1178 |