12 from PyQt6.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper, QProcess |
12 from PyQt6.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper, QProcess |
13 from PyQt6.QtGui import QKeySequence, QAction |
13 from PyQt6.QtGui import QKeySequence, QAction |
14 from PyQt6.QtWidgets import QWidget, QVBoxLayout, QApplication, QWhatsThis, QDialog |
14 from PyQt6.QtWidgets import QWidget, QVBoxLayout, QApplication, QWhatsThis, QDialog |
15 from PyQt6.Qsci import QsciScintilla |
15 from PyQt6.Qsci import QsciScintilla |
16 |
16 |
17 from EricWidgets.EricMainWindow import EricMainWindow |
17 from eric7.EricWidgets.EricMainWindow import EricMainWindow |
18 from EricGui.EricAction import EricAction, createActionGroup |
18 from eric7.EricGui.EricAction import EricAction, createActionGroup |
19 from EricWidgets.EricApplication import ericApp |
19 from eric7.EricWidgets.EricApplication import ericApp |
20 from EricWidgets.EricZoomWidget import EricZoomWidget |
20 from eric7.EricWidgets.EricZoomWidget import EricZoomWidget |
21 from EricWidgets import EricMessageBox |
21 from eric7.EricWidgets import EricMessageBox |
22 |
22 |
23 import UI.Config |
23 from eric7.EricGui import EricPixmapCache |
24 import UI.PixmapCache |
24 from eric7.UI import Config |
25 import Preferences |
25 from eric7 import Preferences |
26 |
26 |
27 from Globals import isMacPlatform, getPythonExecutable |
27 from eric7.Globals import isMacPlatform, getPythonExecutable |
28 |
28 |
29 from .Shell import Shell |
29 from .Shell import Shell |
30 from .APIsManager import APIsManager |
30 from .APIsManager import APIsManager |
31 |
31 |
32 from Debugger.DebugServer import DebugServer |
32 from eric7.Debugger.DebugServer import DebugServer |
33 from UI.SearchWidget import SearchWidget |
33 from eric7.UI.SearchWidget import SearchWidget |
34 from VirtualEnv.VirtualenvManager import VirtualenvManager |
34 from eric7.VirtualEnv.VirtualenvManager import VirtualenvManager |
35 |
35 |
36 from eric7config import getConfig |
36 from eric7config import getConfig |
37 |
37 |
38 |
38 |
39 class ShellWindow(EricMainWindow): |
39 class ShellWindow(EricMainWindow): |
240 self.exitAct.setMenuRole(QAction.MenuRole.QuitRole) |
240 self.exitAct.setMenuRole(QAction.MenuRole.QuitRole) |
241 self.fileActions.append(self.exitAct) |
241 self.fileActions.append(self.exitAct) |
242 |
242 |
243 self.newWindowAct = EricAction( |
243 self.newWindowAct = EricAction( |
244 self.tr("New Window"), |
244 self.tr("New Window"), |
245 UI.PixmapCache.getIcon("newWindow"), |
245 EricPixmapCache.getIcon("newWindow"), |
246 self.tr("New &Window"), |
246 self.tr("New &Window"), |
247 QKeySequence(self.tr("Ctrl+Shift+N", "File|New Window")), |
247 QKeySequence(self.tr("Ctrl+Shift+N", "File|New Window")), |
248 0, |
248 0, |
249 self, |
249 self, |
250 "new_window", |
250 "new_window", |
279 self.restartAct.triggered.connect(self.__shell.doRestart) |
279 self.restartAct.triggered.connect(self.__shell.doRestart) |
280 self.fileActions.append(self.restartAct) |
280 self.fileActions.append(self.restartAct) |
281 |
281 |
282 self.clearRestartAct = EricAction( |
282 self.clearRestartAct = EricAction( |
283 self.tr("Restart and Clear"), |
283 self.tr("Restart and Clear"), |
284 UI.PixmapCache.getIcon("restartDelete"), |
284 EricPixmapCache.getIcon("restartDelete"), |
285 self.tr("Restart and Clear"), |
285 self.tr("Restart and Clear"), |
286 Qt.Key.Key_F4, |
286 Qt.Key.Key_F4, |
287 0, |
287 0, |
288 self, |
288 self, |
289 "shell_clear_restart", |
289 "shell_clear_restart", |
301 self.clearRestartAct.triggered.connect(self.__shell.doClearRestart) |
301 self.clearRestartAct.triggered.connect(self.__shell.doClearRestart) |
302 self.fileActions.append(self.clearRestartAct) |
302 self.fileActions.append(self.clearRestartAct) |
303 |
303 |
304 self.saveContentsAct = EricAction( |
304 self.saveContentsAct = EricAction( |
305 self.tr("Save Contents"), |
305 self.tr("Save Contents"), |
306 UI.PixmapCache.getIcon("fileSave"), |
306 EricPixmapCache.getIcon("fileSave"), |
307 self.tr("Save Contents..."), |
307 self.tr("Save Contents..."), |
308 QKeySequence( |
308 QKeySequence( |
309 QCoreApplication.translate("ViewManager", "Ctrl+S", "File|Save") |
309 QCoreApplication.translate("ViewManager", "Ctrl+S", "File|Save") |
310 ), |
310 ), |
311 0, |
311 0, |
332 self.editActGrp = createActionGroup(self) |
332 self.editActGrp = createActionGroup(self) |
333 self.copyActGrp = createActionGroup(self.editActGrp) |
333 self.copyActGrp = createActionGroup(self.editActGrp) |
334 |
334 |
335 self.cutAct = EricAction( |
335 self.cutAct = EricAction( |
336 QCoreApplication.translate("ViewManager", "Cut"), |
336 QCoreApplication.translate("ViewManager", "Cut"), |
337 UI.PixmapCache.getIcon("editCut"), |
337 EricPixmapCache.getIcon("editCut"), |
338 QCoreApplication.translate("ViewManager", "Cu&t"), |
338 QCoreApplication.translate("ViewManager", "Cu&t"), |
339 QKeySequence( |
339 QKeySequence( |
340 QCoreApplication.translate("ViewManager", "Ctrl+X", "Edit|Cut") |
340 QCoreApplication.translate("ViewManager", "Ctrl+X", "Edit|Cut") |
341 ), |
341 ), |
342 QKeySequence( |
342 QKeySequence( |
356 self.cutAct.triggered.connect(self.__shell.cut) |
356 self.cutAct.triggered.connect(self.__shell.cut) |
357 self.editActions.append(self.cutAct) |
357 self.editActions.append(self.cutAct) |
358 |
358 |
359 self.copyAct = EricAction( |
359 self.copyAct = EricAction( |
360 QCoreApplication.translate("ViewManager", "Copy"), |
360 QCoreApplication.translate("ViewManager", "Copy"), |
361 UI.PixmapCache.getIcon("editCopy"), |
361 EricPixmapCache.getIcon("editCopy"), |
362 QCoreApplication.translate("ViewManager", "&Copy"), |
362 QCoreApplication.translate("ViewManager", "&Copy"), |
363 QKeySequence( |
363 QKeySequence( |
364 QCoreApplication.translate("ViewManager", "Ctrl+C", "Edit|Copy") |
364 QCoreApplication.translate("ViewManager", "Ctrl+C", "Edit|Copy") |
365 ), |
365 ), |
366 QKeySequence( |
366 QKeySequence( |
380 self.copyAct.triggered.connect(self.__shell.copy) |
380 self.copyAct.triggered.connect(self.__shell.copy) |
381 self.editActions.append(self.copyAct) |
381 self.editActions.append(self.copyAct) |
382 |
382 |
383 self.pasteAct = EricAction( |
383 self.pasteAct = EricAction( |
384 QCoreApplication.translate("ViewManager", "Paste"), |
384 QCoreApplication.translate("ViewManager", "Paste"), |
385 UI.PixmapCache.getIcon("editPaste"), |
385 EricPixmapCache.getIcon("editPaste"), |
386 QCoreApplication.translate("ViewManager", "&Paste"), |
386 QCoreApplication.translate("ViewManager", "&Paste"), |
387 QKeySequence( |
387 QKeySequence( |
388 QCoreApplication.translate("ViewManager", "Ctrl+V", "Edit|Paste") |
388 QCoreApplication.translate("ViewManager", "Ctrl+V", "Edit|Paste") |
389 ), |
389 ), |
390 QKeySequence( |
390 QKeySequence( |
405 self.pasteAct.triggered.connect(self.__shell.paste) |
405 self.pasteAct.triggered.connect(self.__shell.paste) |
406 self.editActions.append(self.pasteAct) |
406 self.editActions.append(self.pasteAct) |
407 |
407 |
408 self.clearAct = EricAction( |
408 self.clearAct = EricAction( |
409 QCoreApplication.translate("ViewManager", "Clear"), |
409 QCoreApplication.translate("ViewManager", "Clear"), |
410 UI.PixmapCache.getIcon("editDelete"), |
410 EricPixmapCache.getIcon("editDelete"), |
411 QCoreApplication.translate("ViewManager", "Clear"), |
411 QCoreApplication.translate("ViewManager", "Clear"), |
412 QKeySequence( |
412 QKeySequence( |
413 QCoreApplication.translate("ViewManager", "Alt+Shift+C", "Edit|Clear") |
413 QCoreApplication.translate("ViewManager", "Alt+Shift+C", "Edit|Clear") |
414 ), |
414 ), |
415 0, |
415 0, |
926 """ |
926 """ |
927 self.searchActGrp = createActionGroup(self) |
927 self.searchActGrp = createActionGroup(self) |
928 |
928 |
929 self.searchAct = EricAction( |
929 self.searchAct = EricAction( |
930 QCoreApplication.translate("ViewManager", "Search"), |
930 QCoreApplication.translate("ViewManager", "Search"), |
931 UI.PixmapCache.getIcon("find"), |
931 EricPixmapCache.getIcon("find"), |
932 QCoreApplication.translate("ViewManager", "&Search..."), |
932 QCoreApplication.translate("ViewManager", "&Search..."), |
933 QKeySequence( |
933 QKeySequence( |
934 QCoreApplication.translate("ViewManager", "Ctrl+F", "Search|Search") |
934 QCoreApplication.translate("ViewManager", "Ctrl+F", "Search|Search") |
935 ), |
935 ), |
936 0, |
936 0, |
952 self.searchAct.triggered.connect(self.__showFind) |
952 self.searchAct.triggered.connect(self.__showFind) |
953 self.searchActions.append(self.searchAct) |
953 self.searchActions.append(self.searchAct) |
954 |
954 |
955 self.searchNextAct = EricAction( |
955 self.searchNextAct = EricAction( |
956 QCoreApplication.translate("ViewManager", "Search next"), |
956 QCoreApplication.translate("ViewManager", "Search next"), |
957 UI.PixmapCache.getIcon("findNext"), |
957 EricPixmapCache.getIcon("findNext"), |
958 QCoreApplication.translate("ViewManager", "Search &next"), |
958 QCoreApplication.translate("ViewManager", "Search &next"), |
959 QKeySequence( |
959 QKeySequence( |
960 QCoreApplication.translate("ViewManager", "F3", "Search|Search next") |
960 QCoreApplication.translate("ViewManager", "F3", "Search|Search next") |
961 ), |
961 ), |
962 0, |
962 0, |
980 ) |
980 ) |
981 self.searchActions.append(self.searchNextAct) |
981 self.searchActions.append(self.searchNextAct) |
982 |
982 |
983 self.searchPrevAct = EricAction( |
983 self.searchPrevAct = EricAction( |
984 QCoreApplication.translate("ViewManager", "Search previous"), |
984 QCoreApplication.translate("ViewManager", "Search previous"), |
985 UI.PixmapCache.getIcon("findPrev"), |
985 EricPixmapCache.getIcon("findPrev"), |
986 QCoreApplication.translate("ViewManager", "Search &previous"), |
986 QCoreApplication.translate("ViewManager", "Search &previous"), |
987 QKeySequence( |
987 QKeySequence( |
988 QCoreApplication.translate( |
988 QCoreApplication.translate( |
989 "ViewManager", "Shift+F3", "Search|Search previous" |
989 "ViewManager", "Shift+F3", "Search|Search previous" |
990 ) |
990 ) |
1019 """ |
1019 """ |
1020 self.viewActGrp = createActionGroup(self) |
1020 self.viewActGrp = createActionGroup(self) |
1021 |
1021 |
1022 self.zoomInAct = EricAction( |
1022 self.zoomInAct = EricAction( |
1023 QCoreApplication.translate("ViewManager", "Zoom in"), |
1023 QCoreApplication.translate("ViewManager", "Zoom in"), |
1024 UI.PixmapCache.getIcon("zoomIn"), |
1024 EricPixmapCache.getIcon("zoomIn"), |
1025 QCoreApplication.translate("ViewManager", "Zoom &in"), |
1025 QCoreApplication.translate("ViewManager", "Zoom &in"), |
1026 QKeySequence( |
1026 QKeySequence( |
1027 QCoreApplication.translate("ViewManager", "Ctrl++", "View|Zoom in") |
1027 QCoreApplication.translate("ViewManager", "Ctrl++", "View|Zoom in") |
1028 ), |
1028 ), |
1029 QKeySequence( |
1029 QKeySequence( |
1045 self.zoomInAct.triggered.connect(self.__zoomIn) |
1045 self.zoomInAct.triggered.connect(self.__zoomIn) |
1046 self.viewActions.append(self.zoomInAct) |
1046 self.viewActions.append(self.zoomInAct) |
1047 |
1047 |
1048 self.zoomOutAct = EricAction( |
1048 self.zoomOutAct = EricAction( |
1049 QCoreApplication.translate("ViewManager", "Zoom out"), |
1049 QCoreApplication.translate("ViewManager", "Zoom out"), |
1050 UI.PixmapCache.getIcon("zoomOut"), |
1050 EricPixmapCache.getIcon("zoomOut"), |
1051 QCoreApplication.translate("ViewManager", "Zoom &out"), |
1051 QCoreApplication.translate("ViewManager", "Zoom &out"), |
1052 QKeySequence( |
1052 QKeySequence( |
1053 QCoreApplication.translate("ViewManager", "Ctrl+-", "View|Zoom out") |
1053 QCoreApplication.translate("ViewManager", "Ctrl+-", "View|Zoom out") |
1054 ), |
1054 ), |
1055 QKeySequence( |
1055 QKeySequence( |
1071 self.zoomOutAct.triggered.connect(self.__zoomOut) |
1071 self.zoomOutAct.triggered.connect(self.__zoomOut) |
1072 self.viewActions.append(self.zoomOutAct) |
1072 self.viewActions.append(self.zoomOutAct) |
1073 |
1073 |
1074 self.zoomResetAct = EricAction( |
1074 self.zoomResetAct = EricAction( |
1075 QCoreApplication.translate("ViewManager", "Zoom reset"), |
1075 QCoreApplication.translate("ViewManager", "Zoom reset"), |
1076 UI.PixmapCache.getIcon("zoomReset"), |
1076 EricPixmapCache.getIcon("zoomReset"), |
1077 QCoreApplication.translate("ViewManager", "Zoom &reset"), |
1077 QCoreApplication.translate("ViewManager", "Zoom &reset"), |
1078 QKeySequence( |
1078 QKeySequence( |
1079 QCoreApplication.translate("ViewManager", "Ctrl+0", "View|Zoom reset") |
1079 QCoreApplication.translate("ViewManager", "Ctrl+0", "View|Zoom reset") |
1080 ), |
1080 ), |
1081 0, |
1081 0, |
1136 self.showHistoryAct.setStatusTip(self.tr("Show the shell history in a dialog")) |
1136 self.showHistoryAct.setStatusTip(self.tr("Show the shell history in a dialog")) |
1137 self.showHistoryAct.triggered.connect(self.__shell.showHistory) |
1137 self.showHistoryAct.triggered.connect(self.__shell.showHistory) |
1138 |
1138 |
1139 self.clearHistoryAct = EricAction( |
1139 self.clearHistoryAct = EricAction( |
1140 self.tr("Clear History"), |
1140 self.tr("Clear History"), |
1141 UI.PixmapCache.getIcon("historyClear"), |
1141 EricPixmapCache.getIcon("historyClear"), |
1142 self.tr("&Clear History..."), |
1142 self.tr("&Clear History..."), |
1143 0, |
1143 0, |
1144 0, |
1144 0, |
1145 self, |
1145 self, |
1146 "shell_clear_history", |
1146 "shell_clear_history", |
1193 self.aboutQtAct.triggered.connect(self.__aboutQt) |
1193 self.aboutQtAct.triggered.connect(self.__aboutQt) |
1194 self.helpActions.append(self.aboutQtAct) |
1194 self.helpActions.append(self.aboutQtAct) |
1195 |
1195 |
1196 self.whatsThisAct = EricAction( |
1196 self.whatsThisAct = EricAction( |
1197 self.tr("What's This?"), |
1197 self.tr("What's This?"), |
1198 UI.PixmapCache.getIcon("whatsThis"), |
1198 EricPixmapCache.getIcon("whatsThis"), |
1199 self.tr("&What's This?"), |
1199 self.tr("&What's This?"), |
1200 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), |
1200 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), |
1201 0, |
1201 0, |
1202 self, |
1202 self, |
1203 "help_help_whats_this", |
1203 "help_help_whats_this", |
1454 def __createToolBars(self): |
1454 def __createToolBars(self): |
1455 """ |
1455 """ |
1456 Private method to create the various toolbars. |
1456 Private method to create the various toolbars. |
1457 """ |
1457 """ |
1458 filetb = self.addToolBar(self.tr("File")) |
1458 filetb = self.addToolBar(self.tr("File")) |
1459 filetb.setIconSize(UI.Config.ToolBarIconSize) |
1459 filetb.setIconSize(Config.ToolBarIconSize) |
1460 filetb.addAction(self.newWindowAct) |
1460 filetb.addAction(self.newWindowAct) |
1461 filetb.addSeparator() |
1461 filetb.addSeparator() |
1462 filetb.addAction(self.restartAct) |
1462 filetb.addAction(self.restartAct) |
1463 filetb.addAction(self.clearRestartAct) |
1463 filetb.addAction(self.clearRestartAct) |
1464 filetb.addSeparator() |
1464 filetb.addSeparator() |
1465 filetb.addAction(self.saveContentsAct) |
1465 filetb.addAction(self.saveContentsAct) |
1466 filetb.addSeparator() |
1466 filetb.addSeparator() |
1467 filetb.addAction(self.exitAct) |
1467 filetb.addAction(self.exitAct) |
1468 |
1468 |
1469 edittb = self.addToolBar(self.tr("Edit")) |
1469 edittb = self.addToolBar(self.tr("Edit")) |
1470 edittb.setIconSize(UI.Config.ToolBarIconSize) |
1470 edittb.setIconSize(Config.ToolBarIconSize) |
1471 edittb.addAction(self.cutAct) |
1471 edittb.addAction(self.cutAct) |
1472 edittb.addAction(self.copyAct) |
1472 edittb.addAction(self.copyAct) |
1473 edittb.addAction(self.pasteAct) |
1473 edittb.addAction(self.pasteAct) |
1474 edittb.addAction(self.clearAct) |
1474 edittb.addAction(self.clearAct) |
1475 |
1475 |
1476 findtb = self.addToolBar(self.tr("Find")) |
1476 findtb = self.addToolBar(self.tr("Find")) |
1477 findtb.setIconSize(UI.Config.ToolBarIconSize) |
1477 findtb.setIconSize(Config.ToolBarIconSize) |
1478 findtb.addAction(self.searchAct) |
1478 findtb.addAction(self.searchAct) |
1479 findtb.addAction(self.searchNextAct) |
1479 findtb.addAction(self.searchNextAct) |
1480 findtb.addAction(self.searchPrevAct) |
1480 findtb.addAction(self.searchPrevAct) |
1481 |
1481 |
1482 viewtb = self.addToolBar(self.tr("View")) |
1482 viewtb = self.addToolBar(self.tr("View")) |
1483 viewtb.setIconSize(UI.Config.ToolBarIconSize) |
1483 viewtb.setIconSize(Config.ToolBarIconSize) |
1484 viewtb.addAction(self.zoomInAct) |
1484 viewtb.addAction(self.zoomInAct) |
1485 viewtb.addAction(self.zoomOutAct) |
1485 viewtb.addAction(self.zoomOutAct) |
1486 viewtb.addAction(self.zoomResetAct) |
1486 viewtb.addAction(self.zoomResetAct) |
1487 viewtb.addAction(self.zoomToAct) |
1487 viewtb.addAction(self.zoomToAct) |
1488 |
1488 |
1489 self.__historyToolbar = self.addToolBar(self.tr("History")) |
1489 self.__historyToolbar = self.addToolBar(self.tr("History")) |
1490 self.__historyToolbar.setIconSize(UI.Config.ToolBarIconSize) |
1490 self.__historyToolbar.setIconSize(Config.ToolBarIconSize) |
1491 self.__historyToolbar.addAction(self.showHistoryAct) |
1491 self.__historyToolbar.addAction(self.showHistoryAct) |
1492 self.__historyToolbar.addAction(self.clearHistoryAct) |
1492 self.__historyToolbar.addAction(self.clearHistoryAct) |
1493 self.__historyToolbar.setEnabled(self.__shell.isHistoryEnabled()) |
1493 self.__historyToolbar.setEnabled(self.__shell.isHistoryEnabled()) |
1494 |
1494 |
1495 helptb = self.addToolBar(self.tr("Help")) |
1495 helptb = self.addToolBar(self.tr("Help")) |
1496 helptb.setIconSize(UI.Config.ToolBarIconSize) |
1496 helptb.setIconSize(Config.ToolBarIconSize) |
1497 helptb.addAction(self.whatsThisAct) |
1497 helptb.addAction(self.whatsThisAct) |
1498 |
1498 |
1499 ################################################################## |
1499 ################################################################## |
1500 ## Below are the status bar handling methods |
1500 ## Below are the status bar handling methods |
1501 ################################################################## |
1501 ################################################################## |
1506 """ |
1506 """ |
1507 self.__statusBar = self.statusBar() |
1507 self.__statusBar = self.statusBar() |
1508 self.__statusBar.setSizeGripEnabled(True) |
1508 self.__statusBar.setSizeGripEnabled(True) |
1509 |
1509 |
1510 self.__sbZoom = EricZoomWidget( |
1510 self.__sbZoom = EricZoomWidget( |
1511 UI.PixmapCache.getPixmap("zoomOut"), |
1511 EricPixmapCache.getPixmap("zoomOut"), |
1512 UI.PixmapCache.getPixmap("zoomIn"), |
1512 EricPixmapCache.getPixmap("zoomIn"), |
1513 UI.PixmapCache.getPixmap("zoomReset"), |
1513 EricPixmapCache.getPixmap("zoomReset"), |
1514 self.__statusBar, |
1514 self.__statusBar, |
1515 ) |
1515 ) |
1516 self.__statusBar.addPermanentWidget(self.__sbZoom) |
1516 self.__statusBar.addPermanentWidget(self.__sbZoom) |
1517 self.__sbZoom.setWhatsThis( |
1517 self.__sbZoom.setWhatsThis( |
1518 self.tr("""<p>This part of the status bar allows zooming the shell.</p>""") |
1518 self.tr("""<p>This part of the status bar allows zooming the shell.</p>""") |