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