|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a stand alone shell window. |
|
8 """ |
|
9 |
|
10 import os |
|
11 |
|
12 from PyQt6.QtCore import ( |
|
13 Qt, QCoreApplication, QPoint, QSize, QSignalMapper, QProcess |
|
14 ) |
|
15 from PyQt6.QtGui import QKeySequence, QAction |
|
16 from PyQt6.QtWidgets import ( |
|
17 QWidget, QVBoxLayout, QApplication, QWhatsThis, QDialog |
|
18 ) |
|
19 from PyQt6.Qsci import QsciScintilla |
|
20 |
|
21 from EricWidgets.EricMainWindow import EricMainWindow |
|
22 from EricGui.EricAction import EricAction, createActionGroup |
|
23 from EricWidgets.EricApplication import ericApp |
|
24 from EricWidgets.EricZoomWidget import EricZoomWidget |
|
25 from EricWidgets import EricMessageBox |
|
26 |
|
27 import UI.Config |
|
28 import UI.PixmapCache |
|
29 import Preferences |
|
30 |
|
31 from Globals import isMacPlatform, getPythonExecutable |
|
32 |
|
33 from .Shell import Shell |
|
34 from .APIsManager import APIsManager |
|
35 |
|
36 from Debugger.DebugServer import DebugServer |
|
37 from UI.SearchWidget import SearchWidget |
|
38 from VirtualEnv.VirtualenvManager import VirtualenvManager |
|
39 |
|
40 from eric7config import getConfig |
|
41 |
|
42 |
|
43 class ShellWindow(EricMainWindow): |
|
44 """ |
|
45 Class implementing a stand alone shell window. |
|
46 """ |
|
47 def __init__(self, originalPathString, parent=None, name=None): |
|
48 """ |
|
49 Constructor |
|
50 |
|
51 @param originalPathString original PATH environment variable |
|
52 @type str |
|
53 @param parent reference to the parent widget |
|
54 @type QWidget |
|
55 @param name object name of the window |
|
56 @type str |
|
57 """ |
|
58 super().__init__(parent) |
|
59 if name is not None: |
|
60 self.setObjectName(name) |
|
61 self.setWindowIcon(UI.PixmapCache.getIcon("shell")) |
|
62 self.setWindowTitle(self.tr("eric Shell")) |
|
63 |
|
64 self.setStyle(Preferences.getUI("Style"), |
|
65 Preferences.getUI("StyleSheet")) |
|
66 |
|
67 self.__lastDebuggerId = "" |
|
68 |
|
69 # initialize the APIs manager |
|
70 self.__apisManager = APIsManager(parent=self) |
|
71 |
|
72 # initialize the debug server and shell widgets |
|
73 self.__debugServer = DebugServer(originalPathString, |
|
74 preventPassiveDebugging=True, |
|
75 parent=self) |
|
76 self.__debugServer.clientDebuggerId.connect(self.__clientDebuggerId) |
|
77 |
|
78 self.__shell = Shell(self.__debugServer, self, None, True, self) |
|
79 self.__shell.registerDebuggerIdMethod(self.getDebuggerId) |
|
80 |
|
81 self.__searchWidget = SearchWidget(self.__shell, self, showLine=True) |
|
82 |
|
83 centralWidget = QWidget() |
|
84 layout = QVBoxLayout() |
|
85 layout.setContentsMargins(1, 1, 1, 1) |
|
86 layout.addWidget(self.__shell) |
|
87 layout.addWidget(self.__searchWidget) |
|
88 centralWidget.setLayout(layout) |
|
89 self.setCentralWidget(centralWidget) |
|
90 self.__searchWidget.hide() |
|
91 |
|
92 self.__searchWidget.searchNext.connect(self.__shell.searchNext) |
|
93 self.__searchWidget.searchPrevious.connect(self.__shell.searchPrev) |
|
94 self.__shell.searchStringFound.connect( |
|
95 self.__searchWidget.searchStringFound) |
|
96 |
|
97 self.__shell.zoomValueChanged.connect(self.__zoomValueChanged) |
|
98 |
|
99 self.__createActions() |
|
100 self.__createMenus() |
|
101 self.__createToolBars() |
|
102 self.__createStatusBar() |
|
103 |
|
104 self.__readSettings() |
|
105 |
|
106 self.__shell.historyStyleChanged.connect(self.__historyStyleChanged) |
|
107 |
|
108 # Generate the virtual environment manager and register it |
|
109 self.virtualenvManager = VirtualenvManager(self) |
|
110 ericApp().registerObject("VirtualEnvManager", self.virtualenvManager) |
|
111 |
|
112 self.__shell.virtualEnvironmentChanged.connect( |
|
113 self.__virtualEnvironmentChanged) |
|
114 |
|
115 # now start the debug client with the most recently used virtual |
|
116 # environment |
|
117 self.__debugServer.startClient( |
|
118 False, venvName=Preferences.getShell("LastVirtualEnvironment") |
|
119 ) |
|
120 |
|
121 # set the keyboard input interval |
|
122 interval = Preferences.getUI("KeyboardInputInterval") |
|
123 if interval > 0: |
|
124 QApplication.setKeyboardInputInterval(interval) |
|
125 |
|
126 def closeEvent(self, event): |
|
127 """ |
|
128 Protected method to handle the close event. |
|
129 |
|
130 @param event close event |
|
131 @type QCloseEvent |
|
132 """ |
|
133 self.__writeSettings() |
|
134 self.__debugServer.shutdownServer() |
|
135 self.__shell.closeShell() |
|
136 Preferences.syncPreferences() |
|
137 |
|
138 event.accept() |
|
139 |
|
140 def __clientDebuggerId(self, debuggerId): |
|
141 """ |
|
142 Private slot to receive the ID of a newly connected debugger backend. |
|
143 |
|
144 @param debuggerId ID of a newly connected debugger backend |
|
145 @type str |
|
146 """ |
|
147 self.__lastDebuggerId = debuggerId |
|
148 |
|
149 def getDebuggerId(self): |
|
150 """ |
|
151 Public method to get the most recently registered debugger ID. |
|
152 |
|
153 @return debugger ID |
|
154 @rtype str |
|
155 """ |
|
156 return self.__lastDebuggerId |
|
157 |
|
158 ################################################################## |
|
159 ## Below are API handling methods |
|
160 ################################################################## |
|
161 |
|
162 def getAPIsManager(self): |
|
163 """ |
|
164 Public method to get a reference to the APIs manager. |
|
165 |
|
166 @return the APIs manager object (eric7.QScintilla.APIsManager) |
|
167 """ |
|
168 return self.__apisManager |
|
169 |
|
170 ################################################################## |
|
171 ## Below are action related methods |
|
172 ################################################################## |
|
173 |
|
174 def __readShortcut(self, act, category): |
|
175 """ |
|
176 Private function to read a single keyboard shortcut from the settings. |
|
177 |
|
178 @param act reference to the action object |
|
179 @type EricAction |
|
180 @param category category the action belongs to |
|
181 @type str |
|
182 """ |
|
183 if act.objectName(): |
|
184 accel = Preferences.getSettings().value( |
|
185 "Shortcuts/{0}/{1}/Accel".format(category, act.objectName())) |
|
186 if accel is not None: |
|
187 act.setShortcut(QKeySequence(accel)) |
|
188 accel = Preferences.getSettings().value( |
|
189 "Shortcuts/{0}/{1}/AltAccel".format( |
|
190 category, act.objectName())) |
|
191 if accel is not None: |
|
192 act.setAlternateShortcut(QKeySequence(accel), removeEmpty=True) |
|
193 |
|
194 def __createActions(self): |
|
195 """ |
|
196 Private method to create the actions. |
|
197 """ |
|
198 self.fileActions = [] |
|
199 self.editActions = [] |
|
200 self.searchActions = [] |
|
201 self.viewActions = [] |
|
202 self.helpActions = [] |
|
203 |
|
204 self.viewActGrp = createActionGroup(self) |
|
205 |
|
206 self.__createFileActions() |
|
207 self.__createEditActions() |
|
208 self.__createSearchActions() |
|
209 self.__createViewActions() |
|
210 self.__createHelpActions() |
|
211 self.__createHistoryActions() |
|
212 |
|
213 # read the keyboard shortcuts and make them identical to the main |
|
214 # eric shortcuts |
|
215 for act in self.helpActions: |
|
216 self.__readShortcut(act, "General") |
|
217 for act in self.editActions: |
|
218 self.__readShortcut(act, "Edit") |
|
219 for act in self.fileActions: |
|
220 self.__readShortcut(act, "View") |
|
221 for act in self.searchActions: |
|
222 self.__readShortcut(act, "Search") |
|
223 |
|
224 def __createFileActions(self): |
|
225 """ |
|
226 Private method defining the user interface actions for the file |
|
227 commands. |
|
228 """ |
|
229 self.exitAct = EricAction( |
|
230 self.tr('Quit'), |
|
231 UI.PixmapCache.getIcon("exit"), |
|
232 self.tr('&Quit'), |
|
233 QKeySequence(self.tr("Ctrl+Q", "File|Quit")), |
|
234 0, self, 'quit') |
|
235 self.exitAct.setStatusTip(self.tr('Quit the Shell')) |
|
236 self.exitAct.setWhatsThis(self.tr( |
|
237 """<b>Quit the Shell</b>""" |
|
238 """<p>This quits the Shell window.</p>""" |
|
239 )) |
|
240 self.exitAct.triggered.connect(self.quit) |
|
241 self.exitAct.setMenuRole(QAction.MenuRole.QuitRole) |
|
242 self.fileActions.append(self.exitAct) |
|
243 |
|
244 self.newWindowAct = EricAction( |
|
245 self.tr('New Window'), |
|
246 UI.PixmapCache.getIcon("newWindow"), |
|
247 self.tr('New &Window'), |
|
248 QKeySequence(self.tr("Ctrl+Shift+N", "File|New Window")), |
|
249 0, self, 'new_window') |
|
250 self.newWindowAct.setStatusTip(self.tr( |
|
251 'Open a new Shell window')) |
|
252 self.newWindowAct.setWhatsThis(self.tr( |
|
253 """<b>New Window</b>""" |
|
254 """<p>This opens a new instance of the Shell window.</p>""" |
|
255 )) |
|
256 self.newWindowAct.triggered.connect(self.__newWindow) |
|
257 self.fileActions.append(self.newWindowAct) |
|
258 |
|
259 self.restartAct = EricAction( |
|
260 self.tr('Restart'), |
|
261 UI.PixmapCache.getIcon("restart"), |
|
262 self.tr('Restart'), |
|
263 0, 0, self, 'shell_restart') |
|
264 self.restartAct.setStatusTip(self.tr( |
|
265 'Restart the shell')) |
|
266 self.restartAct.setWhatsThis(self.tr( |
|
267 """<b>Restart</b>""" |
|
268 """<p>Restart the shell for the currently selected""" |
|
269 """ environment.</p>""" |
|
270 )) |
|
271 self.restartAct.triggered.connect(self.__shell.doRestart) |
|
272 self.fileActions.append(self.restartAct) |
|
273 |
|
274 self.clearRestartAct = EricAction( |
|
275 self.tr('Restart and Clear'), |
|
276 UI.PixmapCache.getIcon("restartDelete"), |
|
277 self.tr('Restart and Clear'), |
|
278 Qt.Key.Key_F4, 0, self, 'shell_clear_restart') |
|
279 self.clearRestartAct.setStatusTip(self.tr( |
|
280 'Clear the window and restart the shell')) |
|
281 self.clearRestartAct.setWhatsThis(self.tr( |
|
282 """<b>Restart and Clear</b>""" |
|
283 """<p>Clear the shell window and restart the shell for the""" |
|
284 """ currently selected environment.</p>""" |
|
285 )) |
|
286 self.clearRestartAct.triggered.connect(self.__shell.doClearRestart) |
|
287 self.fileActions.append(self.clearRestartAct) |
|
288 |
|
289 self.saveContentsAct = EricAction( |
|
290 self.tr('Save Contents'), |
|
291 UI.PixmapCache.getIcon("fileSave"), |
|
292 self.tr('Save Contents...'), |
|
293 QKeySequence(QCoreApplication.translate( |
|
294 'ViewManager', "Ctrl+S", "File|Save")), |
|
295 0, self, 'vm_file_save') |
|
296 self.saveContentsAct.setStatusTip(self.tr( |
|
297 'Save the current contents of the shell to a file')) |
|
298 self.saveContentsAct.setWhatsThis(self.tr( |
|
299 """<b>Save Contents</b>""" |
|
300 """<p>Save the current contents of the shell to a file.</p>""" |
|
301 )) |
|
302 self.saveContentsAct.triggered.connect(self.__shell.saveContents) |
|
303 self.fileActions.append(self.saveContentsAct) |
|
304 |
|
305 def __createEditActions(self): |
|
306 """ |
|
307 Private method defining the user interface actions for the edit |
|
308 commands. |
|
309 """ |
|
310 self.editActGrp = createActionGroup(self) |
|
311 self.copyActGrp = createActionGroup(self.editActGrp) |
|
312 |
|
313 self.cutAct = EricAction( |
|
314 QCoreApplication.translate('ViewManager', 'Cut'), |
|
315 UI.PixmapCache.getIcon("editCut"), |
|
316 QCoreApplication.translate('ViewManager', 'Cu&t'), |
|
317 QKeySequence(QCoreApplication.translate( |
|
318 'ViewManager', "Ctrl+X", "Edit|Cut")), |
|
319 QKeySequence(QCoreApplication.translate( |
|
320 'ViewManager', "Shift+Del", "Edit|Cut")), |
|
321 self.copyActGrp, 'vm_edit_cut') |
|
322 self.cutAct.setStatusTip(QCoreApplication.translate( |
|
323 'ViewManager', 'Cut the selection')) |
|
324 self.cutAct.setWhatsThis(self.tr( |
|
325 """<b>Cut</b>""" |
|
326 """<p>Cut the selected text to the clipboard.</p>""" |
|
327 )) |
|
328 self.cutAct.triggered.connect(self.__shell.cut) |
|
329 self.editActions.append(self.cutAct) |
|
330 |
|
331 self.copyAct = EricAction( |
|
332 QCoreApplication.translate('ViewManager', 'Copy'), |
|
333 UI.PixmapCache.getIcon("editCopy"), |
|
334 QCoreApplication.translate('ViewManager', '&Copy'), |
|
335 QKeySequence(QCoreApplication.translate( |
|
336 'ViewManager', "Ctrl+C", "Edit|Copy")), |
|
337 QKeySequence(QCoreApplication.translate( |
|
338 'ViewManager', "Ctrl+Ins", "Edit|Copy")), |
|
339 self.copyActGrp, 'vm_edit_copy') |
|
340 self.copyAct.setStatusTip(QCoreApplication.translate( |
|
341 'ViewManager', 'Copy the selection')) |
|
342 self.copyAct.setWhatsThis(self.tr( |
|
343 """<b>Copy</b>""" |
|
344 """<p>Copy the selected text to the clipboard.</p>""" |
|
345 )) |
|
346 self.copyAct.triggered.connect(self.__shell.copy) |
|
347 self.editActions.append(self.copyAct) |
|
348 |
|
349 self.pasteAct = EricAction( |
|
350 QCoreApplication.translate('ViewManager', 'Paste'), |
|
351 UI.PixmapCache.getIcon("editPaste"), |
|
352 QCoreApplication.translate('ViewManager', '&Paste'), |
|
353 QKeySequence(QCoreApplication.translate( |
|
354 'ViewManager', "Ctrl+V", "Edit|Paste")), |
|
355 QKeySequence(QCoreApplication.translate( |
|
356 'ViewManager', "Shift+Ins", "Edit|Paste")), |
|
357 self.copyActGrp, 'vm_edit_paste') |
|
358 self.pasteAct.setStatusTip(QCoreApplication.translate( |
|
359 'ViewManager', 'Paste the last cut/copied text')) |
|
360 self.pasteAct.setWhatsThis(self.tr( |
|
361 """<b>Paste</b>""" |
|
362 """<p>Paste the last cut/copied text from the clipboard.</p>""" |
|
363 )) |
|
364 self.pasteAct.triggered.connect(self.__shell.paste) |
|
365 self.editActions.append(self.pasteAct) |
|
366 |
|
367 self.clearAct = EricAction( |
|
368 QCoreApplication.translate('ViewManager', 'Clear'), |
|
369 UI.PixmapCache.getIcon("editDelete"), |
|
370 QCoreApplication.translate('ViewManager', 'Clear'), |
|
371 QKeySequence(QCoreApplication.translate( |
|
372 'ViewManager', "Alt+Shift+C", "Edit|Clear")), |
|
373 0, |
|
374 self.copyActGrp, 'vm_edit_clear') |
|
375 self.clearAct.setStatusTip(QCoreApplication.translate( |
|
376 'ViewManager', 'Clear all text')) |
|
377 self.clearAct.setWhatsThis(self.tr( |
|
378 """<b>Clear</b>""" |
|
379 """<p>Delete all text.</p>""" |
|
380 )) |
|
381 self.clearAct.triggered.connect(self.__shell.clear) |
|
382 self.editActions.append(self.clearAct) |
|
383 |
|
384 self.cutAct.setEnabled(False) |
|
385 self.copyAct.setEnabled(False) |
|
386 self.__shell.copyAvailable.connect(self.cutAct.setEnabled) |
|
387 self.__shell.copyAvailable.connect(self.copyAct.setEnabled) |
|
388 |
|
389 #################################################################### |
|
390 ## Below follow the actions for QScintilla standard commands. |
|
391 #################################################################### |
|
392 |
|
393 self.esm = QSignalMapper(self) |
|
394 try: |
|
395 self.esm.mappedInt.connect(self.__shell.editorCommand) |
|
396 except AttributeError: |
|
397 # pre Qt 5.15 |
|
398 self.esm.mapped[int].connect(self.__shell.editorCommand) |
|
399 |
|
400 self.editorActGrp = createActionGroup(self) |
|
401 |
|
402 act = EricAction( |
|
403 QCoreApplication.translate('ViewManager', 'Delete current line'), |
|
404 QCoreApplication.translate('ViewManager', 'Delete current line'), |
|
405 QKeySequence(QCoreApplication.translate( |
|
406 'ViewManager', 'Ctrl+Shift+L')), |
|
407 0, |
|
408 self.editorActGrp, 'vm_edit_delete_current_line') |
|
409 self.esm.setMapping(act, QsciScintilla.SCI_LINEDELETE) |
|
410 act.triggered.connect(self.esm.map) |
|
411 self.editActions.append(act) |
|
412 |
|
413 act = EricAction( |
|
414 QCoreApplication.translate('ViewManager', 'Indent one level'), |
|
415 QCoreApplication.translate('ViewManager', 'Indent one level'), |
|
416 QKeySequence(QCoreApplication.translate('ViewManager', 'Tab')), 0, |
|
417 self.editorActGrp, 'vm_edit_indent_one_level') |
|
418 self.esm.setMapping(act, QsciScintilla.SCI_TAB) |
|
419 act.triggered.connect(self.esm.map) |
|
420 self.editActions.append(act) |
|
421 |
|
422 act = EricAction( |
|
423 QCoreApplication.translate('ViewManager', 'Insert new line'), |
|
424 QCoreApplication.translate('ViewManager', 'Insert new line'), |
|
425 QKeySequence(QCoreApplication.translate('ViewManager', 'Return')), |
|
426 QKeySequence(QCoreApplication.translate('ViewManager', 'Enter')), |
|
427 self.editorActGrp, 'vm_edit_insert_line') |
|
428 self.esm.setMapping(act, QsciScintilla.SCI_NEWLINE) |
|
429 act.triggered.connect(self.esm.map) |
|
430 self.editActions.append(act) |
|
431 |
|
432 act = EricAction( |
|
433 QCoreApplication.translate('ViewManager', |
|
434 'Delete previous character'), |
|
435 QCoreApplication.translate('ViewManager', |
|
436 'Delete previous character'), |
|
437 QKeySequence(QCoreApplication.translate('ViewManager', |
|
438 'Backspace')), |
|
439 0, self.editorActGrp, 'vm_edit_delete_previous_char') |
|
440 if isMacPlatform(): |
|
441 act.setAlternateShortcut(QKeySequence( |
|
442 QCoreApplication.translate('ViewManager', 'Meta+H'))) |
|
443 else: |
|
444 act.setAlternateShortcut(QKeySequence( |
|
445 QCoreApplication.translate('ViewManager', 'Shift+Backspace'))) |
|
446 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACK) |
|
447 act.triggered.connect(self.esm.map) |
|
448 self.editActions.append(act) |
|
449 |
|
450 act = EricAction( |
|
451 QCoreApplication.translate('ViewManager', |
|
452 'Delete current character'), |
|
453 QCoreApplication.translate('ViewManager', |
|
454 'Delete current character'), |
|
455 QKeySequence(QCoreApplication.translate('ViewManager', 'Del')), |
|
456 0, self.editorActGrp, 'vm_edit_delete_current_char') |
|
457 if isMacPlatform(): |
|
458 act.setAlternateShortcut(QKeySequence( |
|
459 QCoreApplication.translate('ViewManager', 'Meta+D'))) |
|
460 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) |
|
461 act.triggered.connect(self.esm.map) |
|
462 self.editActions.append(act) |
|
463 |
|
464 act = EricAction( |
|
465 QCoreApplication.translate('ViewManager', 'Delete word to left'), |
|
466 QCoreApplication.translate('ViewManager', 'Delete word to left'), |
|
467 QKeySequence(QCoreApplication.translate( |
|
468 'ViewManager', 'Ctrl+Backspace')), |
|
469 0, |
|
470 self.editorActGrp, 'vm_edit_delete_word_left') |
|
471 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDLEFT) |
|
472 act.triggered.connect(self.esm.map) |
|
473 self.editActions.append(act) |
|
474 |
|
475 act = EricAction( |
|
476 QCoreApplication.translate('ViewManager', 'Delete word to right'), |
|
477 QCoreApplication.translate('ViewManager', 'Delete word to right'), |
|
478 QKeySequence(QCoreApplication.translate('ViewManager', |
|
479 'Ctrl+Del')), |
|
480 0, self.editorActGrp, 'vm_edit_delete_word_right') |
|
481 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHT) |
|
482 act.triggered.connect(self.esm.map) |
|
483 self.editActions.append(act) |
|
484 |
|
485 act = EricAction( |
|
486 QCoreApplication.translate('ViewManager', 'Delete line to left'), |
|
487 QCoreApplication.translate('ViewManager', 'Delete line to left'), |
|
488 QKeySequence(QCoreApplication.translate( |
|
489 'ViewManager', 'Ctrl+Shift+Backspace')), |
|
490 0, |
|
491 self.editorActGrp, 'vm_edit_delete_line_left') |
|
492 self.esm.setMapping(act, QsciScintilla.SCI_DELLINELEFT) |
|
493 act.triggered.connect(self.esm.map) |
|
494 self.editActions.append(act) |
|
495 |
|
496 act = EricAction( |
|
497 QCoreApplication.translate('ViewManager', 'Delete line to right'), |
|
498 QCoreApplication.translate('ViewManager', 'Delete line to right'), |
|
499 0, 0, |
|
500 self.editorActGrp, 'vm_edit_delete_line_right') |
|
501 if isMacPlatform(): |
|
502 act.setShortcut(QKeySequence( |
|
503 QCoreApplication.translate('ViewManager', 'Meta+K'))) |
|
504 else: |
|
505 act.setShortcut(QKeySequence( |
|
506 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Del'))) |
|
507 self.esm.setMapping(act, QsciScintilla.SCI_DELLINERIGHT) |
|
508 act.triggered.connect(self.esm.map) |
|
509 self.editActions.append(act) |
|
510 |
|
511 act = EricAction( |
|
512 QCoreApplication.translate('ViewManager', |
|
513 'Move left one character'), |
|
514 QCoreApplication.translate('ViewManager', |
|
515 'Move left one character'), |
|
516 QKeySequence(QCoreApplication.translate('ViewManager', 'Left')), 0, |
|
517 self.editorActGrp, 'vm_edit_move_left_char') |
|
518 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) |
|
519 if isMacPlatform(): |
|
520 act.setAlternateShortcut(QKeySequence( |
|
521 QCoreApplication.translate('ViewManager', 'Meta+B'))) |
|
522 act.triggered.connect(self.esm.map) |
|
523 self.editActions.append(act) |
|
524 |
|
525 act = EricAction( |
|
526 QCoreApplication.translate('ViewManager', |
|
527 'Move right one character'), |
|
528 QCoreApplication.translate('ViewManager', |
|
529 'Move right one character'), |
|
530 QKeySequence(QCoreApplication.translate('ViewManager', 'Right')), |
|
531 0, self.editorActGrp, 'vm_edit_move_right_char') |
|
532 if isMacPlatform(): |
|
533 act.setAlternateShortcut(QKeySequence( |
|
534 QCoreApplication.translate('ViewManager', 'Meta+F'))) |
|
535 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) |
|
536 act.triggered.connect(self.esm.map) |
|
537 self.editActions.append(act) |
|
538 |
|
539 act = EricAction( |
|
540 QCoreApplication.translate('ViewManager', 'Move left one word'), |
|
541 QCoreApplication.translate('ViewManager', 'Move left one word'), |
|
542 0, 0, |
|
543 self.editorActGrp, 'vm_edit_move_left_word') |
|
544 if isMacPlatform(): |
|
545 act.setShortcut(QKeySequence( |
|
546 QCoreApplication.translate('ViewManager', 'Alt+Left'))) |
|
547 else: |
|
548 act.setShortcut(QKeySequence( |
|
549 QCoreApplication.translate('ViewManager', 'Ctrl+Left'))) |
|
550 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFT) |
|
551 act.triggered.connect(self.esm.map) |
|
552 self.editActions.append(act) |
|
553 |
|
554 act = EricAction( |
|
555 QCoreApplication.translate('ViewManager', 'Move right one word'), |
|
556 QCoreApplication.translate('ViewManager', 'Move right one word'), |
|
557 0, 0, |
|
558 self.editorActGrp, 'vm_edit_move_right_word') |
|
559 if not isMacPlatform(): |
|
560 act.setShortcut(QKeySequence( |
|
561 QCoreApplication.translate('ViewManager', 'Ctrl+Right'))) |
|
562 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) |
|
563 act.triggered.connect(self.esm.map) |
|
564 self.editActions.append(act) |
|
565 |
|
566 act = EricAction( |
|
567 QCoreApplication.translate( |
|
568 'ViewManager', |
|
569 'Move to first visible character in document line'), |
|
570 QCoreApplication.translate( |
|
571 'ViewManager', |
|
572 'Move to first visible character in document line'), |
|
573 0, 0, |
|
574 self.editorActGrp, 'vm_edit_move_first_visible_char') |
|
575 if not isMacPlatform(): |
|
576 act.setShortcut(QKeySequence( |
|
577 QCoreApplication.translate('ViewManager', 'Home'))) |
|
578 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) |
|
579 act.triggered.connect(self.esm.map) |
|
580 self.editActions.append(act) |
|
581 |
|
582 act = EricAction( |
|
583 QCoreApplication.translate( |
|
584 'ViewManager', 'Move to end of document line'), |
|
585 QCoreApplication.translate( |
|
586 'ViewManager', 'Move to end of document line'), |
|
587 0, 0, |
|
588 self.editorActGrp, 'vm_edit_move_end_line') |
|
589 if isMacPlatform(): |
|
590 act.setShortcut(QKeySequence( |
|
591 QCoreApplication.translate('ViewManager', 'Meta+E'))) |
|
592 else: |
|
593 act.setShortcut(QKeySequence( |
|
594 QCoreApplication.translate('ViewManager', 'End'))) |
|
595 self.esm.setMapping(act, QsciScintilla.SCI_LINEEND) |
|
596 act.triggered.connect(self.esm.map) |
|
597 self.editActions.append(act) |
|
598 |
|
599 act = EricAction( |
|
600 QCoreApplication.translate('ViewManager', 'Move up one line'), |
|
601 QCoreApplication.translate('ViewManager', 'Move up one line'), |
|
602 QKeySequence(QCoreApplication.translate('ViewManager', 'Up')), 0, |
|
603 self.editorActGrp, 'vm_edit_move_up_line') |
|
604 if isMacPlatform(): |
|
605 act.setAlternateShortcut(QKeySequence( |
|
606 QCoreApplication.translate('ViewManager', 'Meta+P'))) |
|
607 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) |
|
608 act.triggered.connect(self.esm.map) |
|
609 self.editActions.append(act) |
|
610 |
|
611 act = EricAction( |
|
612 QCoreApplication.translate('ViewManager', 'Move down one line'), |
|
613 QCoreApplication.translate('ViewManager', 'Move down one line'), |
|
614 QKeySequence(QCoreApplication.translate('ViewManager', 'Down')), 0, |
|
615 self.editorActGrp, 'vm_edit_move_down_line') |
|
616 if isMacPlatform(): |
|
617 act.setAlternateShortcut(QKeySequence( |
|
618 QCoreApplication.translate('ViewManager', 'Meta+N'))) |
|
619 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) |
|
620 act.triggered.connect(self.esm.map) |
|
621 self.editActions.append(act) |
|
622 |
|
623 act = EricAction( |
|
624 self.tr('Move forward one history entry'), |
|
625 self.tr('Move forward one history entry'), |
|
626 QKeySequence(QCoreApplication.translate('ViewManager', |
|
627 'Ctrl+Down')), |
|
628 0, self.editorActGrp, 'vm_edit_scroll_down_line') |
|
629 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLDOWN) |
|
630 act.triggered.connect(self.esm.map) |
|
631 self.editActions.append(act) |
|
632 |
|
633 act = EricAction( |
|
634 self.tr('Move back one history entry'), |
|
635 self.tr('Move back one history entry'), |
|
636 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+Up')), |
|
637 0, self.editorActGrp, 'vm_edit_scroll_up_line') |
|
638 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLUP) |
|
639 act.triggered.connect(self.esm.map) |
|
640 self.editActions.append(act) |
|
641 |
|
642 act = EricAction( |
|
643 QCoreApplication.translate('ViewManager', 'Move up one page'), |
|
644 QCoreApplication.translate('ViewManager', 'Move up one page'), |
|
645 QKeySequence(QCoreApplication.translate('ViewManager', 'PgUp')), 0, |
|
646 self.editorActGrp, 'vm_edit_move_up_page') |
|
647 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUP) |
|
648 act.triggered.connect(self.esm.map) |
|
649 self.editActions.append(act) |
|
650 |
|
651 act = EricAction( |
|
652 QCoreApplication.translate('ViewManager', 'Move down one page'), |
|
653 QCoreApplication.translate('ViewManager', 'Move down one page'), |
|
654 QKeySequence(QCoreApplication.translate('ViewManager', 'PgDown')), |
|
655 0, self.editorActGrp, 'vm_edit_move_down_page') |
|
656 if isMacPlatform(): |
|
657 act.setAlternateShortcut(QKeySequence( |
|
658 QCoreApplication.translate('ViewManager', 'Meta+V'))) |
|
659 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) |
|
660 act.triggered.connect(self.esm.map) |
|
661 self.editActions.append(act) |
|
662 |
|
663 act = EricAction( |
|
664 QCoreApplication.translate('ViewManager', 'Escape'), |
|
665 QCoreApplication.translate('ViewManager', 'Escape'), |
|
666 QKeySequence(QCoreApplication.translate('ViewManager', 'Esc')), 0, |
|
667 self.editorActGrp, 'vm_edit_escape') |
|
668 self.esm.setMapping(act, QsciScintilla.SCI_CANCEL) |
|
669 act.triggered.connect(self.esm.map) |
|
670 self.editActions.append(act) |
|
671 |
|
672 act = EricAction( |
|
673 QCoreApplication.translate( |
|
674 'ViewManager', 'Extend selection left one character'), |
|
675 QCoreApplication.translate( |
|
676 'ViewManager', 'Extend selection left one character'), |
|
677 QKeySequence(QCoreApplication.translate('ViewManager', |
|
678 'Shift+Left')), |
|
679 0, self.editorActGrp, 'vm_edit_extend_selection_left_char') |
|
680 if isMacPlatform(): |
|
681 act.setAlternateShortcut(QKeySequence( |
|
682 QCoreApplication.translate('ViewManager', 'Meta+Shift+B'))) |
|
683 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) |
|
684 act.triggered.connect(self.esm.map) |
|
685 self.editActions.append(act) |
|
686 |
|
687 act = EricAction( |
|
688 QCoreApplication.translate( |
|
689 'ViewManager', 'Extend selection right one character'), |
|
690 QCoreApplication.translate( |
|
691 'ViewManager', 'Extend selection right one character'), |
|
692 QKeySequence(QCoreApplication.translate('ViewManager', |
|
693 'Shift+Right')), |
|
694 0, self.editorActGrp, 'vm_edit_extend_selection_right_char') |
|
695 if isMacPlatform(): |
|
696 act.setAlternateShortcut(QKeySequence( |
|
697 QCoreApplication.translate('ViewManager', 'Meta+Shift+F'))) |
|
698 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) |
|
699 act.triggered.connect(self.esm.map) |
|
700 self.editActions.append(act) |
|
701 |
|
702 act = EricAction( |
|
703 QCoreApplication.translate( |
|
704 'ViewManager', 'Extend selection left one word'), |
|
705 QCoreApplication.translate( |
|
706 'ViewManager', 'Extend selection left one word'), |
|
707 0, 0, |
|
708 self.editorActGrp, 'vm_edit_extend_selection_left_word') |
|
709 if isMacPlatform(): |
|
710 act.setShortcut(QKeySequence( |
|
711 QCoreApplication.translate('ViewManager', 'Alt+Shift+Left'))) |
|
712 else: |
|
713 act.setShortcut(QKeySequence( |
|
714 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Left'))) |
|
715 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEXTEND) |
|
716 act.triggered.connect(self.esm.map) |
|
717 self.editActions.append(act) |
|
718 |
|
719 act = EricAction( |
|
720 QCoreApplication.translate( |
|
721 'ViewManager', 'Extend selection right one word'), |
|
722 QCoreApplication.translate( |
|
723 'ViewManager', 'Extend selection right one word'), |
|
724 0, 0, |
|
725 self.editorActGrp, 'vm_edit_extend_selection_right_word') |
|
726 if isMacPlatform(): |
|
727 act.setShortcut(QKeySequence( |
|
728 QCoreApplication.translate('ViewManager', 'Alt+Shift+Right'))) |
|
729 else: |
|
730 act.setShortcut(QKeySequence( |
|
731 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Right'))) |
|
732 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEXTEND) |
|
733 act.triggered.connect(self.esm.map) |
|
734 self.editActions.append(act) |
|
735 |
|
736 act = EricAction( |
|
737 QCoreApplication.translate( |
|
738 'ViewManager', |
|
739 'Extend selection to first visible character in document' |
|
740 ' line'), |
|
741 QCoreApplication.translate( |
|
742 'ViewManager', |
|
743 'Extend selection to first visible character in document' |
|
744 ' line'), |
|
745 0, 0, |
|
746 self.editorActGrp, 'vm_edit_extend_selection_first_visible_char') |
|
747 if not isMacPlatform(): |
|
748 act.setShortcut(QKeySequence( |
|
749 QCoreApplication.translate('ViewManager', 'Shift+Home'))) |
|
750 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) |
|
751 act.triggered.connect(self.esm.map) |
|
752 self.editActions.append(act) |
|
753 |
|
754 act = EricAction( |
|
755 QCoreApplication.translate( |
|
756 'ViewManager', 'Extend selection to end of document line'), |
|
757 QCoreApplication.translate( |
|
758 'ViewManager', 'Extend selection to end of document line'), |
|
759 0, 0, |
|
760 self.editorActGrp, 'vm_edit_extend_selection_end_line') |
|
761 if isMacPlatform(): |
|
762 act.setShortcut(QKeySequence( |
|
763 QCoreApplication.translate('ViewManager', 'Meta+Shift+E'))) |
|
764 else: |
|
765 act.setShortcut(QKeySequence( |
|
766 QCoreApplication.translate('ViewManager', 'Shift+End'))) |
|
767 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDEXTEND) |
|
768 act.triggered.connect(self.esm.map) |
|
769 self.editActions.append(act) |
|
770 |
|
771 def __createSearchActions(self): |
|
772 """ |
|
773 Private method defining the user interface actions for the search |
|
774 commands. |
|
775 """ |
|
776 self.searchActGrp = createActionGroup(self) |
|
777 |
|
778 self.searchAct = EricAction( |
|
779 QCoreApplication.translate('ViewManager', 'Search'), |
|
780 UI.PixmapCache.getIcon("find"), |
|
781 QCoreApplication.translate('ViewManager', '&Search...'), |
|
782 QKeySequence(QCoreApplication.translate( |
|
783 'ViewManager', "Ctrl+F", "Search|Search")), |
|
784 0, |
|
785 self, 'vm_search') |
|
786 self.searchAct.setStatusTip(QCoreApplication.translate( |
|
787 'ViewManager', 'Search for a text')) |
|
788 self.searchAct.setWhatsThis(QCoreApplication.translate( |
|
789 'ViewManager', |
|
790 """<b>Search</b>""" |
|
791 """<p>Search for some text in the shell window. A""" |
|
792 """ dialog is shown to enter the search text and options""" |
|
793 """ for the search.</p>""" |
|
794 )) |
|
795 self.searchAct.triggered.connect(self.__showFind) |
|
796 self.searchActions.append(self.searchAct) |
|
797 |
|
798 self.searchNextAct = EricAction( |
|
799 QCoreApplication.translate( |
|
800 'ViewManager', 'Search next'), |
|
801 UI.PixmapCache.getIcon("findNext"), |
|
802 QCoreApplication.translate('ViewManager', 'Search &next'), |
|
803 QKeySequence(QCoreApplication.translate( |
|
804 'ViewManager', "F3", "Search|Search next")), |
|
805 0, |
|
806 self, 'vm_search_next') |
|
807 self.searchNextAct.setStatusTip(QCoreApplication.translate( |
|
808 'ViewManager', 'Search next occurrence of text')) |
|
809 self.searchNextAct.setWhatsThis(QCoreApplication.translate( |
|
810 'ViewManager', |
|
811 """<b>Search next</b>""" |
|
812 """<p>Search the next occurrence of some text in the shell""" |
|
813 """ window. The previously entered search text and options are""" |
|
814 """ reused.</p>""" |
|
815 )) |
|
816 self.searchNextAct.triggered.connect( |
|
817 self.__searchWidget.on_findNextButton_clicked) |
|
818 self.searchActions.append(self.searchNextAct) |
|
819 |
|
820 self.searchPrevAct = EricAction( |
|
821 QCoreApplication.translate('ViewManager', 'Search previous'), |
|
822 UI.PixmapCache.getIcon("findPrev"), |
|
823 QCoreApplication.translate('ViewManager', 'Search &previous'), |
|
824 QKeySequence(QCoreApplication.translate( |
|
825 'ViewManager', "Shift+F3", "Search|Search previous")), |
|
826 0, |
|
827 self, 'vm_search_previous') |
|
828 self.searchPrevAct.setStatusTip(QCoreApplication.translate( |
|
829 'ViewManager', 'Search previous occurrence of text')) |
|
830 self.searchPrevAct.setWhatsThis(QCoreApplication.translate( |
|
831 'ViewManager', |
|
832 """<b>Search previous</b>""" |
|
833 """<p>Search the previous occurrence of some text in the shell""" |
|
834 """ window. The previously entered search text and options are""" |
|
835 """ reused.</p>""" |
|
836 )) |
|
837 self.searchPrevAct.triggered.connect( |
|
838 self.__searchWidget.on_findPrevButton_clicked) |
|
839 self.searchActions.append(self.searchPrevAct) |
|
840 |
|
841 def __createViewActions(self): |
|
842 """ |
|
843 Private method defining the user interface actions for the view |
|
844 commands. |
|
845 """ |
|
846 self.viewActGrp = createActionGroup(self) |
|
847 |
|
848 self.zoomInAct = EricAction( |
|
849 QCoreApplication.translate('ViewManager', 'Zoom in'), |
|
850 UI.PixmapCache.getIcon("zoomIn"), |
|
851 QCoreApplication.translate('ViewManager', 'Zoom &in'), |
|
852 QKeySequence(QCoreApplication.translate( |
|
853 'ViewManager', "Ctrl++", "View|Zoom in")), |
|
854 QKeySequence(QCoreApplication.translate( |
|
855 'ViewManager', "Zoom In", "View|Zoom in")), |
|
856 self.viewActGrp, 'vm_view_zoom_in') |
|
857 self.zoomInAct.setStatusTip(QCoreApplication.translate( |
|
858 'ViewManager', 'Zoom in on the text')) |
|
859 self.zoomInAct.setWhatsThis(QCoreApplication.translate( |
|
860 'ViewManager', |
|
861 """<b>Zoom in</b>""" |
|
862 """<p>Zoom in on the text. This makes the text bigger.</p>""" |
|
863 )) |
|
864 self.zoomInAct.triggered.connect(self.__zoomIn) |
|
865 self.viewActions.append(self.zoomInAct) |
|
866 |
|
867 self.zoomOutAct = EricAction( |
|
868 QCoreApplication.translate('ViewManager', 'Zoom out'), |
|
869 UI.PixmapCache.getIcon("zoomOut"), |
|
870 QCoreApplication.translate('ViewManager', 'Zoom &out'), |
|
871 QKeySequence(QCoreApplication.translate( |
|
872 'ViewManager', "Ctrl+-", "View|Zoom out")), |
|
873 QKeySequence(QCoreApplication.translate( |
|
874 'ViewManager', "Zoom Out", "View|Zoom out")), |
|
875 self.viewActGrp, 'vm_view_zoom_out') |
|
876 self.zoomOutAct.setStatusTip(QCoreApplication.translate( |
|
877 'ViewManager', 'Zoom out on the text')) |
|
878 self.zoomOutAct.setWhatsThis(QCoreApplication.translate( |
|
879 'ViewManager', |
|
880 """<b>Zoom out</b>""" |
|
881 """<p>Zoom out on the text. This makes the text smaller.</p>""" |
|
882 )) |
|
883 self.zoomOutAct.triggered.connect(self.__zoomOut) |
|
884 self.viewActions.append(self.zoomOutAct) |
|
885 |
|
886 self.zoomResetAct = EricAction( |
|
887 QCoreApplication.translate('ViewManager', 'Zoom reset'), |
|
888 UI.PixmapCache.getIcon("zoomReset"), |
|
889 QCoreApplication.translate('ViewManager', 'Zoom &reset'), |
|
890 QKeySequence(QCoreApplication.translate( |
|
891 'ViewManager', "Ctrl+0", "View|Zoom reset")), |
|
892 0, |
|
893 self.viewActGrp, 'vm_view_zoom_reset') |
|
894 self.zoomResetAct.setStatusTip(QCoreApplication.translate( |
|
895 'ViewManager', 'Reset the zoom of the text')) |
|
896 self.zoomResetAct.setWhatsThis(QCoreApplication.translate( |
|
897 'ViewManager', |
|
898 """<b>Zoom reset</b>""" |
|
899 """<p>Reset the zoom of the text. """ |
|
900 """This sets the zoom factor to 100%.</p>""" |
|
901 )) |
|
902 self.zoomResetAct.triggered.connect(self.__zoomReset) |
|
903 self.viewActions.append(self.zoomResetAct) |
|
904 |
|
905 self.zoomToAct = EricAction( |
|
906 QCoreApplication.translate('ViewManager', 'Zoom'), |
|
907 UI.PixmapCache.getIcon("zoomTo"), |
|
908 QCoreApplication.translate('ViewManager', '&Zoom'), |
|
909 0, 0, |
|
910 self.viewActGrp, 'vm_view_zoom') |
|
911 self.zoomToAct.setStatusTip(QCoreApplication.translate( |
|
912 'ViewManager', 'Zoom the text')) |
|
913 self.zoomToAct.setWhatsThis(QCoreApplication.translate( |
|
914 'ViewManager', |
|
915 """<b>Zoom</b>""" |
|
916 """<p>Zoom the text. This opens a dialog where the""" |
|
917 """ desired size can be entered.</p>""" |
|
918 )) |
|
919 self.zoomToAct.triggered.connect(self.__zoom) |
|
920 self.viewActions.append(self.zoomToAct) |
|
921 |
|
922 def __createHistoryActions(self): |
|
923 """ |
|
924 Private method defining the user interface actions for the history |
|
925 commands. |
|
926 """ |
|
927 self.showHistoryAct = EricAction( |
|
928 self.tr('Show History'), |
|
929 UI.PixmapCache.getIcon("history"), |
|
930 self.tr('&Show History...'), |
|
931 0, 0, |
|
932 self, 'shell_show_history') |
|
933 self.showHistoryAct.setStatusTip(self.tr( |
|
934 "Show the shell history in a dialog")) |
|
935 self.showHistoryAct.triggered.connect(self.__shell.showHistory) |
|
936 |
|
937 self.clearHistoryAct = EricAction( |
|
938 self.tr('Clear History'), |
|
939 UI.PixmapCache.getIcon("historyClear"), |
|
940 self.tr('&Clear History...'), |
|
941 0, 0, |
|
942 self, 'shell_clear_history') |
|
943 self.clearHistoryAct.setStatusTip(self.tr( |
|
944 "Clear the shell history")) |
|
945 self.clearHistoryAct.triggered.connect(self.__shell.clearHistory) |
|
946 |
|
947 self.selectHistoryAct = EricAction( |
|
948 self.tr('Select History Entry'), |
|
949 self.tr('Select History &Entry'), |
|
950 0, 0, |
|
951 self, 'shell_select_history') |
|
952 self.selectHistoryAct.setStatusTip(self.tr( |
|
953 "Select an entry of the shell history")) |
|
954 self.selectHistoryAct.triggered.connect(self.__shell.selectHistory) |
|
955 |
|
956 def __createHelpActions(self): |
|
957 """ |
|
958 Private method to create the Help actions. |
|
959 """ |
|
960 self.aboutAct = EricAction( |
|
961 self.tr('About'), |
|
962 self.tr('&About'), |
|
963 0, 0, self, 'about_eric') |
|
964 self.aboutAct.setStatusTip(self.tr( |
|
965 'Display information about this software')) |
|
966 self.aboutAct.setWhatsThis(self.tr( |
|
967 """<b>About</b>""" |
|
968 """<p>Display some information about this software.</p>""")) |
|
969 self.aboutAct.triggered.connect(self.__about) |
|
970 self.helpActions.append(self.aboutAct) |
|
971 |
|
972 self.aboutQtAct = EricAction( |
|
973 self.tr('About Qt'), |
|
974 self.tr('About &Qt'), |
|
975 0, 0, self, 'about_qt') |
|
976 self.aboutQtAct.setStatusTip( |
|
977 self.tr('Display information about the Qt toolkit')) |
|
978 self.aboutQtAct.setWhatsThis(self.tr( |
|
979 """<b>About Qt</b>""" |
|
980 """<p>Display some information about the Qt toolkit.</p>""" |
|
981 )) |
|
982 self.aboutQtAct.triggered.connect(self.__aboutQt) |
|
983 self.helpActions.append(self.aboutQtAct) |
|
984 |
|
985 self.whatsThisAct = EricAction( |
|
986 self.tr('What\'s This?'), |
|
987 UI.PixmapCache.getIcon("whatsThis"), |
|
988 self.tr('&What\'s This?'), |
|
989 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), |
|
990 0, self, 'help_help_whats_this') |
|
991 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help')) |
|
992 self.whatsThisAct.setWhatsThis(self.tr( |
|
993 """<b>Display context sensitive help</b>""" |
|
994 """<p>In What's This? mode, the mouse cursor shows an arrow""" |
|
995 """ with a question mark, and you can click on the interface""" |
|
996 """ elements to get a short description of what they do and""" |
|
997 """ how to use them. In dialogs, this feature can be""" |
|
998 """ accessed using the context help button in the titlebar.""" |
|
999 """</p>""" |
|
1000 )) |
|
1001 self.whatsThisAct.triggered.connect(self.__whatsThis) |
|
1002 self.helpActions.append(self.whatsThisAct) |
|
1003 |
|
1004 def __showFind(self): |
|
1005 """ |
|
1006 Private method to display the search widget. |
|
1007 """ |
|
1008 txt = self.__shell.selectedText() |
|
1009 self.showFind(txt) |
|
1010 |
|
1011 def showFind(self, txt=""): |
|
1012 """ |
|
1013 Public method to display the search widget. |
|
1014 |
|
1015 @param txt text to be shown in the combo |
|
1016 @type str |
|
1017 """ |
|
1018 self.__searchWidget.showFind(txt) |
|
1019 |
|
1020 def activeWindow(self): |
|
1021 """ |
|
1022 Public method to get a reference to the active shell. |
|
1023 |
|
1024 @return reference to the shell widget |
|
1025 @rtype Shell |
|
1026 """ |
|
1027 return self.__shell |
|
1028 |
|
1029 def __readSettings(self): |
|
1030 """ |
|
1031 Private method to read the settings remembered last time. |
|
1032 """ |
|
1033 settings = Preferences.getSettings() |
|
1034 pos = settings.value("ShellWindow/Position", QPoint(0, 0)) |
|
1035 size = settings.value("ShellWindow/Size", QSize(800, 600)) |
|
1036 self.resize(size) |
|
1037 self.move(pos) |
|
1038 |
|
1039 def __writeSettings(self): |
|
1040 """ |
|
1041 Private method to write the settings for reuse. |
|
1042 """ |
|
1043 settings = Preferences.getSettings() |
|
1044 settings.setValue("ShellWindow/Position", self.pos()) |
|
1045 settings.setValue("ShellWindow/Size", self.size()) |
|
1046 |
|
1047 def quit(self): |
|
1048 """ |
|
1049 Public method to quit the application. |
|
1050 """ |
|
1051 ericApp().closeAllWindows() |
|
1052 |
|
1053 def __newWindow(self): |
|
1054 """ |
|
1055 Private slot to start a new instance of eric. |
|
1056 """ |
|
1057 program = getPythonExecutable() |
|
1058 eric7 = os.path.join(getConfig("ericDir"), "eric7_shell.py") |
|
1059 args = [eric7] |
|
1060 QProcess.startDetached(program, args) |
|
1061 |
|
1062 def __virtualEnvironmentChanged(self, venvName): |
|
1063 """ |
|
1064 Private slot handling a change of the shell's virtual environment. |
|
1065 |
|
1066 @param venvName name of the virtual environment of the shell |
|
1067 @type str |
|
1068 """ |
|
1069 if venvName: |
|
1070 self.setWindowTitle(self.tr("eric Shell [{0}]").format(venvName)) |
|
1071 else: |
|
1072 self.setWindowTitle(self.tr("eric Shell")) |
|
1073 |
|
1074 ################################################################## |
|
1075 ## Below are the action methods for the view menu |
|
1076 ################################################################## |
|
1077 |
|
1078 def __zoomIn(self): |
|
1079 """ |
|
1080 Private method to handle the zoom in action. |
|
1081 """ |
|
1082 self.__shell.zoomIn() |
|
1083 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1084 |
|
1085 def __zoomOut(self): |
|
1086 """ |
|
1087 Private method to handle the zoom out action. |
|
1088 """ |
|
1089 self.__shell.zoomOut() |
|
1090 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1091 |
|
1092 def __zoomReset(self): |
|
1093 """ |
|
1094 Private method to reset the zoom factor. |
|
1095 """ |
|
1096 self.__shell.zoomTo(0) |
|
1097 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1098 |
|
1099 def __zoom(self): |
|
1100 """ |
|
1101 Private method to handle the zoom action. |
|
1102 """ |
|
1103 from QScintilla.ZoomDialog import ZoomDialog |
|
1104 dlg = ZoomDialog(self.__shell.getZoom(), self, None, True) |
|
1105 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
1106 value = dlg.getZoomSize() |
|
1107 self.__zoomTo(value) |
|
1108 |
|
1109 def __zoomTo(self, value): |
|
1110 """ |
|
1111 Private slot to zoom to a given value. |
|
1112 |
|
1113 @param value zoom value to be set |
|
1114 @type int |
|
1115 """ |
|
1116 self.__shell.zoomTo(value) |
|
1117 self.__sbZoom.setValue(self.__shell.getZoom()) |
|
1118 |
|
1119 def __zoomValueChanged(self, value): |
|
1120 """ |
|
1121 Private slot to handle changes of the zoom value. |
|
1122 |
|
1123 @param value new zoom value |
|
1124 @type int |
|
1125 """ |
|
1126 self.__sbZoom.setValue(value) |
|
1127 |
|
1128 ################################################################## |
|
1129 ## Below are the action methods for the help menu |
|
1130 ################################################################## |
|
1131 |
|
1132 def __about(self): |
|
1133 """ |
|
1134 Private slot to show a little About message. |
|
1135 """ |
|
1136 EricMessageBox.about( |
|
1137 self, |
|
1138 self.tr("About eric Shell Window"), |
|
1139 self.tr( |
|
1140 "The eric Shell is a standalone shell window." |
|
1141 " It uses the same backend as the debugger of" |
|
1142 " the full IDE, but is executed independently.")) |
|
1143 |
|
1144 def __aboutQt(self): |
|
1145 """ |
|
1146 Private slot to handle the About Qt dialog. |
|
1147 """ |
|
1148 EricMessageBox.aboutQt(self, "eric Shell Window") |
|
1149 |
|
1150 def __whatsThis(self): |
|
1151 """ |
|
1152 Private slot called in to enter Whats This mode. |
|
1153 """ |
|
1154 QWhatsThis.enterWhatsThisMode() |
|
1155 |
|
1156 ################################################################## |
|
1157 ## Below are the main menu handling methods |
|
1158 ################################################################## |
|
1159 |
|
1160 def __createMenus(self): |
|
1161 """ |
|
1162 Private method to create the menus of the menu bar. |
|
1163 """ |
|
1164 self.__fileMenu = self.menuBar().addMenu(self.tr("&File")) |
|
1165 self.__fileMenu.setTearOffEnabled(True) |
|
1166 self.__fileMenu.addAction(self.newWindowAct) |
|
1167 self.__fileMenu.addSeparator() |
|
1168 self.__fileMenu.addAction(self.restartAct) |
|
1169 self.__fileMenu.addAction(self.clearRestartAct) |
|
1170 self.__fileMenu.addSeparator() |
|
1171 self.__fileMenu.addAction(self.saveContentsAct) |
|
1172 self.__fileMenu.addSeparator() |
|
1173 self.__fileMenu.addAction(self.exitAct) |
|
1174 |
|
1175 self.__editMenu = self.menuBar().addMenu(self.tr("&Edit")) |
|
1176 self.__editMenu.setTearOffEnabled(True) |
|
1177 self.__editMenu.addAction(self.cutAct) |
|
1178 self.__editMenu.addAction(self.copyAct) |
|
1179 self.__editMenu.addAction(self.pasteAct) |
|
1180 self.__editMenu.addAction(self.clearAct) |
|
1181 self.__editMenu.addSeparator() |
|
1182 self.__editMenu.addAction(self.searchAct) |
|
1183 self.__editMenu.addAction(self.searchNextAct) |
|
1184 self.__editMenu.addAction(self.searchPrevAct) |
|
1185 |
|
1186 self.__viewMenu = self.menuBar().addMenu(self.tr("&View")) |
|
1187 self.__viewMenu.setTearOffEnabled(True) |
|
1188 self.__viewMenu.addAction(self.zoomInAct) |
|
1189 self.__viewMenu.addAction(self.zoomOutAct) |
|
1190 self.__viewMenu.addAction(self.zoomResetAct) |
|
1191 self.__viewMenu.addAction(self.zoomToAct) |
|
1192 |
|
1193 self.__historyMenu = self.menuBar().addMenu(self.tr("Histor&y")) |
|
1194 self.__historyMenu.setTearOffEnabled(True) |
|
1195 self.__historyMenu.addAction(self.selectHistoryAct) |
|
1196 self.__historyMenu.addAction(self.showHistoryAct) |
|
1197 self.__historyMenu.addAction(self.clearHistoryAct) |
|
1198 self.__historyMenu.setEnabled(self.__shell.isHistoryEnabled()) |
|
1199 |
|
1200 self.__startMenu = self.menuBar().addMenu(self.tr("&Start")) |
|
1201 self.__startMenu.aboutToShow.connect(self.__showStartMenu) |
|
1202 self.__startMenu.triggered.connect(self.__startShell) |
|
1203 |
|
1204 self.menuBar().addSeparator() |
|
1205 |
|
1206 self.__helpMenu = self.menuBar().addMenu(self.tr("&Help")) |
|
1207 self.__helpMenu.setTearOffEnabled(True) |
|
1208 self.__helpMenu.addAction(self.aboutAct) |
|
1209 self.__helpMenu.addAction(self.aboutQtAct) |
|
1210 self.__helpMenu.addSeparator() |
|
1211 self.__helpMenu.addAction(self.whatsThisAct) |
|
1212 |
|
1213 def __showStartMenu(self): |
|
1214 """ |
|
1215 Private slot to prepare the language menu. |
|
1216 """ |
|
1217 self.__startMenu.clear() |
|
1218 for venvName in sorted(self.virtualenvManager.getVirtualenvNames()): |
|
1219 self.__startMenu.addAction(venvName) |
|
1220 |
|
1221 def __startShell(self, action): |
|
1222 """ |
|
1223 Private slot to start a shell according to the action triggered. |
|
1224 |
|
1225 @param action menu action that was triggered (QAction) |
|
1226 """ |
|
1227 venvName = action.text() |
|
1228 self.__debugServer.startClient(False, venvName=venvName) |
|
1229 self.__debugServer.remoteBanner() |
|
1230 |
|
1231 ################################################################## |
|
1232 ## Below are the toolbar handling methods |
|
1233 ################################################################## |
|
1234 |
|
1235 def __createToolBars(self): |
|
1236 """ |
|
1237 Private method to create the various toolbars. |
|
1238 """ |
|
1239 filetb = self.addToolBar(self.tr("File")) |
|
1240 filetb.setIconSize(UI.Config.ToolBarIconSize) |
|
1241 filetb.addAction(self.newWindowAct) |
|
1242 filetb.addSeparator() |
|
1243 filetb.addAction(self.restartAct) |
|
1244 filetb.addAction(self.clearRestartAct) |
|
1245 filetb.addSeparator() |
|
1246 filetb.addAction(self.saveContentsAct) |
|
1247 filetb.addSeparator() |
|
1248 filetb.addAction(self.exitAct) |
|
1249 |
|
1250 edittb = self.addToolBar(self.tr("Edit")) |
|
1251 edittb.setIconSize(UI.Config.ToolBarIconSize) |
|
1252 edittb.addAction(self.cutAct) |
|
1253 edittb.addAction(self.copyAct) |
|
1254 edittb.addAction(self.pasteAct) |
|
1255 edittb.addAction(self.clearAct) |
|
1256 |
|
1257 findtb = self.addToolBar(self.tr("Find")) |
|
1258 findtb.setIconSize(UI.Config.ToolBarIconSize) |
|
1259 findtb.addAction(self.searchAct) |
|
1260 findtb.addAction(self.searchNextAct) |
|
1261 findtb.addAction(self.searchPrevAct) |
|
1262 |
|
1263 viewtb = self.addToolBar(self.tr("View")) |
|
1264 viewtb.setIconSize(UI.Config.ToolBarIconSize) |
|
1265 viewtb.addAction(self.zoomInAct) |
|
1266 viewtb.addAction(self.zoomOutAct) |
|
1267 viewtb.addAction(self.zoomResetAct) |
|
1268 viewtb.addAction(self.zoomToAct) |
|
1269 |
|
1270 self.__historyToolbar = self.addToolBar(self.tr("History")) |
|
1271 self.__historyToolbar.setIconSize(UI.Config.ToolBarIconSize) |
|
1272 self.__historyToolbar.addAction(self.showHistoryAct) |
|
1273 self.__historyToolbar.addAction(self.clearHistoryAct) |
|
1274 self.__historyToolbar.setEnabled(self.__shell.isHistoryEnabled()) |
|
1275 |
|
1276 helptb = self.addToolBar(self.tr("Help")) |
|
1277 helptb.setIconSize(UI.Config.ToolBarIconSize) |
|
1278 helptb.addAction(self.whatsThisAct) |
|
1279 |
|
1280 ################################################################## |
|
1281 ## Below are the status bar handling methods |
|
1282 ################################################################## |
|
1283 |
|
1284 def __createStatusBar(self): |
|
1285 """ |
|
1286 Private slot to set up the status bar. |
|
1287 """ |
|
1288 self.__statusBar = self.statusBar() |
|
1289 self.__statusBar.setSizeGripEnabled(True) |
|
1290 |
|
1291 self.__sbZoom = EricZoomWidget( |
|
1292 UI.PixmapCache.getPixmap("zoomOut"), |
|
1293 UI.PixmapCache.getPixmap("zoomIn"), |
|
1294 UI.PixmapCache.getPixmap("zoomReset"), |
|
1295 self.__statusBar) |
|
1296 self.__statusBar.addPermanentWidget(self.__sbZoom) |
|
1297 self.__sbZoom.setWhatsThis(self.tr( |
|
1298 """<p>This part of the status bar allows zooming the shell.</p>""" |
|
1299 )) |
|
1300 |
|
1301 self.__sbZoom.valueChanged.connect(self.__zoomTo) |
|
1302 self.__sbZoom.setValue(0) |
|
1303 |
|
1304 def __historyStyleChanged(self, historyStyle): |
|
1305 """ |
|
1306 Private slot to handle a change of the shell history style. |
|
1307 |
|
1308 @param historyStyle style to be used for the history |
|
1309 @type ShellHistoryStyle |
|
1310 """ |
|
1311 enabled = self.__shell.isHistoryEnabled() |
|
1312 self.__historyMenu.setEnabled(enabled) |
|
1313 self.__historyToolbar.setEnabled(enabled) |