|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the viewmanager base class. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 import os |
|
13 |
|
14 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QSignalMapper, QTimer, \ |
|
15 QFileInfo, QRegExp, Qt, QCoreApplication, QPoint |
|
16 from PyQt5.QtGui import QColor, QKeySequence, QPalette, QPixmap |
|
17 from PyQt5.QtWidgets import QLineEdit, QToolBar, QWidgetAction, QDialog, \ |
|
18 QApplication, QMenu, QComboBox, QWidget |
|
19 from PyQt5.Qsci import QsciScintilla |
|
20 |
|
21 from E5Gui.E5Application import e5App |
|
22 from E5Gui import E5FileDialog, E5MessageBox |
|
23 |
|
24 from Globals import recentNameFiles, isMacPlatform |
|
25 |
|
26 import Preferences |
|
27 |
|
28 from QScintilla.Editor import Editor |
|
29 from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION |
|
30 |
|
31 import Utilities |
|
32 |
|
33 import UI.PixmapCache |
|
34 import UI.Config |
|
35 |
|
36 from E5Gui.E5Action import E5Action, createActionGroup |
|
37 |
|
38 |
|
39 class QuickSearchLineEdit(QLineEdit): |
|
40 """ |
|
41 Class implementing a line edit that reacts to newline and cancel commands. |
|
42 |
|
43 @signal escPressed() emitted after the cancel command was activated |
|
44 @signal gotFocus() emitted when the focus is changed to this widget |
|
45 """ |
|
46 escPressed = pyqtSignal() |
|
47 gotFocus = pyqtSignal() |
|
48 |
|
49 def editorCommand(self, cmd): |
|
50 """ |
|
51 Public method to perform an editor command. |
|
52 |
|
53 @param cmd the scintilla command to be performed |
|
54 """ |
|
55 if cmd == QsciScintilla.SCI_NEWLINE: |
|
56 cb = self.parent() |
|
57 hasEntry = cb.findText(self.text()) != -1 |
|
58 if not hasEntry: |
|
59 if cb.insertPolicy() == QComboBox.InsertAtTop: |
|
60 cb.insertItem(0, self.text()) |
|
61 else: |
|
62 cb.addItem(self.text()) |
|
63 self.returnPressed.emit() |
|
64 elif cmd == QsciScintilla.SCI_CANCEL: |
|
65 self.escPressed.emit() |
|
66 |
|
67 def keyPressEvent(self, evt): |
|
68 """ |
|
69 Protected method to handle the press of the ESC key. |
|
70 |
|
71 @param evt key event (QKeyPressEvent) |
|
72 """ |
|
73 if evt.key() == Qt.Key_Escape: |
|
74 self.escPressed.emit() |
|
75 else: |
|
76 super(QuickSearchLineEdit, self).keyPressEvent(evt) # pass it on |
|
77 |
|
78 def focusInEvent(self, evt): |
|
79 """ |
|
80 Protected method to record the current editor widget. |
|
81 |
|
82 @param evt focus event (QFocusEvent) |
|
83 """ |
|
84 self.gotFocus.emit() |
|
85 super(QuickSearchLineEdit, self).focusInEvent(evt) # pass it on |
|
86 |
|
87 |
|
88 class ViewManager(QWidget): |
|
89 """ |
|
90 Base class inherited by all specific viewmanager classes. |
|
91 |
|
92 It defines the interface to be implemented by specific |
|
93 viewmanager classes and all common methods. |
|
94 |
|
95 @signal changeCaption(str) emitted if a change of the caption is necessary |
|
96 @signal editorChanged(str) emitted when the current editor has changed |
|
97 @signal editorChangedEd(Editor) emitted when the current editor has changed |
|
98 @signal lastEditorClosed() emitted after the last editor window was closed |
|
99 @signal editorOpened(str) emitted after an editor window was opened |
|
100 @signal editorOpenedEd(Editor) emitted after an editor window was opened |
|
101 @signal editorClosed(str) emitted just before an editor window gets closed |
|
102 @signal editorClosedEd(Editor) emitted just before an editor window gets |
|
103 closed |
|
104 @signal editorRenamed(str) emitted after an editor was renamed |
|
105 @signal editorRenamedEd(Editor) emitted after an editor was renamed |
|
106 @signal editorSaved(str) emitted after an editor window was saved |
|
107 @signal editorSavedEd(Editor) emitted after an editor window was saved |
|
108 @signal checkActions(Editor) emitted when some actions should be checked |
|
109 for their status |
|
110 @signal cursorChanged(Editor) emitted after the cursor position of the |
|
111 active window has changed |
|
112 @signal breakpointToggled(Editor) emitted when a breakpoint is toggled |
|
113 @signal bookmarkToggled(Editor) emitted when a bookmark is toggled |
|
114 @signal syntaxerrorToggled(Editor) emitted when a syntax error is toggled |
|
115 @signal previewStateChanged(bool) emitted to signal a change in the |
|
116 preview state |
|
117 @signal astViewerStateChanged(bool) emitted to signal a change in the |
|
118 AST viewer state |
|
119 @signal editorLanguageChanged(Editor) emitted to signal a change of an |
|
120 editor's language |
|
121 @signal editorTextChanged(Editor) emitted to signal a change of an |
|
122 editor's text |
|
123 @signal editorLineChanged(str,int) emitted to signal a change of an |
|
124 editor's current line (line is given one based) |
|
125 @signal editorDoubleClickedEd(Editor, position, buttons) emitted to signal |
|
126 a mouse double click in an editor |
|
127 """ |
|
128 changeCaption = pyqtSignal(str) |
|
129 editorChanged = pyqtSignal(str) |
|
130 editorChangedEd = pyqtSignal(Editor) |
|
131 lastEditorClosed = pyqtSignal() |
|
132 editorOpened = pyqtSignal(str) |
|
133 editorOpenedEd = pyqtSignal(Editor) |
|
134 editorClosed = pyqtSignal(str) |
|
135 editorClosedEd = pyqtSignal(Editor) |
|
136 editorRenamed = pyqtSignal(str) |
|
137 editorRenamedEd = pyqtSignal(Editor) |
|
138 editorSaved = pyqtSignal(str) |
|
139 editorSavedEd = pyqtSignal(Editor) |
|
140 checkActions = pyqtSignal(Editor) |
|
141 cursorChanged = pyqtSignal(Editor) |
|
142 breakpointToggled = pyqtSignal(Editor) |
|
143 bookmarkToggled = pyqtSignal(Editor) |
|
144 syntaxerrorToggled = pyqtSignal(Editor) |
|
145 previewStateChanged = pyqtSignal(bool) |
|
146 astViewerStateChanged = pyqtSignal(bool) |
|
147 editorLanguageChanged = pyqtSignal(Editor) |
|
148 editorTextChanged = pyqtSignal(Editor) |
|
149 editorLineChanged = pyqtSignal(str, int) |
|
150 editorDoubleClickedEd = pyqtSignal(Editor, QPoint, int) |
|
151 |
|
152 def __init__(self): |
|
153 """ |
|
154 Constructor |
|
155 """ |
|
156 super(ViewManager, self).__init__() |
|
157 |
|
158 # initialize the instance variables |
|
159 self.editors = [] |
|
160 self.currentEditor = None |
|
161 self.untitledCount = 0 |
|
162 self.srHistory = { |
|
163 "search": [], |
|
164 "replace": [] |
|
165 } |
|
166 self.editorsCheckFocusIn = True |
|
167 |
|
168 self.recent = [] |
|
169 self.__loadRecent() |
|
170 |
|
171 self.bookmarked = [] |
|
172 bs = Preferences.Prefs.settings.value("Bookmarked/Sources") |
|
173 if bs is not None: |
|
174 self.bookmarked = bs |
|
175 |
|
176 # initialize the autosave timer |
|
177 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
|
178 self.autosaveTimer = QTimer(self) |
|
179 self.autosaveTimer.setObjectName("AutosaveTimer") |
|
180 self.autosaveTimer.setSingleShot(True) |
|
181 self.autosaveTimer.timeout.connect(self.__autosave) |
|
182 |
|
183 # initialize the APIs manager |
|
184 from QScintilla.APIsManager import APIsManager |
|
185 self.apisManager = APIsManager(parent=self) |
|
186 |
|
187 self.__cooperationClient = None |
|
188 |
|
189 self.__lastFocusWidget = None |
|
190 |
|
191 def setReferences(self, ui, dbs): |
|
192 """ |
|
193 Public method to set some references needed later on. |
|
194 |
|
195 @param ui reference to the main user interface |
|
196 @param dbs reference to the debug server object |
|
197 """ |
|
198 from QScintilla.SearchReplaceWidget import SearchReplaceSlidingWidget |
|
199 |
|
200 self.ui = ui |
|
201 self.dbs = dbs |
|
202 |
|
203 self.__searchWidget = SearchReplaceSlidingWidget(False, self, ui) |
|
204 self.__replaceWidget = SearchReplaceSlidingWidget(True, self, ui) |
|
205 |
|
206 self.checkActions.connect(self.__searchWidget.updateSelectionCheckBox) |
|
207 self.checkActions.connect(self.__replaceWidget.updateSelectionCheckBox) |
|
208 |
|
209 def searchWidget(self): |
|
210 """ |
|
211 Public method to get a reference to the search widget. |
|
212 |
|
213 @return reference to the search widget (SearchReplaceSlidingWidget) |
|
214 """ |
|
215 return self.__searchWidget |
|
216 |
|
217 def replaceWidget(self): |
|
218 """ |
|
219 Public method to get a reference to the replace widget. |
|
220 |
|
221 @return reference to the replace widget (SearchReplaceSlidingWidget) |
|
222 """ |
|
223 return self.__replaceWidget |
|
224 |
|
225 def __loadRecent(self): |
|
226 """ |
|
227 Private method to load the recently opened filenames. |
|
228 """ |
|
229 self.recent = [] |
|
230 Preferences.Prefs.rsettings.sync() |
|
231 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
|
232 if rs is not None: |
|
233 for f in Preferences.toList(rs): |
|
234 if QFileInfo(f).exists(): |
|
235 self.recent.append(f) |
|
236 |
|
237 def __saveRecent(self): |
|
238 """ |
|
239 Private method to save the list of recently opened filenames. |
|
240 """ |
|
241 Preferences.Prefs.rsettings.setValue(recentNameFiles, self.recent) |
|
242 Preferences.Prefs.rsettings.sync() |
|
243 |
|
244 def getMostRecent(self): |
|
245 """ |
|
246 Public method to get the most recently opened file. |
|
247 |
|
248 @return path of the most recently opened file (string) |
|
249 """ |
|
250 if len(self.recent): |
|
251 return self.recent[0] |
|
252 else: |
|
253 return None |
|
254 |
|
255 def setSbInfo(self, sbLine, sbPos, sbWritable, sbEncoding, sbLanguage, |
|
256 sbEol, sbZoom): |
|
257 """ |
|
258 Public method to transfer statusbar info from the user interface to |
|
259 viewmanager. |
|
260 |
|
261 @param sbLine reference to the line number part of the statusbar |
|
262 (QLabel) |
|
263 @param sbPos reference to the character position part of the statusbar |
|
264 (QLabel) |
|
265 @param sbWritable reference to the writability indicator part of |
|
266 the statusbar (QLabel) |
|
267 @param sbEncoding reference to the encoding indicator part of the |
|
268 statusbar (QLabel) |
|
269 @param sbLanguage reference to the language indicator part of the |
|
270 statusbar (QLabel) |
|
271 @param sbEol reference to the eol indicator part of the statusbar |
|
272 (QLabel) |
|
273 @param sbZoom reference to the zoom widget (E5ZoomWidget) |
|
274 """ |
|
275 self.sbLine = sbLine |
|
276 self.sbPos = sbPos |
|
277 self.sbWritable = sbWritable |
|
278 self.sbEnc = sbEncoding |
|
279 self.sbLang = sbLanguage |
|
280 self.sbEol = sbEol |
|
281 self.sbZoom = sbZoom |
|
282 self.sbZoom.valueChanged.connect(self.__zoomTo) |
|
283 self.__setSbFile(zoom=0) |
|
284 |
|
285 self.sbLang.clicked.connect(self.__showLanguagesMenu) |
|
286 self.sbEol.clicked.connect(self.__showEolMenu) |
|
287 self.sbEnc.clicked.connect(self.__showEncodingsMenu) |
|
288 |
|
289 ################################################################## |
|
290 ## Below are menu handling methods for status bar labels |
|
291 ################################################################## |
|
292 |
|
293 def __showLanguagesMenu(self, pos): |
|
294 """ |
|
295 Private slot to show the Languages menu of the current editor. |
|
296 |
|
297 @param pos position the menu should be shown at (QPoint) |
|
298 """ |
|
299 aw = self.activeWindow() |
|
300 if aw is not None: |
|
301 menu = aw.getMenu("Languages") |
|
302 if menu is not None: |
|
303 menu.exec_(pos) |
|
304 |
|
305 def __showEolMenu(self, pos): |
|
306 """ |
|
307 Private slot to show the EOL menu of the current editor. |
|
308 |
|
309 @param pos position the menu should be shown at (QPoint) |
|
310 """ |
|
311 aw = self.activeWindow() |
|
312 if aw is not None: |
|
313 menu = aw.getMenu("Eol") |
|
314 if menu is not None: |
|
315 menu.exec_(pos) |
|
316 |
|
317 def __showEncodingsMenu(self, pos): |
|
318 """ |
|
319 Private slot to show the Encodings menu of the current editor. |
|
320 |
|
321 @param pos position the menu should be shown at (QPoint) |
|
322 """ |
|
323 aw = self.activeWindow() |
|
324 if aw is not None: |
|
325 menu = aw.getMenu("Encodings") |
|
326 if menu is not None: |
|
327 menu.exec_(pos) |
|
328 |
|
329 ########################################################################### |
|
330 ## methods below need to be implemented by a subclass |
|
331 ########################################################################### |
|
332 |
|
333 def canCascade(self): |
|
334 """ |
|
335 Public method to signal if cascading of managed windows is available. |
|
336 |
|
337 @ireturn flag indicating cascading of windows is available |
|
338 @exception RuntimeError Not implemented |
|
339 """ |
|
340 raise RuntimeError('Not implemented') |
|
341 |
|
342 def canTile(self): |
|
343 """ |
|
344 Public method to signal if tiling of managed windows is available. |
|
345 |
|
346 @ireturn flag indicating tiling of windows is available |
|
347 @exception RuntimeError Not implemented |
|
348 """ |
|
349 raise RuntimeError('Not implemented') |
|
350 |
|
351 def tile(self): |
|
352 """ |
|
353 Public method to tile the managed windows. |
|
354 |
|
355 @exception RuntimeError Not implemented |
|
356 """ |
|
357 raise RuntimeError('Not implemented') |
|
358 |
|
359 def cascade(self): |
|
360 """ |
|
361 Public method to cascade the managed windows. |
|
362 |
|
363 @exception RuntimeError Not implemented |
|
364 """ |
|
365 raise RuntimeError('Not implemented') |
|
366 |
|
367 def activeWindow(self): |
|
368 """ |
|
369 Public method to return the active (i.e. current) window. |
|
370 |
|
371 @ireturn reference to the active editor |
|
372 @exception RuntimeError Not implemented |
|
373 """ |
|
374 raise RuntimeError('Not implemented') |
|
375 |
|
376 def _removeAllViews(self): |
|
377 """ |
|
378 Protected method to remove all views (i.e. windows). |
|
379 |
|
380 @exception RuntimeError Not implemented |
|
381 """ |
|
382 raise RuntimeError('Not implemented') |
|
383 |
|
384 def _removeView(self, win): |
|
385 """ |
|
386 Protected method to remove a view (i.e. window). |
|
387 |
|
388 @param win editor window to be removed |
|
389 @exception RuntimeError Not implemented |
|
390 """ |
|
391 raise RuntimeError('Not implemented') |
|
392 |
|
393 def _addView(self, win, fn=None, noName="", addNext=False, indexes=None): |
|
394 """ |
|
395 Protected method to add a view (i.e. window). |
|
396 |
|
397 @param win editor assembly to be added |
|
398 @type EditorAssembly |
|
399 @param fn filename of this editor |
|
400 @type str |
|
401 @param noName name to be used for an unnamed editor |
|
402 @type str |
|
403 @param addNext flag indicating to add the view next to the current |
|
404 view |
|
405 @type bool |
|
406 @param indexes of the editor, first the split view index, second the |
|
407 index within the view |
|
408 @type tuple of two int |
|
409 @exception RuntimeError Not implemented |
|
410 """ |
|
411 raise RuntimeError('Not implemented') |
|
412 |
|
413 def _showView(self, win, fn=None): |
|
414 """ |
|
415 Protected method to show a view (i.e. window). |
|
416 |
|
417 @param win editor assembly to be shown |
|
418 @param fn filename of this editor |
|
419 @exception RuntimeError Not implemented |
|
420 """ |
|
421 raise RuntimeError('Not implemented') |
|
422 |
|
423 def showWindowMenu(self, windowMenu): |
|
424 """ |
|
425 Public method to set up the viewmanager part of the Window menu. |
|
426 |
|
427 @param windowMenu reference to the window menu |
|
428 @exception RuntimeError Not implemented |
|
429 """ |
|
430 raise RuntimeError('Not implemented') |
|
431 |
|
432 def _initWindowActions(self): |
|
433 """ |
|
434 Protected method to define the user interface actions for window |
|
435 handling. |
|
436 |
|
437 @exception RuntimeError Not implemented |
|
438 """ |
|
439 raise RuntimeError('Not implemented') |
|
440 |
|
441 def setEditorName(self, editor, newName): |
|
442 """ |
|
443 Public method to change the displayed name of the editor. |
|
444 |
|
445 @param editor editor window to be changed |
|
446 @param newName new name to be shown (string) |
|
447 @exception RuntimeError Not implemented |
|
448 """ |
|
449 raise RuntimeError('Not implemented') |
|
450 |
|
451 def _modificationStatusChanged(self, m, editor): |
|
452 """ |
|
453 Protected slot to handle the modificationStatusChanged signal. |
|
454 |
|
455 @param m flag indicating the modification status (boolean) |
|
456 @param editor editor window changed |
|
457 @exception RuntimeError Not implemented |
|
458 """ |
|
459 raise RuntimeError('Not implemented') |
|
460 |
|
461 def mainWidget(self): |
|
462 """ |
|
463 Public method to return a reference to the main Widget of a |
|
464 specific view manager subclass. |
|
465 |
|
466 @exception RuntimeError Not implemented |
|
467 """ |
|
468 raise RuntimeError('Not implemented') |
|
469 |
|
470 ##################################################################### |
|
471 ## methods above need to be implemented by a subclass |
|
472 ##################################################################### |
|
473 |
|
474 def canSplit(self): |
|
475 """ |
|
476 Public method to signal if splitting of the view is available. |
|
477 |
|
478 @return flag indicating splitting of the view is available. |
|
479 """ |
|
480 return False |
|
481 |
|
482 def addSplit(self): |
|
483 """ |
|
484 Public method used to split the current view. |
|
485 """ |
|
486 pass |
|
487 |
|
488 @pyqtSlot() |
|
489 def removeSplit(self, index=-1): |
|
490 """ |
|
491 Public method used to remove the current split view or a split view |
|
492 by index. |
|
493 |
|
494 @param index index of the split to be removed (-1 means to |
|
495 delete the current split) |
|
496 @type int |
|
497 @return flag indicating successful deletion |
|
498 @rtype bool |
|
499 """ |
|
500 return False |
|
501 |
|
502 def splitCount(self): |
|
503 """ |
|
504 Public method to get the number of split views. |
|
505 |
|
506 @return number of split views |
|
507 @rtype int |
|
508 """ |
|
509 return 0 |
|
510 |
|
511 def setSplitCount(self, count): |
|
512 """ |
|
513 Public method to set the number of split views. |
|
514 |
|
515 @param count number of split views |
|
516 @type int |
|
517 """ |
|
518 pass |
|
519 |
|
520 def getSplitOrientation(self): |
|
521 """ |
|
522 Public method to get the orientation of the split view. |
|
523 |
|
524 @return orientation of the split (Qt.Horizontal or Qt.Vertical) |
|
525 """ |
|
526 return Qt.Vertical |
|
527 |
|
528 def setSplitOrientation(self, orientation): |
|
529 """ |
|
530 Public method used to set the orientation of the split view. |
|
531 |
|
532 @param orientation orientation of the split |
|
533 (Qt.Horizontal or Qt.Vertical) |
|
534 """ |
|
535 pass |
|
536 |
|
537 def nextSplit(self): |
|
538 """ |
|
539 Public slot used to move to the next split. |
|
540 """ |
|
541 pass |
|
542 |
|
543 def prevSplit(self): |
|
544 """ |
|
545 Public slot used to move to the previous split. |
|
546 """ |
|
547 pass |
|
548 |
|
549 def eventFilter(self, qobject, event): |
|
550 """ |
|
551 Public method called to filter an event. |
|
552 |
|
553 @param qobject object, that generated the event (QObject) |
|
554 @param event the event, that was generated by object (QEvent) |
|
555 @return flag indicating if event was filtered out |
|
556 """ |
|
557 return False |
|
558 |
|
559 ##################################################################### |
|
560 ## methods above need to be implemented by a subclass, that supports |
|
561 ## splitting of the viewmanager area. |
|
562 ##################################################################### |
|
563 |
|
564 def initActions(self): |
|
565 """ |
|
566 Public method defining the user interface actions. |
|
567 """ |
|
568 # list containing all edit actions |
|
569 self.editActions = [] |
|
570 |
|
571 # list containing all file actions |
|
572 self.fileActions = [] |
|
573 |
|
574 # list containing all search actions |
|
575 self.searchActions = [] |
|
576 |
|
577 # list containing all view actions |
|
578 self.viewActions = [] |
|
579 |
|
580 # list containing all window actions |
|
581 self.windowActions = [] |
|
582 |
|
583 # list containing all macro actions |
|
584 self.macroActions = [] |
|
585 |
|
586 # list containing all bookmark actions |
|
587 self.bookmarkActions = [] |
|
588 |
|
589 # list containing all spell checking actions |
|
590 self.spellingActions = [] |
|
591 |
|
592 self.__actions = { |
|
593 "bookmark": self.bookmarkActions, |
|
594 "edit": self.editActions, |
|
595 "file": self.fileActions, |
|
596 "macro": self.macroActions, |
|
597 "search": self.searchActions, |
|
598 "spelling": self.spellingActions, |
|
599 "view": self.viewActions, |
|
600 "window": self.windowActions, |
|
601 } |
|
602 |
|
603 self._initWindowActions() |
|
604 self.__initFileActions() |
|
605 self.__initEditActions() |
|
606 self.__initSearchActions() |
|
607 self.__initViewActions() |
|
608 self.__initMacroActions() |
|
609 self.__initBookmarkActions() |
|
610 self.__initSpellingActions() |
|
611 |
|
612 ################################################################## |
|
613 ## Initialize the file related actions, file menu and toolbar |
|
614 ################################################################## |
|
615 |
|
616 def __initFileActions(self): |
|
617 """ |
|
618 Private method defining the user interface actions for file handling. |
|
619 """ |
|
620 self.newAct = E5Action( |
|
621 QCoreApplication.translate('ViewManager', 'New'), |
|
622 UI.PixmapCache.getIcon("new.png"), |
|
623 QCoreApplication.translate('ViewManager', '&New'), |
|
624 QKeySequence( |
|
625 QCoreApplication.translate('ViewManager', "Ctrl+N", |
|
626 "File|New")), |
|
627 0, self, 'vm_file_new') |
|
628 self.newAct.setStatusTip( |
|
629 QCoreApplication.translate( |
|
630 'ViewManager', 'Open an empty editor window')) |
|
631 self.newAct.setWhatsThis(QCoreApplication.translate( |
|
632 'ViewManager', |
|
633 """<b>New</b>""" |
|
634 """<p>An empty editor window will be created.</p>""" |
|
635 )) |
|
636 self.newAct.triggered.connect(self.newEditor) |
|
637 self.fileActions.append(self.newAct) |
|
638 |
|
639 self.openAct = E5Action( |
|
640 QCoreApplication.translate('ViewManager', 'Open'), |
|
641 UI.PixmapCache.getIcon("open.png"), |
|
642 QCoreApplication.translate('ViewManager', '&Open...'), |
|
643 QKeySequence( |
|
644 QCoreApplication.translate('ViewManager', "Ctrl+O", |
|
645 "File|Open")), |
|
646 0, self, 'vm_file_open') |
|
647 self.openAct.setStatusTip(QCoreApplication.translate( |
|
648 'ViewManager', 'Open a file')) |
|
649 self.openAct.setWhatsThis(QCoreApplication.translate( |
|
650 'ViewManager', |
|
651 """<b>Open a file</b>""" |
|
652 """<p>You will be asked for the name of a file to be opened""" |
|
653 """ in an editor window.</p>""" |
|
654 )) |
|
655 self.openAct.triggered.connect(self.__openFiles) |
|
656 self.fileActions.append(self.openAct) |
|
657 |
|
658 self.closeActGrp = createActionGroup(self) |
|
659 |
|
660 self.closeAct = E5Action( |
|
661 QCoreApplication.translate('ViewManager', 'Close'), |
|
662 UI.PixmapCache.getIcon("close.png"), |
|
663 QCoreApplication.translate('ViewManager', '&Close'), |
|
664 QKeySequence( |
|
665 QCoreApplication.translate('ViewManager', "Ctrl+W", |
|
666 "File|Close")), |
|
667 0, self.closeActGrp, 'vm_file_close') |
|
668 self.closeAct.setStatusTip( |
|
669 QCoreApplication.translate('ViewManager', |
|
670 'Close the current window')) |
|
671 self.closeAct.setWhatsThis(QCoreApplication.translate( |
|
672 'ViewManager', |
|
673 """<b>Close Window</b>""" |
|
674 """<p>Close the current window.</p>""" |
|
675 )) |
|
676 self.closeAct.triggered.connect(self.closeCurrentWindow) |
|
677 self.fileActions.append(self.closeAct) |
|
678 |
|
679 self.closeAllAct = E5Action( |
|
680 QCoreApplication.translate('ViewManager', 'Close All'), |
|
681 QCoreApplication.translate('ViewManager', 'Clos&e All'), |
|
682 0, 0, self.closeActGrp, 'vm_file_close_all') |
|
683 self.closeAllAct.setStatusTip( |
|
684 QCoreApplication.translate('ViewManager', |
|
685 'Close all editor windows')) |
|
686 self.closeAllAct.setWhatsThis(QCoreApplication.translate( |
|
687 'ViewManager', |
|
688 """<b>Close All Windows</b>""" |
|
689 """<p>Close all editor windows.</p>""" |
|
690 )) |
|
691 self.closeAllAct.triggered.connect(self.closeAllWindows) |
|
692 self.fileActions.append(self.closeAllAct) |
|
693 |
|
694 self.closeActGrp.setEnabled(False) |
|
695 |
|
696 self.saveActGrp = createActionGroup(self) |
|
697 |
|
698 self.saveAct = E5Action( |
|
699 QCoreApplication.translate('ViewManager', 'Save'), |
|
700 UI.PixmapCache.getIcon("fileSave.png"), |
|
701 QCoreApplication.translate('ViewManager', '&Save'), |
|
702 QKeySequence(QCoreApplication.translate( |
|
703 'ViewManager', "Ctrl+S", "File|Save")), |
|
704 0, self.saveActGrp, 'vm_file_save') |
|
705 self.saveAct.setStatusTip( |
|
706 QCoreApplication.translate('ViewManager', 'Save the current file')) |
|
707 self.saveAct.setWhatsThis(QCoreApplication.translate( |
|
708 'ViewManager', |
|
709 """<b>Save File</b>""" |
|
710 """<p>Save the contents of current editor window.</p>""" |
|
711 )) |
|
712 self.saveAct.triggered.connect(self.saveCurrentEditor) |
|
713 self.fileActions.append(self.saveAct) |
|
714 |
|
715 self.saveAsAct = E5Action( |
|
716 QCoreApplication.translate('ViewManager', 'Save as'), |
|
717 UI.PixmapCache.getIcon("fileSaveAs.png"), |
|
718 QCoreApplication.translate('ViewManager', 'Save &as...'), |
|
719 QKeySequence(QCoreApplication.translate( |
|
720 'ViewManager', "Shift+Ctrl+S", "File|Save As")), |
|
721 0, self.saveActGrp, 'vm_file_save_as') |
|
722 self.saveAsAct.setStatusTip(QCoreApplication.translate( |
|
723 'ViewManager', 'Save the current file to a new one')) |
|
724 self.saveAsAct.setWhatsThis(QCoreApplication.translate( |
|
725 'ViewManager', |
|
726 """<b>Save File as</b>""" |
|
727 """<p>Save the contents of current editor window to a new file.""" |
|
728 """ The file can be entered in a file selection dialog.</p>""" |
|
729 )) |
|
730 self.saveAsAct.triggered.connect(self.saveAsCurrentEditor) |
|
731 self.fileActions.append(self.saveAsAct) |
|
732 |
|
733 self.saveCopyAct = E5Action( |
|
734 QCoreApplication.translate('ViewManager', 'Save Copy'), |
|
735 UI.PixmapCache.getIcon("fileSaveCopy.png"), |
|
736 QCoreApplication.translate('ViewManager', 'Save &Copy...'), |
|
737 0, 0, self.saveActGrp, 'vm_file_save_copy') |
|
738 self.saveCopyAct.setStatusTip(QCoreApplication.translate( |
|
739 'ViewManager', 'Save a copy of the current file')) |
|
740 self.saveCopyAct.setWhatsThis(QCoreApplication.translate( |
|
741 'ViewManager', |
|
742 """<b>Save Copy</b>""" |
|
743 """<p>Save a copy of the contents of current editor window.""" |
|
744 """ The file can be entered in a file selection dialog.</p>""" |
|
745 )) |
|
746 self.saveCopyAct.triggered.connect(self.saveCopyCurrentEditor) |
|
747 self.fileActions.append(self.saveCopyAct) |
|
748 |
|
749 self.saveAllAct = E5Action( |
|
750 QCoreApplication.translate('ViewManager', 'Save all'), |
|
751 UI.PixmapCache.getIcon("fileSaveAll.png"), |
|
752 QCoreApplication.translate('ViewManager', 'Save a&ll'), |
|
753 0, 0, self.saveActGrp, 'vm_file_save_all') |
|
754 self.saveAllAct.setStatusTip(QCoreApplication.translate( |
|
755 'ViewManager', 'Save all files')) |
|
756 self.saveAllAct.setWhatsThis(QCoreApplication.translate( |
|
757 'ViewManager', |
|
758 """<b>Save All Files</b>""" |
|
759 """<p>Save the contents of all editor windows.</p>""" |
|
760 )) |
|
761 self.saveAllAct.triggered.connect(self.saveAllEditors) |
|
762 self.fileActions.append(self.saveAllAct) |
|
763 |
|
764 self.saveActGrp.setEnabled(False) |
|
765 |
|
766 self.printAct = E5Action( |
|
767 QCoreApplication.translate('ViewManager', 'Print'), |
|
768 UI.PixmapCache.getIcon("print.png"), |
|
769 QCoreApplication.translate('ViewManager', '&Print'), |
|
770 QKeySequence(QCoreApplication.translate( |
|
771 'ViewManager', "Ctrl+P", "File|Print")), |
|
772 0, self, 'vm_file_print') |
|
773 self.printAct.setStatusTip(QCoreApplication.translate( |
|
774 'ViewManager', 'Print the current file')) |
|
775 self.printAct.setWhatsThis(QCoreApplication.translate( |
|
776 'ViewManager', |
|
777 """<b>Print File</b>""" |
|
778 """<p>Print the contents of current editor window.</p>""" |
|
779 )) |
|
780 self.printAct.triggered.connect(self.printCurrentEditor) |
|
781 self.printAct.setEnabled(False) |
|
782 self.fileActions.append(self.printAct) |
|
783 |
|
784 self.printPreviewAct = E5Action( |
|
785 QCoreApplication.translate('ViewManager', 'Print Preview'), |
|
786 UI.PixmapCache.getIcon("printPreview.png"), |
|
787 QCoreApplication.translate('ViewManager', 'Print Preview'), |
|
788 0, 0, self, 'vm_file_print_preview') |
|
789 self.printPreviewAct.setStatusTip(QCoreApplication.translate( |
|
790 'ViewManager', 'Print preview of the current file')) |
|
791 self.printPreviewAct.setWhatsThis(QCoreApplication.translate( |
|
792 'ViewManager', |
|
793 """<b>Print Preview</b>""" |
|
794 """<p>Print preview of the current editor window.</p>""" |
|
795 )) |
|
796 self.printPreviewAct.triggered.connect( |
|
797 self.printPreviewCurrentEditor) |
|
798 self.printPreviewAct.setEnabled(False) |
|
799 self.fileActions.append(self.printPreviewAct) |
|
800 |
|
801 self.findFileNameAct = E5Action( |
|
802 QCoreApplication.translate('ViewManager', 'Search File'), |
|
803 QCoreApplication.translate('ViewManager', 'Search &File...'), |
|
804 QKeySequence(QCoreApplication.translate( |
|
805 'ViewManager', "Alt+Ctrl+F", "File|Search File")), |
|
806 0, self, 'vm_file_search_file') |
|
807 self.findFileNameAct.setStatusTip(QCoreApplication.translate( |
|
808 'ViewManager', 'Search for a file')) |
|
809 self.findFileNameAct.setWhatsThis(QCoreApplication.translate( |
|
810 'ViewManager', |
|
811 """<b>Search File</b>""" |
|
812 """<p>Search for a file.</p>""" |
|
813 )) |
|
814 self.findFileNameAct.triggered.connect(self.__findFileName) |
|
815 self.fileActions.append(self.findFileNameAct) |
|
816 |
|
817 def initFileMenu(self): |
|
818 """ |
|
819 Public method to create the File menu. |
|
820 |
|
821 @return the generated menu |
|
822 """ |
|
823 menu = QMenu(QCoreApplication.translate('ViewManager', '&File'), |
|
824 self.ui) |
|
825 self.recentMenu = QMenu( |
|
826 QCoreApplication.translate('ViewManager', 'Open &Recent Files'), |
|
827 menu) |
|
828 self.bookmarkedMenu = QMenu( |
|
829 QCoreApplication.translate('ViewManager', |
|
830 'Open &Bookmarked Files'), |
|
831 menu) |
|
832 self.exportersMenu = self.__initContextMenuExporters() |
|
833 menu.setTearOffEnabled(True) |
|
834 |
|
835 menu.addAction(self.newAct) |
|
836 menu.addAction(self.openAct) |
|
837 self.menuRecentAct = menu.addMenu(self.recentMenu) |
|
838 menu.addMenu(self.bookmarkedMenu) |
|
839 menu.addSeparator() |
|
840 menu.addAction(self.closeAct) |
|
841 menu.addAction(self.closeAllAct) |
|
842 menu.addSeparator() |
|
843 menu.addAction(self.findFileNameAct) |
|
844 menu.addSeparator() |
|
845 menu.addAction(self.saveAct) |
|
846 menu.addAction(self.saveAsAct) |
|
847 menu.addAction(self.saveCopyAct) |
|
848 menu.addAction(self.saveAllAct) |
|
849 self.exportersMenuAct = menu.addMenu(self.exportersMenu) |
|
850 menu.addSeparator() |
|
851 menu.addAction(self.printPreviewAct) |
|
852 menu.addAction(self.printAct) |
|
853 |
|
854 self.recentMenu.aboutToShow.connect(self.__showRecentMenu) |
|
855 self.recentMenu.triggered.connect(self.__openSourceFile) |
|
856 self.bookmarkedMenu.aboutToShow.connect(self.__showBookmarkedMenu) |
|
857 self.bookmarkedMenu.triggered.connect(self.__openSourceFile) |
|
858 menu.aboutToShow.connect(self.__showFileMenu) |
|
859 |
|
860 self.exportersMenuAct.setEnabled(False) |
|
861 |
|
862 return menu |
|
863 |
|
864 def initFileToolbar(self, toolbarManager): |
|
865 """ |
|
866 Public method to create the File toolbar. |
|
867 |
|
868 @param toolbarManager reference to a toolbar manager object |
|
869 (E5ToolBarManager) |
|
870 @return the generated toolbar |
|
871 """ |
|
872 tb = QToolBar(QCoreApplication.translate('ViewManager', 'File'), |
|
873 self.ui) |
|
874 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
875 tb.setObjectName("FileToolbar") |
|
876 tb.setToolTip(QCoreApplication.translate('ViewManager', 'File')) |
|
877 |
|
878 tb.addAction(self.newAct) |
|
879 tb.addAction(self.openAct) |
|
880 tb.addAction(self.closeAct) |
|
881 tb.addSeparator() |
|
882 tb.addAction(self.saveAct) |
|
883 tb.addAction(self.saveAsAct) |
|
884 tb.addAction(self.saveCopyAct) |
|
885 tb.addAction(self.saveAllAct) |
|
886 |
|
887 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
888 toolbarManager.addAction(self.printPreviewAct, tb.windowTitle()) |
|
889 toolbarManager.addAction(self.printAct, tb.windowTitle()) |
|
890 |
|
891 return tb |
|
892 |
|
893 def __initContextMenuExporters(self): |
|
894 """ |
|
895 Private method used to setup the Exporters sub menu. |
|
896 |
|
897 @return reference to the generated menu (QMenu) |
|
898 """ |
|
899 menu = QMenu(QCoreApplication.translate('ViewManager', "Export as")) |
|
900 |
|
901 import QScintilla.Exporters |
|
902 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
|
903 exporters = sorted(list(supportedExporters.keys())) |
|
904 for exporter in exporters: |
|
905 act = menu.addAction(supportedExporters[exporter]) |
|
906 act.setData(exporter) |
|
907 |
|
908 menu.triggered.connect(self.__exportMenuTriggered) |
|
909 |
|
910 return menu |
|
911 |
|
912 ################################################################## |
|
913 ## Initialize the edit related actions, edit menu and toolbar |
|
914 ################################################################## |
|
915 |
|
916 def __initEditActions(self): |
|
917 """ |
|
918 Private method defining the user interface actions for the edit |
|
919 commands. |
|
920 """ |
|
921 self.editActGrp = createActionGroup(self) |
|
922 |
|
923 self.undoAct = E5Action( |
|
924 QCoreApplication.translate('ViewManager', 'Undo'), |
|
925 UI.PixmapCache.getIcon("editUndo.png"), |
|
926 QCoreApplication.translate('ViewManager', '&Undo'), |
|
927 QKeySequence(QCoreApplication.translate( |
|
928 'ViewManager', "Ctrl+Z", "Edit|Undo")), |
|
929 QKeySequence(QCoreApplication.translate( |
|
930 'ViewManager', "Alt+Backspace", "Edit|Undo")), |
|
931 self.editActGrp, 'vm_edit_undo') |
|
932 self.undoAct.setStatusTip(QCoreApplication.translate( |
|
933 'ViewManager', 'Undo the last change')) |
|
934 self.undoAct.setWhatsThis(QCoreApplication.translate( |
|
935 'ViewManager', |
|
936 """<b>Undo</b>""" |
|
937 """<p>Undo the last change done in the current editor.</p>""" |
|
938 )) |
|
939 self.undoAct.triggered.connect(self.__editUndo) |
|
940 self.editActions.append(self.undoAct) |
|
941 |
|
942 self.redoAct = E5Action( |
|
943 QCoreApplication.translate('ViewManager', 'Redo'), |
|
944 UI.PixmapCache.getIcon("editRedo.png"), |
|
945 QCoreApplication.translate('ViewManager', '&Redo'), |
|
946 QKeySequence(QCoreApplication.translate( |
|
947 'ViewManager', "Ctrl+Shift+Z", "Edit|Redo")), |
|
948 0, |
|
949 self.editActGrp, 'vm_edit_redo') |
|
950 self.redoAct.setStatusTip(QCoreApplication.translate( |
|
951 'ViewManager', 'Redo the last change')) |
|
952 self.redoAct.setWhatsThis(QCoreApplication.translate( |
|
953 'ViewManager', |
|
954 """<b>Redo</b>""" |
|
955 """<p>Redo the last change done in the current editor.</p>""" |
|
956 )) |
|
957 self.redoAct.triggered.connect(self.__editRedo) |
|
958 self.editActions.append(self.redoAct) |
|
959 |
|
960 self.revertAct = E5Action( |
|
961 QCoreApplication.translate( |
|
962 'ViewManager', 'Revert to last saved state'), |
|
963 QCoreApplication.translate( |
|
964 'ViewManager', 'Re&vert to last saved state'), |
|
965 QKeySequence(QCoreApplication.translate( |
|
966 'ViewManager', "Ctrl+Y", "Edit|Revert")), |
|
967 0, |
|
968 self.editActGrp, 'vm_edit_revert') |
|
969 self.revertAct.setStatusTip(QCoreApplication.translate( |
|
970 'ViewManager', 'Revert to last saved state')) |
|
971 self.revertAct.setWhatsThis(QCoreApplication.translate( |
|
972 'ViewManager', |
|
973 """<b>Revert to last saved state</b>""" |
|
974 """<p>Undo all changes up to the last saved state""" |
|
975 """ of the current editor.</p>""" |
|
976 )) |
|
977 self.revertAct.triggered.connect(self.__editRevert) |
|
978 self.editActions.append(self.revertAct) |
|
979 |
|
980 self.copyActGrp = createActionGroup(self.editActGrp) |
|
981 |
|
982 self.cutAct = E5Action( |
|
983 QCoreApplication.translate('ViewManager', 'Cut'), |
|
984 UI.PixmapCache.getIcon("editCut.png"), |
|
985 QCoreApplication.translate('ViewManager', 'Cu&t'), |
|
986 QKeySequence(QCoreApplication.translate( |
|
987 'ViewManager', "Ctrl+X", "Edit|Cut")), |
|
988 QKeySequence(QCoreApplication.translate( |
|
989 'ViewManager', "Shift+Del", "Edit|Cut")), |
|
990 self.copyActGrp, 'vm_edit_cut') |
|
991 self.cutAct.setStatusTip(QCoreApplication.translate( |
|
992 'ViewManager', 'Cut the selection')) |
|
993 self.cutAct.setWhatsThis(QCoreApplication.translate( |
|
994 'ViewManager', |
|
995 """<b>Cut</b>""" |
|
996 """<p>Cut the selected text of the current editor to the""" |
|
997 """ clipboard.</p>""" |
|
998 )) |
|
999 self.cutAct.triggered.connect(self.__editCut) |
|
1000 self.editActions.append(self.cutAct) |
|
1001 |
|
1002 self.copyAct = E5Action( |
|
1003 QCoreApplication.translate('ViewManager', 'Copy'), |
|
1004 UI.PixmapCache.getIcon("editCopy.png"), |
|
1005 QCoreApplication.translate('ViewManager', '&Copy'), |
|
1006 QKeySequence(QCoreApplication.translate( |
|
1007 'ViewManager', "Ctrl+C", "Edit|Copy")), |
|
1008 QKeySequence(QCoreApplication.translate( |
|
1009 'ViewManager', "Ctrl+Ins", "Edit|Copy")), |
|
1010 self.copyActGrp, 'vm_edit_copy') |
|
1011 self.copyAct.setStatusTip(QCoreApplication.translate( |
|
1012 'ViewManager', 'Copy the selection')) |
|
1013 self.copyAct.setWhatsThis(QCoreApplication.translate( |
|
1014 'ViewManager', |
|
1015 """<b>Copy</b>""" |
|
1016 """<p>Copy the selected text of the current editor to the""" |
|
1017 """ clipboard.</p>""" |
|
1018 )) |
|
1019 self.copyAct.triggered.connect(self.__editCopy) |
|
1020 self.editActions.append(self.copyAct) |
|
1021 |
|
1022 self.pasteAct = E5Action( |
|
1023 QCoreApplication.translate('ViewManager', 'Paste'), |
|
1024 UI.PixmapCache.getIcon("editPaste.png"), |
|
1025 QCoreApplication.translate('ViewManager', '&Paste'), |
|
1026 QKeySequence(QCoreApplication.translate( |
|
1027 'ViewManager', "Ctrl+V", "Edit|Paste")), |
|
1028 QKeySequence(QCoreApplication.translate( |
|
1029 'ViewManager', "Shift+Ins", "Edit|Paste")), |
|
1030 self.copyActGrp, 'vm_edit_paste') |
|
1031 self.pasteAct.setStatusTip(QCoreApplication.translate( |
|
1032 'ViewManager', 'Paste the last cut/copied text')) |
|
1033 self.pasteAct.setWhatsThis(QCoreApplication.translate( |
|
1034 'ViewManager', |
|
1035 """<b>Paste</b>""" |
|
1036 """<p>Paste the last cut/copied text from the clipboard to""" |
|
1037 """ the current editor.</p>""" |
|
1038 )) |
|
1039 self.pasteAct.triggered.connect(self.__editPaste) |
|
1040 self.editActions.append(self.pasteAct) |
|
1041 |
|
1042 self.deleteAct = E5Action( |
|
1043 QCoreApplication.translate('ViewManager', 'Clear'), |
|
1044 UI.PixmapCache.getIcon("editDelete.png"), |
|
1045 QCoreApplication.translate('ViewManager', 'Clear'), |
|
1046 QKeySequence(QCoreApplication.translate( |
|
1047 'ViewManager', "Alt+Shift+C", "Edit|Clear")), |
|
1048 0, |
|
1049 self.copyActGrp, 'vm_edit_clear') |
|
1050 self.deleteAct.setStatusTip(QCoreApplication.translate( |
|
1051 'ViewManager', 'Clear all text')) |
|
1052 self.deleteAct.setWhatsThis(QCoreApplication.translate( |
|
1053 'ViewManager', |
|
1054 """<b>Clear</b>""" |
|
1055 """<p>Delete all text of the current editor.</p>""" |
|
1056 )) |
|
1057 self.deleteAct.triggered.connect(self.__editDelete) |
|
1058 self.editActions.append(self.deleteAct) |
|
1059 |
|
1060 self.joinAct = E5Action( |
|
1061 QCoreApplication.translate('ViewManager', 'Join Lines'), |
|
1062 QCoreApplication.translate('ViewManager', 'Join Lines'), |
|
1063 QKeySequence(QCoreApplication.translate( |
|
1064 'ViewManager', "Ctrl+J", "Edit|Join Lines")), |
|
1065 0, |
|
1066 self.copyActGrp, 'vm_edit_join_lines') |
|
1067 self.joinAct.setStatusTip(QCoreApplication.translate( |
|
1068 'ViewManager', 'Join Lines')) |
|
1069 self.joinAct.setWhatsThis(QCoreApplication.translate( |
|
1070 'ViewManager', |
|
1071 """<b>Join Lines</b>""" |
|
1072 """<p>Join the current and the next lines.</p>""" |
|
1073 )) |
|
1074 self.joinAct.triggered.connect(self.__editJoin) |
|
1075 self.editActions.append(self.joinAct) |
|
1076 |
|
1077 self.indentAct = E5Action( |
|
1078 QCoreApplication.translate('ViewManager', 'Indent'), |
|
1079 UI.PixmapCache.getIcon("editIndent.png"), |
|
1080 QCoreApplication.translate('ViewManager', '&Indent'), |
|
1081 QKeySequence(QCoreApplication.translate( |
|
1082 'ViewManager', "Ctrl+I", "Edit|Indent")), |
|
1083 0, |
|
1084 self.editActGrp, 'vm_edit_indent') |
|
1085 self.indentAct.setStatusTip(QCoreApplication.translate( |
|
1086 'ViewManager', 'Indent line')) |
|
1087 self.indentAct.setWhatsThis(QCoreApplication.translate( |
|
1088 'ViewManager', |
|
1089 """<b>Indent</b>""" |
|
1090 """<p>Indents the current line or the lines of the""" |
|
1091 """ selection by one level.</p>""" |
|
1092 )) |
|
1093 self.indentAct.triggered.connect(self.__editIndent) |
|
1094 self.editActions.append(self.indentAct) |
|
1095 |
|
1096 self.unindentAct = E5Action( |
|
1097 QCoreApplication.translate('ViewManager', 'Unindent'), |
|
1098 UI.PixmapCache.getIcon("editUnindent.png"), |
|
1099 QCoreApplication.translate('ViewManager', 'U&nindent'), |
|
1100 QKeySequence(QCoreApplication.translate( |
|
1101 'ViewManager', "Ctrl+Shift+I", "Edit|Unindent")), |
|
1102 0, |
|
1103 self.editActGrp, 'vm_edit_unindent') |
|
1104 self.unindentAct.setStatusTip(QCoreApplication.translate( |
|
1105 'ViewManager', 'Unindent line')) |
|
1106 self.unindentAct.setWhatsThis(QCoreApplication.translate( |
|
1107 'ViewManager', |
|
1108 """<b>Unindent</b>""" |
|
1109 """<p>Unindents the current line or the lines of the""" |
|
1110 """ selection by one level.</p>""" |
|
1111 )) |
|
1112 self.unindentAct.triggered.connect(self.__editUnindent) |
|
1113 self.editActions.append(self.unindentAct) |
|
1114 |
|
1115 self.smartIndentAct = E5Action( |
|
1116 QCoreApplication.translate('ViewManager', 'Smart indent'), |
|
1117 UI.PixmapCache.getIcon("editSmartIndent.png"), |
|
1118 QCoreApplication.translate('ViewManager', 'Smart indent'), |
|
1119 0, 0, |
|
1120 self.editActGrp, 'vm_edit_smart_indent') |
|
1121 self.smartIndentAct.setStatusTip(QCoreApplication.translate( |
|
1122 'ViewManager', 'Smart indent Line or Selection')) |
|
1123 self.smartIndentAct.setWhatsThis(QCoreApplication.translate( |
|
1124 'ViewManager', |
|
1125 """<b>Smart indent</b>""" |
|
1126 """<p>Indents the current line or the lines of the""" |
|
1127 """ current selection smartly.</p>""" |
|
1128 )) |
|
1129 self.smartIndentAct.triggered.connect(self.__editSmartIndent) |
|
1130 self.editActions.append(self.smartIndentAct) |
|
1131 |
|
1132 self.commentAct = E5Action( |
|
1133 QCoreApplication.translate('ViewManager', 'Comment'), |
|
1134 UI.PixmapCache.getIcon("editComment.png"), |
|
1135 QCoreApplication.translate('ViewManager', 'C&omment'), |
|
1136 QKeySequence(QCoreApplication.translate( |
|
1137 'ViewManager', "Ctrl+M", "Edit|Comment")), |
|
1138 0, |
|
1139 self.editActGrp, 'vm_edit_comment') |
|
1140 self.commentAct.setStatusTip(QCoreApplication.translate( |
|
1141 'ViewManager', 'Comment Line or Selection')) |
|
1142 self.commentAct.setWhatsThis(QCoreApplication.translate( |
|
1143 'ViewManager', |
|
1144 """<b>Comment</b>""" |
|
1145 """<p>Comments the current line or the lines of the""" |
|
1146 """ current selection.</p>""" |
|
1147 )) |
|
1148 self.commentAct.triggered.connect(self.__editComment) |
|
1149 self.editActions.append(self.commentAct) |
|
1150 |
|
1151 self.uncommentAct = E5Action( |
|
1152 QCoreApplication.translate('ViewManager', 'Uncomment'), |
|
1153 UI.PixmapCache.getIcon("editUncomment.png"), |
|
1154 QCoreApplication.translate('ViewManager', 'Unco&mment'), |
|
1155 QKeySequence(QCoreApplication.translate( |
|
1156 'ViewManager', "Alt+Ctrl+M", "Edit|Uncomment")), |
|
1157 0, |
|
1158 self.editActGrp, 'vm_edit_uncomment') |
|
1159 self.uncommentAct.setStatusTip(QCoreApplication.translate( |
|
1160 'ViewManager', 'Uncomment Line or Selection')) |
|
1161 self.uncommentAct.setWhatsThis(QCoreApplication.translate( |
|
1162 'ViewManager', |
|
1163 """<b>Uncomment</b>""" |
|
1164 """<p>Uncomments the current line or the lines of the""" |
|
1165 """ current selection.</p>""" |
|
1166 )) |
|
1167 self.uncommentAct.triggered.connect(self.__editUncomment) |
|
1168 self.editActions.append(self.uncommentAct) |
|
1169 |
|
1170 self.toggleCommentAct = E5Action( |
|
1171 QCoreApplication.translate('ViewManager', 'Toggle Comment'), |
|
1172 UI.PixmapCache.getIcon("editToggleComment.png"), |
|
1173 QCoreApplication.translate('ViewManager', 'Toggle Comment'), |
|
1174 QKeySequence(QCoreApplication.translate( |
|
1175 'ViewManager', "Ctrl+Shift+M", "Edit|Toggle Comment")), |
|
1176 0, |
|
1177 self.editActGrp, 'vm_edit_toggle_comment') |
|
1178 self.toggleCommentAct.setStatusTip(QCoreApplication.translate( |
|
1179 'ViewManager', |
|
1180 'Toggle the comment of the current line, selection or' |
|
1181 ' comment block')) |
|
1182 self.toggleCommentAct.setWhatsThis(QCoreApplication.translate( |
|
1183 'ViewManager', |
|
1184 """<b>Toggle Comment</b>""" |
|
1185 """<p>If the current line does not start with a block comment,""" |
|
1186 """ the current line or selection is commented. If it is already""" |
|
1187 """ commented, this comment block is uncommented. </p>""" |
|
1188 )) |
|
1189 self.toggleCommentAct.triggered.connect(self.__editToggleComment) |
|
1190 self.editActions.append(self.toggleCommentAct) |
|
1191 |
|
1192 self.streamCommentAct = E5Action( |
|
1193 QCoreApplication.translate('ViewManager', 'Stream Comment'), |
|
1194 QCoreApplication.translate('ViewManager', 'Stream Comment'), |
|
1195 0, 0, |
|
1196 self.editActGrp, 'vm_edit_stream_comment') |
|
1197 self.streamCommentAct.setStatusTip(QCoreApplication.translate( |
|
1198 'ViewManager', |
|
1199 'Stream Comment Line or Selection')) |
|
1200 self.streamCommentAct.setWhatsThis(QCoreApplication.translate( |
|
1201 'ViewManager', |
|
1202 """<b>Stream Comment</b>""" |
|
1203 """<p>Stream comments the current line or the current""" |
|
1204 """ selection.</p>""" |
|
1205 )) |
|
1206 self.streamCommentAct.triggered.connect(self.__editStreamComment) |
|
1207 self.editActions.append(self.streamCommentAct) |
|
1208 |
|
1209 self.boxCommentAct = E5Action( |
|
1210 QCoreApplication.translate('ViewManager', 'Box Comment'), |
|
1211 QCoreApplication.translate('ViewManager', 'Box Comment'), |
|
1212 0, 0, |
|
1213 self.editActGrp, 'vm_edit_box_comment') |
|
1214 self.boxCommentAct.setStatusTip(QCoreApplication.translate( |
|
1215 'ViewManager', 'Box Comment Line or Selection')) |
|
1216 self.boxCommentAct.setWhatsThis(QCoreApplication.translate( |
|
1217 'ViewManager', |
|
1218 """<b>Box Comment</b>""" |
|
1219 """<p>Box comments the current line or the lines of the""" |
|
1220 """ current selection.</p>""" |
|
1221 )) |
|
1222 self.boxCommentAct.triggered.connect(self.__editBoxComment) |
|
1223 self.editActions.append(self.boxCommentAct) |
|
1224 |
|
1225 self.selectBraceAct = E5Action( |
|
1226 QCoreApplication.translate('ViewManager', 'Select to brace'), |
|
1227 QCoreApplication.translate('ViewManager', 'Select to &brace'), |
|
1228 QKeySequence(QCoreApplication.translate( |
|
1229 'ViewManager', "Ctrl+E", "Edit|Select to brace")), |
|
1230 0, |
|
1231 self.editActGrp, 'vm_edit_select_to_brace') |
|
1232 self.selectBraceAct.setStatusTip(QCoreApplication.translate( |
|
1233 'ViewManager', 'Select text to the matching brace')) |
|
1234 self.selectBraceAct.setWhatsThis(QCoreApplication.translate( |
|
1235 'ViewManager', |
|
1236 """<b>Select to brace</b>""" |
|
1237 """<p>Select text of the current editor to the matching""" |
|
1238 """ brace.</p>""" |
|
1239 )) |
|
1240 self.selectBraceAct.triggered.connect(self.__editSelectBrace) |
|
1241 self.editActions.append(self.selectBraceAct) |
|
1242 |
|
1243 self.selectAllAct = E5Action( |
|
1244 QCoreApplication.translate('ViewManager', 'Select all'), |
|
1245 UI.PixmapCache.getIcon("editSelectAll.png"), |
|
1246 QCoreApplication.translate('ViewManager', '&Select all'), |
|
1247 QKeySequence(QCoreApplication.translate( |
|
1248 'ViewManager', "Ctrl+A", "Edit|Select all")), |
|
1249 0, |
|
1250 self.editActGrp, 'vm_edit_select_all') |
|
1251 self.selectAllAct.setStatusTip(QCoreApplication.translate( |
|
1252 'ViewManager', 'Select all text')) |
|
1253 self.selectAllAct.setWhatsThis(QCoreApplication.translate( |
|
1254 'ViewManager', |
|
1255 """<b>Select All</b>""" |
|
1256 """<p>Select all text of the current editor.</p>""" |
|
1257 )) |
|
1258 self.selectAllAct.triggered.connect(self.__editSelectAll) |
|
1259 self.editActions.append(self.selectAllAct) |
|
1260 |
|
1261 self.deselectAllAct = E5Action( |
|
1262 QCoreApplication.translate('ViewManager', 'Deselect all'), |
|
1263 QCoreApplication.translate('ViewManager', '&Deselect all'), |
|
1264 QKeySequence(QCoreApplication.translate( |
|
1265 'ViewManager', "Alt+Ctrl+A", "Edit|Deselect all")), |
|
1266 0, |
|
1267 self.editActGrp, 'vm_edit_deselect_all') |
|
1268 self.deselectAllAct.setStatusTip(QCoreApplication.translate( |
|
1269 'ViewManager', 'Deselect all text')) |
|
1270 self.deselectAllAct.setWhatsThis(QCoreApplication.translate( |
|
1271 'ViewManager', |
|
1272 """<b>Deselect All</b>""" |
|
1273 """<p>Deselect all text of the current editor.</p>""" |
|
1274 )) |
|
1275 self.deselectAllAct.triggered.connect(self.__editDeselectAll) |
|
1276 self.editActions.append(self.deselectAllAct) |
|
1277 |
|
1278 self.convertEOLAct = E5Action( |
|
1279 QCoreApplication.translate( |
|
1280 'ViewManager', 'Convert Line End Characters'), |
|
1281 QCoreApplication.translate( |
|
1282 'ViewManager', 'Convert &Line End Characters'), |
|
1283 0, 0, |
|
1284 self.editActGrp, 'vm_edit_convert_eol') |
|
1285 self.convertEOLAct.setStatusTip(QCoreApplication.translate( |
|
1286 'ViewManager', 'Convert Line End Characters')) |
|
1287 self.convertEOLAct.setWhatsThis(QCoreApplication.translate( |
|
1288 'ViewManager', |
|
1289 """<b>Convert Line End Characters</b>""" |
|
1290 """<p>Convert the line end characters to the currently set""" |
|
1291 """ type.</p>""" |
|
1292 )) |
|
1293 self.convertEOLAct.triggered.connect(self.__convertEOL) |
|
1294 self.editActions.append(self.convertEOLAct) |
|
1295 |
|
1296 self.shortenEmptyAct = E5Action( |
|
1297 QCoreApplication.translate('ViewManager', 'Shorten empty lines'), |
|
1298 QCoreApplication.translate('ViewManager', 'Shorten empty lines'), |
|
1299 0, 0, |
|
1300 self.editActGrp, 'vm_edit_shorten_empty_lines') |
|
1301 self.shortenEmptyAct.setStatusTip(QCoreApplication.translate( |
|
1302 'ViewManager', 'Shorten empty lines')) |
|
1303 self.shortenEmptyAct.setWhatsThis(QCoreApplication.translate( |
|
1304 'ViewManager', |
|
1305 """<b>Shorten empty lines</b>""" |
|
1306 """<p>Shorten lines consisting solely of whitespace""" |
|
1307 """ characters.</p>""" |
|
1308 )) |
|
1309 self.shortenEmptyAct.triggered.connect(self.__shortenEmptyLines) |
|
1310 self.editActions.append(self.shortenEmptyAct) |
|
1311 |
|
1312 self.autoCompleteAct = E5Action( |
|
1313 QCoreApplication.translate('ViewManager', 'Complete'), |
|
1314 QCoreApplication.translate('ViewManager', '&Complete'), |
|
1315 QKeySequence(QCoreApplication.translate( |
|
1316 'ViewManager', "Ctrl+Space", "Edit|Complete")), |
|
1317 0, |
|
1318 self.editActGrp, 'vm_edit_autocomplete') |
|
1319 self.autoCompleteAct.setStatusTip(QCoreApplication.translate( |
|
1320 'ViewManager', 'Complete current word')) |
|
1321 self.autoCompleteAct.setWhatsThis(QCoreApplication.translate( |
|
1322 'ViewManager', |
|
1323 """<b>Complete</b>""" |
|
1324 """<p>Performs a completion of the word containing""" |
|
1325 """ the cursor.</p>""" |
|
1326 )) |
|
1327 self.autoCompleteAct.triggered.connect(self.__editAutoComplete) |
|
1328 self.editActions.append(self.autoCompleteAct) |
|
1329 |
|
1330 self.autoCompleteFromDocAct = E5Action( |
|
1331 QCoreApplication.translate( |
|
1332 'ViewManager', 'Complete from Document'), |
|
1333 QCoreApplication.translate( |
|
1334 'ViewManager', 'Complete from Document'), |
|
1335 QKeySequence(QCoreApplication.translate( |
|
1336 'ViewManager', "Ctrl+Shift+Space", |
|
1337 "Edit|Complete from Document")), |
|
1338 0, |
|
1339 self.editActGrp, 'vm_edit_autocomplete_from_document') |
|
1340 self.autoCompleteFromDocAct.setStatusTip(QCoreApplication.translate( |
|
1341 'ViewManager', |
|
1342 'Complete current word from Document')) |
|
1343 self.autoCompleteFromDocAct.setWhatsThis(QCoreApplication.translate( |
|
1344 'ViewManager', |
|
1345 """<b>Complete from Document</b>""" |
|
1346 """<p>Performs a completion from document of the word""" |
|
1347 """ containing the cursor.</p>""" |
|
1348 )) |
|
1349 self.autoCompleteFromDocAct.triggered.connect( |
|
1350 self.__editAutoCompleteFromDoc) |
|
1351 self.editActions.append(self.autoCompleteFromDocAct) |
|
1352 |
|
1353 self.autoCompleteFromAPIsAct = E5Action( |
|
1354 QCoreApplication.translate('ViewManager', |
|
1355 'Complete from APIs'), |
|
1356 QCoreApplication.translate('ViewManager', |
|
1357 'Complete from APIs'), |
|
1358 QKeySequence(QCoreApplication.translate( |
|
1359 'ViewManager', "Ctrl+Alt+Space", |
|
1360 "Edit|Complete from APIs")), |
|
1361 0, |
|
1362 self.editActGrp, 'vm_edit_autocomplete_from_api') |
|
1363 self.autoCompleteFromAPIsAct.setStatusTip(QCoreApplication.translate( |
|
1364 'ViewManager', |
|
1365 'Complete current word from APIs')) |
|
1366 self.autoCompleteFromAPIsAct.setWhatsThis(QCoreApplication.translate( |
|
1367 'ViewManager', |
|
1368 """<b>Complete from APIs</b>""" |
|
1369 """<p>Performs a completion from APIs of the word""" |
|
1370 """ containing the cursor.</p>""" |
|
1371 )) |
|
1372 self.autoCompleteFromAPIsAct.triggered.connect( |
|
1373 self.__editAutoCompleteFromAPIs) |
|
1374 self.editActions.append(self.autoCompleteFromAPIsAct) |
|
1375 |
|
1376 self.autoCompleteFromAllAct = E5Action( |
|
1377 QCoreApplication.translate( |
|
1378 'ViewManager', 'Complete from Document and APIs'), |
|
1379 QCoreApplication.translate( |
|
1380 'ViewManager', 'Complete from Document and APIs'), |
|
1381 QKeySequence(QCoreApplication.translate( |
|
1382 'ViewManager', "Alt+Shift+Space", |
|
1383 "Edit|Complete from Document and APIs")), |
|
1384 0, |
|
1385 self.editActGrp, 'vm_edit_autocomplete_from_all') |
|
1386 self.autoCompleteFromAllAct.setStatusTip(QCoreApplication.translate( |
|
1387 'ViewManager', |
|
1388 'Complete current word from Document and APIs')) |
|
1389 self.autoCompleteFromAllAct.setWhatsThis(QCoreApplication.translate( |
|
1390 'ViewManager', |
|
1391 """<b>Complete from Document and APIs</b>""" |
|
1392 """<p>Performs a completion from document and APIs""" |
|
1393 """ of the word containing the cursor.</p>""" |
|
1394 )) |
|
1395 self.autoCompleteFromAllAct.triggered.connect( |
|
1396 self.__editAutoCompleteFromAll) |
|
1397 self.editActions.append(self.autoCompleteFromAllAct) |
|
1398 |
|
1399 self.calltipsAct = E5Action( |
|
1400 QCoreApplication.translate('ViewManager', 'Calltip'), |
|
1401 QCoreApplication.translate('ViewManager', '&Calltip'), |
|
1402 QKeySequence(QCoreApplication.translate( |
|
1403 'ViewManager', "Meta+Alt+Space", "Edit|Calltip")), |
|
1404 0, |
|
1405 self.editActGrp, 'vm_edit_calltip') |
|
1406 self.calltipsAct.setStatusTip(QCoreApplication.translate( |
|
1407 'ViewManager', 'Show Calltips')) |
|
1408 self.calltipsAct.setWhatsThis(QCoreApplication.translate( |
|
1409 'ViewManager', |
|
1410 """<b>Calltip</b>""" |
|
1411 """<p>Show calltips based on the characters immediately to the""" |
|
1412 """ left of the cursor.</p>""" |
|
1413 )) |
|
1414 self.calltipsAct.triggered.connect(self.__editShowCallTips) |
|
1415 self.editActions.append(self.calltipsAct) |
|
1416 |
|
1417 self.codeInfoAct = E5Action( |
|
1418 QCoreApplication.translate('ViewManager', 'Code Info'), |
|
1419 UI.PixmapCache.getIcon("codeDocuViewer.png"), |
|
1420 QCoreApplication.translate('ViewManager', 'Code Info'), |
|
1421 QKeySequence(QCoreApplication.translate( |
|
1422 'ViewManager', "Ctrl+Alt+I", "Edit|Code Info")), |
|
1423 0, |
|
1424 self.editActGrp, 'vm_edit_codeinfo') |
|
1425 self.codeInfoAct.setStatusTip(QCoreApplication.translate( |
|
1426 'ViewManager', 'Show Code Info')) |
|
1427 self.codeInfoAct.setWhatsThis(QCoreApplication.translate( |
|
1428 'ViewManager', |
|
1429 """<b>Code Info</b>""" |
|
1430 """<p>Show code information based on the cursor position.</p>""" |
|
1431 )) |
|
1432 self.codeInfoAct.triggered.connect(self.__editShowCodeInfo) |
|
1433 self.editActions.append(self.codeInfoAct) |
|
1434 |
|
1435 self.sortAct = E5Action( |
|
1436 QCoreApplication.translate('ViewManager', 'Sort'), |
|
1437 QCoreApplication.translate('ViewManager', 'Sort'), |
|
1438 QKeySequence(QCoreApplication.translate( |
|
1439 'ViewManager', "Ctrl+Alt+S", "Edit|Sort")), |
|
1440 0, |
|
1441 self.editActGrp, 'vm_edit_sort') |
|
1442 self.sortAct.setStatusTip(QCoreApplication.translate( |
|
1443 'ViewManager', |
|
1444 'Sort the lines containing the rectangular selection')) |
|
1445 self.sortAct.setWhatsThis(QCoreApplication.translate( |
|
1446 'ViewManager', |
|
1447 """<b>Sort</b>""" |
|
1448 """<p>Sort the lines spanned by a rectangular selection based on""" |
|
1449 """ the selection ignoring leading and trailing whitespace.</p>""" |
|
1450 )) |
|
1451 self.sortAct.triggered.connect(self.__editSortSelectedLines) |
|
1452 self.editActions.append(self.sortAct) |
|
1453 |
|
1454 self.editActGrp.setEnabled(False) |
|
1455 self.copyActGrp.setEnabled(False) |
|
1456 |
|
1457 #################################################################### |
|
1458 ## Below follow the actions for QScintilla standard commands. |
|
1459 #################################################################### |
|
1460 |
|
1461 self.esm = QSignalMapper(self) |
|
1462 self.esm.mapped[int].connect(self.__editorCommand) |
|
1463 |
|
1464 self.editorActGrp = createActionGroup(self.editActGrp) |
|
1465 |
|
1466 act = E5Action( |
|
1467 QCoreApplication.translate('ViewManager', |
|
1468 'Move left one character'), |
|
1469 QCoreApplication.translate('ViewManager', |
|
1470 'Move left one character'), |
|
1471 QKeySequence(QCoreApplication.translate('ViewManager', 'Left')), 0, |
|
1472 self.editorActGrp, 'vm_edit_move_left_char') |
|
1473 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) |
|
1474 if isMacPlatform(): |
|
1475 act.setAlternateShortcut(QKeySequence( |
|
1476 QCoreApplication.translate('ViewManager', 'Meta+B'))) |
|
1477 act.triggered.connect(self.esm.map) |
|
1478 self.editActions.append(act) |
|
1479 |
|
1480 act = E5Action( |
|
1481 QCoreApplication.translate('ViewManager', |
|
1482 'Move right one character'), |
|
1483 QCoreApplication.translate('ViewManager', |
|
1484 'Move right one character'), |
|
1485 QKeySequence(QCoreApplication.translate('ViewManager', 'Right')), |
|
1486 0, self.editorActGrp, 'vm_edit_move_right_char') |
|
1487 if isMacPlatform(): |
|
1488 act.setAlternateShortcut(QKeySequence( |
|
1489 QCoreApplication.translate('ViewManager', 'Meta+F'))) |
|
1490 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) |
|
1491 act.triggered.connect(self.esm.map) |
|
1492 self.editActions.append(act) |
|
1493 |
|
1494 act = E5Action( |
|
1495 QCoreApplication.translate('ViewManager', 'Move up one line'), |
|
1496 QCoreApplication.translate('ViewManager', 'Move up one line'), |
|
1497 QKeySequence(QCoreApplication.translate('ViewManager', 'Up')), 0, |
|
1498 self.editorActGrp, 'vm_edit_move_up_line') |
|
1499 if isMacPlatform(): |
|
1500 act.setAlternateShortcut(QKeySequence( |
|
1501 QCoreApplication.translate('ViewManager', 'Meta+P'))) |
|
1502 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) |
|
1503 act.triggered.connect(self.esm.map) |
|
1504 self.editActions.append(act) |
|
1505 |
|
1506 act = E5Action( |
|
1507 QCoreApplication.translate('ViewManager', 'Move down one line'), |
|
1508 QCoreApplication.translate('ViewManager', 'Move down one line'), |
|
1509 QKeySequence(QCoreApplication.translate('ViewManager', 'Down')), 0, |
|
1510 self.editorActGrp, 'vm_edit_move_down_line') |
|
1511 if isMacPlatform(): |
|
1512 act.setAlternateShortcut(QKeySequence( |
|
1513 QCoreApplication.translate('ViewManager', 'Meta+N'))) |
|
1514 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) |
|
1515 act.triggered.connect(self.esm.map) |
|
1516 self.editActions.append(act) |
|
1517 |
|
1518 act = E5Action( |
|
1519 QCoreApplication.translate('ViewManager', |
|
1520 'Move left one word part'), |
|
1521 QCoreApplication.translate('ViewManager', |
|
1522 'Move left one word part'), |
|
1523 0, 0, |
|
1524 self.editorActGrp, 'vm_edit_move_left_word_part') |
|
1525 if not isMacPlatform(): |
|
1526 act.setShortcut(QKeySequence( |
|
1527 QCoreApplication.translate('ViewManager', 'Alt+Left'))) |
|
1528 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFT) |
|
1529 act.triggered.connect(self.esm.map) |
|
1530 self.editActions.append(act) |
|
1531 |
|
1532 act = E5Action( |
|
1533 QCoreApplication.translate('ViewManager', |
|
1534 'Move right one word part'), |
|
1535 QCoreApplication.translate('ViewManager', |
|
1536 'Move right one word part'), |
|
1537 0, 0, |
|
1538 self.editorActGrp, 'vm_edit_move_right_word_part') |
|
1539 if not isMacPlatform(): |
|
1540 act.setShortcut(QKeySequence( |
|
1541 QCoreApplication.translate('ViewManager', 'Alt+Right'))) |
|
1542 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHT) |
|
1543 act.triggered.connect(self.esm.map) |
|
1544 self.editActions.append(act) |
|
1545 |
|
1546 act = E5Action( |
|
1547 QCoreApplication.translate('ViewManager', 'Move left one word'), |
|
1548 QCoreApplication.translate('ViewManager', 'Move left one word'), |
|
1549 0, 0, |
|
1550 self.editorActGrp, 'vm_edit_move_left_word') |
|
1551 if isMacPlatform(): |
|
1552 act.setShortcut(QKeySequence( |
|
1553 QCoreApplication.translate('ViewManager', 'Alt+Left'))) |
|
1554 else: |
|
1555 act.setShortcut(QKeySequence( |
|
1556 QCoreApplication.translate('ViewManager', 'Ctrl+Left'))) |
|
1557 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFT) |
|
1558 act.triggered.connect(self.esm.map) |
|
1559 self.editActions.append(act) |
|
1560 |
|
1561 act = E5Action( |
|
1562 QCoreApplication.translate('ViewManager', 'Move right one word'), |
|
1563 QCoreApplication.translate('ViewManager', 'Move right one word'), |
|
1564 0, 0, |
|
1565 self.editorActGrp, 'vm_edit_move_right_word') |
|
1566 if not isMacPlatform(): |
|
1567 act.setShortcut(QKeySequence( |
|
1568 QCoreApplication.translate('ViewManager', 'Ctrl+Right'))) |
|
1569 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) |
|
1570 act.triggered.connect(self.esm.map) |
|
1571 self.editActions.append(act) |
|
1572 |
|
1573 act = E5Action( |
|
1574 QCoreApplication.translate( |
|
1575 'ViewManager', |
|
1576 'Move to first visible character in document line'), |
|
1577 QCoreApplication.translate( |
|
1578 'ViewManager', |
|
1579 'Move to first visible character in document line'), |
|
1580 0, 0, |
|
1581 self.editorActGrp, 'vm_edit_move_first_visible_char') |
|
1582 if not isMacPlatform(): |
|
1583 act.setShortcut(QKeySequence( |
|
1584 QCoreApplication.translate('ViewManager', 'Home'))) |
|
1585 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) |
|
1586 act.triggered.connect(self.esm.map) |
|
1587 self.editActions.append(act) |
|
1588 |
|
1589 act = E5Action( |
|
1590 QCoreApplication.translate( |
|
1591 'ViewManager', 'Move to start of display line'), |
|
1592 QCoreApplication.translate( |
|
1593 'ViewManager', 'Move to start of display line'), |
|
1594 0, 0, |
|
1595 self.editorActGrp, 'vm_edit_move_start_line') |
|
1596 if isMacPlatform(): |
|
1597 act.setShortcut(QKeySequence( |
|
1598 QCoreApplication.translate('ViewManager', 'Ctrl+Left'))) |
|
1599 else: |
|
1600 act.setShortcut(QKeySequence( |
|
1601 QCoreApplication.translate('ViewManager', 'Alt+Home'))) |
|
1602 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAY) |
|
1603 act.triggered.connect(self.esm.map) |
|
1604 self.editActions.append(act) |
|
1605 |
|
1606 act = E5Action( |
|
1607 QCoreApplication.translate( |
|
1608 'ViewManager', 'Move to end of document line'), |
|
1609 QCoreApplication.translate( |
|
1610 'ViewManager', 'Move to end of document line'), |
|
1611 0, 0, |
|
1612 self.editorActGrp, 'vm_edit_move_end_line') |
|
1613 if isMacPlatform(): |
|
1614 act.setShortcut(QKeySequence( |
|
1615 QCoreApplication.translate('ViewManager', 'Meta+E'))) |
|
1616 else: |
|
1617 act.setShortcut(QKeySequence( |
|
1618 QCoreApplication.translate('ViewManager', 'End'))) |
|
1619 self.esm.setMapping(act, QsciScintilla.SCI_LINEEND) |
|
1620 act.triggered.connect(self.esm.map) |
|
1621 self.editActions.append(act) |
|
1622 |
|
1623 act = E5Action( |
|
1624 QCoreApplication.translate('ViewManager', |
|
1625 'Scroll view down one line'), |
|
1626 QCoreApplication.translate('ViewManager', |
|
1627 'Scroll view down one line'), |
|
1628 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1629 'Ctrl+Down')), |
|
1630 0, self.editorActGrp, 'vm_edit_scroll_down_line') |
|
1631 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLDOWN) |
|
1632 act.triggered.connect(self.esm.map) |
|
1633 self.editActions.append(act) |
|
1634 |
|
1635 act = E5Action( |
|
1636 QCoreApplication.translate('ViewManager', |
|
1637 'Scroll view up one line'), |
|
1638 QCoreApplication.translate('ViewManager', |
|
1639 'Scroll view up one line'), |
|
1640 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+Up')), |
|
1641 0, self.editorActGrp, 'vm_edit_scroll_up_line') |
|
1642 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLUP) |
|
1643 act.triggered.connect(self.esm.map) |
|
1644 self.editActions.append(act) |
|
1645 |
|
1646 act = E5Action( |
|
1647 QCoreApplication.translate('ViewManager', 'Move up one paragraph'), |
|
1648 QCoreApplication.translate('ViewManager', 'Move up one paragraph'), |
|
1649 QKeySequence(QCoreApplication.translate('ViewManager', 'Alt+Up')), |
|
1650 0, self.editorActGrp, 'vm_edit_move_up_para') |
|
1651 self.esm.setMapping(act, QsciScintilla.SCI_PARAUP) |
|
1652 act.triggered.connect(self.esm.map) |
|
1653 self.editActions.append(act) |
|
1654 |
|
1655 act = E5Action( |
|
1656 QCoreApplication.translate('ViewManager', |
|
1657 'Move down one paragraph'), |
|
1658 QCoreApplication.translate('ViewManager', |
|
1659 'Move down one paragraph'), |
|
1660 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1661 'Alt+Down')), |
|
1662 0, self.editorActGrp, 'vm_edit_move_down_para') |
|
1663 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWN) |
|
1664 act.triggered.connect(self.esm.map) |
|
1665 self.editActions.append(act) |
|
1666 |
|
1667 act = E5Action( |
|
1668 QCoreApplication.translate('ViewManager', 'Move up one page'), |
|
1669 QCoreApplication.translate('ViewManager', 'Move up one page'), |
|
1670 QKeySequence(QCoreApplication.translate('ViewManager', 'PgUp')), 0, |
|
1671 self.editorActGrp, 'vm_edit_move_up_page') |
|
1672 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUP) |
|
1673 act.triggered.connect(self.esm.map) |
|
1674 self.editActions.append(act) |
|
1675 |
|
1676 act = E5Action( |
|
1677 QCoreApplication.translate('ViewManager', 'Move down one page'), |
|
1678 QCoreApplication.translate('ViewManager', 'Move down one page'), |
|
1679 QKeySequence(QCoreApplication.translate('ViewManager', 'PgDown')), |
|
1680 0, self.editorActGrp, 'vm_edit_move_down_page') |
|
1681 if isMacPlatform(): |
|
1682 act.setAlternateShortcut(QKeySequence( |
|
1683 QCoreApplication.translate('ViewManager', 'Meta+V'))) |
|
1684 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) |
|
1685 act.triggered.connect(self.esm.map) |
|
1686 self.editActions.append(act) |
|
1687 |
|
1688 act = E5Action( |
|
1689 QCoreApplication.translate('ViewManager', |
|
1690 'Move to start of document'), |
|
1691 QCoreApplication.translate('ViewManager', |
|
1692 'Move to start of document'), |
|
1693 0, 0, |
|
1694 self.editorActGrp, 'vm_edit_move_start_text') |
|
1695 if isMacPlatform(): |
|
1696 act.setShortcut(QKeySequence( |
|
1697 QCoreApplication.translate('ViewManager', 'Ctrl+Up'))) |
|
1698 else: |
|
1699 act.setShortcut(QKeySequence( |
|
1700 QCoreApplication.translate('ViewManager', 'Ctrl+Home'))) |
|
1701 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTART) |
|
1702 act.triggered.connect(self.esm.map) |
|
1703 self.editActions.append(act) |
|
1704 |
|
1705 act = E5Action( |
|
1706 QCoreApplication.translate('ViewManager', |
|
1707 'Move to end of document'), |
|
1708 QCoreApplication.translate('ViewManager', |
|
1709 'Move to end of document'), |
|
1710 0, 0, |
|
1711 self.editorActGrp, 'vm_edit_move_end_text') |
|
1712 if isMacPlatform(): |
|
1713 act.setShortcut(QKeySequence( |
|
1714 QCoreApplication.translate('ViewManager', 'Ctrl+Down'))) |
|
1715 else: |
|
1716 act.setShortcut(QKeySequence( |
|
1717 QCoreApplication.translate('ViewManager', 'Ctrl+End'))) |
|
1718 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTEND) |
|
1719 act.triggered.connect(self.esm.map) |
|
1720 self.editActions.append(act) |
|
1721 |
|
1722 act = E5Action( |
|
1723 QCoreApplication.translate('ViewManager', 'Indent one level'), |
|
1724 QCoreApplication.translate('ViewManager', 'Indent one level'), |
|
1725 QKeySequence(QCoreApplication.translate('ViewManager', 'Tab')), 0, |
|
1726 self.editorActGrp, 'vm_edit_indent_one_level') |
|
1727 self.esm.setMapping(act, QsciScintilla.SCI_TAB) |
|
1728 act.triggered.connect(self.esm.map) |
|
1729 self.editActions.append(act) |
|
1730 |
|
1731 act = E5Action( |
|
1732 QCoreApplication.translate('ViewManager', 'Unindent one level'), |
|
1733 QCoreApplication.translate('ViewManager', 'Unindent one level'), |
|
1734 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1735 'Shift+Tab')), |
|
1736 0, self.editorActGrp, 'vm_edit_unindent_one_level') |
|
1737 self.esm.setMapping(act, QsciScintilla.SCI_BACKTAB) |
|
1738 act.triggered.connect(self.esm.map) |
|
1739 self.editActions.append(act) |
|
1740 |
|
1741 act = E5Action( |
|
1742 QCoreApplication.translate( |
|
1743 'ViewManager', 'Extend selection left one character'), |
|
1744 QCoreApplication.translate( |
|
1745 'ViewManager', 'Extend selection left one character'), |
|
1746 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1747 'Shift+Left')), |
|
1748 0, self.editorActGrp, 'vm_edit_extend_selection_left_char') |
|
1749 if isMacPlatform(): |
|
1750 act.setAlternateShortcut(QKeySequence( |
|
1751 QCoreApplication.translate('ViewManager', 'Meta+Shift+B'))) |
|
1752 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) |
|
1753 act.triggered.connect(self.esm.map) |
|
1754 self.editActions.append(act) |
|
1755 |
|
1756 act = E5Action( |
|
1757 QCoreApplication.translate( |
|
1758 'ViewManager', 'Extend selection right one character'), |
|
1759 QCoreApplication.translate( |
|
1760 'ViewManager', 'Extend selection right one character'), |
|
1761 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1762 'Shift+Right')), |
|
1763 0, self.editorActGrp, 'vm_edit_extend_selection_right_char') |
|
1764 if isMacPlatform(): |
|
1765 act.setAlternateShortcut(QKeySequence( |
|
1766 QCoreApplication.translate('ViewManager', 'Meta+Shift+F'))) |
|
1767 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) |
|
1768 act.triggered.connect(self.esm.map) |
|
1769 self.editActions.append(act) |
|
1770 |
|
1771 act = E5Action( |
|
1772 QCoreApplication.translate( |
|
1773 'ViewManager', 'Extend selection up one line'), |
|
1774 QCoreApplication.translate( |
|
1775 'ViewManager', 'Extend selection up one line'), |
|
1776 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1777 'Shift+Up')), |
|
1778 0, self.editorActGrp, 'vm_edit_extend_selection_up_line') |
|
1779 if isMacPlatform(): |
|
1780 act.setAlternateShortcut(QKeySequence( |
|
1781 QCoreApplication.translate('ViewManager', 'Meta+Shift+P'))) |
|
1782 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPEXTEND) |
|
1783 act.triggered.connect(self.esm.map) |
|
1784 self.editActions.append(act) |
|
1785 |
|
1786 act = E5Action( |
|
1787 QCoreApplication.translate( |
|
1788 'ViewManager', 'Extend selection down one line'), |
|
1789 QCoreApplication.translate( |
|
1790 'ViewManager', 'Extend selection down one line'), |
|
1791 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1792 'Shift+Down')), |
|
1793 0, self.editorActGrp, 'vm_edit_extend_selection_down_line') |
|
1794 if isMacPlatform(): |
|
1795 act.setAlternateShortcut(QKeySequence( |
|
1796 QCoreApplication.translate('ViewManager', 'Meta+Shift+N'))) |
|
1797 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNEXTEND) |
|
1798 act.triggered.connect(self.esm.map) |
|
1799 self.editActions.append(act) |
|
1800 |
|
1801 act = E5Action( |
|
1802 QCoreApplication.translate( |
|
1803 'ViewManager', 'Extend selection left one word part'), |
|
1804 QCoreApplication.translate( |
|
1805 'ViewManager', 'Extend selection left one word part'), |
|
1806 0, 0, |
|
1807 self.editorActGrp, 'vm_edit_extend_selection_left_word_part') |
|
1808 if not isMacPlatform(): |
|
1809 act.setShortcut(QKeySequence( |
|
1810 QCoreApplication.translate('ViewManager', 'Alt+Shift+Left'))) |
|
1811 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFTEXTEND) |
|
1812 act.triggered.connect(self.esm.map) |
|
1813 self.editActions.append(act) |
|
1814 |
|
1815 act = E5Action( |
|
1816 QCoreApplication.translate( |
|
1817 'ViewManager', 'Extend selection right one word part'), |
|
1818 QCoreApplication.translate( |
|
1819 'ViewManager', 'Extend selection right one word part'), |
|
1820 0, 0, |
|
1821 self.editorActGrp, 'vm_edit_extend_selection_right_word_part') |
|
1822 if not isMacPlatform(): |
|
1823 act.setShortcut(QKeySequence( |
|
1824 QCoreApplication.translate('ViewManager', 'Alt+Shift+Right'))) |
|
1825 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHTEXTEND) |
|
1826 act.triggered.connect(self.esm.map) |
|
1827 self.editActions.append(act) |
|
1828 |
|
1829 act = E5Action( |
|
1830 QCoreApplication.translate( |
|
1831 'ViewManager', 'Extend selection left one word'), |
|
1832 QCoreApplication.translate( |
|
1833 'ViewManager', 'Extend selection left one word'), |
|
1834 0, 0, |
|
1835 self.editorActGrp, 'vm_edit_extend_selection_left_word') |
|
1836 if isMacPlatform(): |
|
1837 act.setShortcut(QKeySequence( |
|
1838 QCoreApplication.translate('ViewManager', 'Alt+Shift+Left'))) |
|
1839 else: |
|
1840 act.setShortcut(QKeySequence( |
|
1841 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Left'))) |
|
1842 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEXTEND) |
|
1843 act.triggered.connect(self.esm.map) |
|
1844 self.editActions.append(act) |
|
1845 |
|
1846 act = E5Action( |
|
1847 QCoreApplication.translate( |
|
1848 'ViewManager', 'Extend selection right one word'), |
|
1849 QCoreApplication.translate( |
|
1850 'ViewManager', 'Extend selection right one word'), |
|
1851 0, 0, |
|
1852 self.editorActGrp, 'vm_edit_extend_selection_right_word') |
|
1853 if isMacPlatform(): |
|
1854 act.setShortcut(QKeySequence( |
|
1855 QCoreApplication.translate('ViewManager', 'Alt+Shift+Right'))) |
|
1856 else: |
|
1857 act.setShortcut(QKeySequence( |
|
1858 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Right'))) |
|
1859 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEXTEND) |
|
1860 act.triggered.connect(self.esm.map) |
|
1861 self.editActions.append(act) |
|
1862 |
|
1863 act = E5Action( |
|
1864 QCoreApplication.translate( |
|
1865 'ViewManager', |
|
1866 'Extend selection to first visible character in document' |
|
1867 ' line'), |
|
1868 QCoreApplication.translate( |
|
1869 'ViewManager', |
|
1870 'Extend selection to first visible character in document' |
|
1871 ' line'), |
|
1872 0, 0, |
|
1873 self.editorActGrp, 'vm_edit_extend_selection_first_visible_char') |
|
1874 if not isMacPlatform(): |
|
1875 act.setShortcut(QKeySequence( |
|
1876 QCoreApplication.translate('ViewManager', 'Shift+Home'))) |
|
1877 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) |
|
1878 act.triggered.connect(self.esm.map) |
|
1879 self.editActions.append(act) |
|
1880 |
|
1881 act = E5Action( |
|
1882 QCoreApplication.translate( |
|
1883 'ViewManager', 'Extend selection to end of document line'), |
|
1884 QCoreApplication.translate( |
|
1885 'ViewManager', 'Extend selection to end of document line'), |
|
1886 0, 0, |
|
1887 self.editorActGrp, 'vm_edit_extend_selection_end_line') |
|
1888 if isMacPlatform(): |
|
1889 act.setShortcut(QKeySequence( |
|
1890 QCoreApplication.translate('ViewManager', 'Meta+Shift+E'))) |
|
1891 else: |
|
1892 act.setShortcut(QKeySequence( |
|
1893 QCoreApplication.translate('ViewManager', 'Shift+End'))) |
|
1894 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDEXTEND) |
|
1895 act.triggered.connect(self.esm.map) |
|
1896 self.editActions.append(act) |
|
1897 |
|
1898 act = E5Action( |
|
1899 QCoreApplication.translate( |
|
1900 'ViewManager', 'Extend selection up one paragraph'), |
|
1901 QCoreApplication.translate( |
|
1902 'ViewManager', 'Extend selection up one paragraph'), |
|
1903 QKeySequence(QCoreApplication.translate( |
|
1904 'ViewManager', 'Alt+Shift+Up')), |
|
1905 0, |
|
1906 self.editorActGrp, 'vm_edit_extend_selection_up_para') |
|
1907 self.esm.setMapping(act, QsciScintilla.SCI_PARAUPEXTEND) |
|
1908 act.triggered.connect(self.esm.map) |
|
1909 self.editActions.append(act) |
|
1910 |
|
1911 act = E5Action( |
|
1912 QCoreApplication.translate( |
|
1913 'ViewManager', 'Extend selection down one paragraph'), |
|
1914 QCoreApplication.translate( |
|
1915 'ViewManager', 'Extend selection down one paragraph'), |
|
1916 QKeySequence(QCoreApplication.translate( |
|
1917 'ViewManager', 'Alt+Shift+Down')), |
|
1918 0, |
|
1919 self.editorActGrp, 'vm_edit_extend_selection_down_para') |
|
1920 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWNEXTEND) |
|
1921 act.triggered.connect(self.esm.map) |
|
1922 self.editActions.append(act) |
|
1923 |
|
1924 act = E5Action( |
|
1925 QCoreApplication.translate( |
|
1926 'ViewManager', 'Extend selection up one page'), |
|
1927 QCoreApplication.translate( |
|
1928 'ViewManager', 'Extend selection up one page'), |
|
1929 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1930 'Shift+PgUp')), |
|
1931 0, self.editorActGrp, 'vm_edit_extend_selection_up_page') |
|
1932 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPEXTEND) |
|
1933 act.triggered.connect(self.esm.map) |
|
1934 self.editActions.append(act) |
|
1935 |
|
1936 act = E5Action( |
|
1937 QCoreApplication.translate( |
|
1938 'ViewManager', 'Extend selection down one page'), |
|
1939 QCoreApplication.translate( |
|
1940 'ViewManager', 'Extend selection down one page'), |
|
1941 QKeySequence(QCoreApplication.translate( |
|
1942 'ViewManager', 'Shift+PgDown')), |
|
1943 0, |
|
1944 self.editorActGrp, 'vm_edit_extend_selection_down_page') |
|
1945 if isMacPlatform(): |
|
1946 act.setAlternateShortcut(QKeySequence( |
|
1947 QCoreApplication.translate('ViewManager', 'Meta+Shift+V'))) |
|
1948 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNEXTEND) |
|
1949 act.triggered.connect(self.esm.map) |
|
1950 self.editActions.append(act) |
|
1951 |
|
1952 act = E5Action( |
|
1953 QCoreApplication.translate( |
|
1954 'ViewManager', 'Extend selection to start of document'), |
|
1955 QCoreApplication.translate( |
|
1956 'ViewManager', 'Extend selection to start of document'), |
|
1957 0, 0, |
|
1958 self.editorActGrp, 'vm_edit_extend_selection_start_text') |
|
1959 if isMacPlatform(): |
|
1960 act.setShortcut(QKeySequence( |
|
1961 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Up'))) |
|
1962 else: |
|
1963 act.setShortcut(QKeySequence( |
|
1964 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Home'))) |
|
1965 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTARTEXTEND) |
|
1966 act.triggered.connect(self.esm.map) |
|
1967 self.editActions.append(act) |
|
1968 |
|
1969 act = E5Action( |
|
1970 QCoreApplication.translate( |
|
1971 'ViewManager', 'Extend selection to end of document'), |
|
1972 QCoreApplication.translate( |
|
1973 'ViewManager', 'Extend selection to end of document'), |
|
1974 0, 0, |
|
1975 self.editorActGrp, 'vm_edit_extend_selection_end_text') |
|
1976 if isMacPlatform(): |
|
1977 act.setShortcut(QKeySequence( |
|
1978 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Down'))) |
|
1979 else: |
|
1980 act.setShortcut(QKeySequence( |
|
1981 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+End'))) |
|
1982 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTENDEXTEND) |
|
1983 act.triggered.connect(self.esm.map) |
|
1984 self.editActions.append(act) |
|
1985 |
|
1986 act = E5Action( |
|
1987 QCoreApplication.translate('ViewManager', |
|
1988 'Delete previous character'), |
|
1989 QCoreApplication.translate('ViewManager', |
|
1990 'Delete previous character'), |
|
1991 QKeySequence(QCoreApplication.translate('ViewManager', |
|
1992 'Backspace')), |
|
1993 0, self.editorActGrp, 'vm_edit_delete_previous_char') |
|
1994 if isMacPlatform(): |
|
1995 act.setAlternateShortcut(QKeySequence( |
|
1996 QCoreApplication.translate('ViewManager', 'Meta+H'))) |
|
1997 else: |
|
1998 act.setAlternateShortcut(QKeySequence( |
|
1999 QCoreApplication.translate('ViewManager', 'Shift+Backspace'))) |
|
2000 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACK) |
|
2001 act.triggered.connect(self.esm.map) |
|
2002 self.editActions.append(act) |
|
2003 |
|
2004 act = E5Action( |
|
2005 QCoreApplication.translate( |
|
2006 'ViewManager', |
|
2007 'Delete previous character if not at start of line'), |
|
2008 QCoreApplication.translate( |
|
2009 'ViewManager', |
|
2010 'Delete previous character if not at start of line'), |
|
2011 0, 0, |
|
2012 self.editorActGrp, 'vm_edit_delet_previous_char_not_line_start') |
|
2013 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACKNOTLINE) |
|
2014 act.triggered.connect(self.esm.map) |
|
2015 self.editActions.append(act) |
|
2016 |
|
2017 act = E5Action( |
|
2018 QCoreApplication.translate('ViewManager', |
|
2019 'Delete current character'), |
|
2020 QCoreApplication.translate('ViewManager', |
|
2021 'Delete current character'), |
|
2022 QKeySequence(QCoreApplication.translate('ViewManager', 'Del')), |
|
2023 0, self.editorActGrp, 'vm_edit_delete_current_char') |
|
2024 if isMacPlatform(): |
|
2025 act.setAlternateShortcut(QKeySequence( |
|
2026 QCoreApplication.translate('ViewManager', 'Meta+D'))) |
|
2027 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) |
|
2028 act.triggered.connect(self.esm.map) |
|
2029 self.editActions.append(act) |
|
2030 |
|
2031 act = E5Action( |
|
2032 QCoreApplication.translate('ViewManager', 'Delete word to left'), |
|
2033 QCoreApplication.translate('ViewManager', 'Delete word to left'), |
|
2034 QKeySequence(QCoreApplication.translate( |
|
2035 'ViewManager', 'Ctrl+Backspace')), |
|
2036 0, |
|
2037 self.editorActGrp, 'vm_edit_delete_word_left') |
|
2038 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDLEFT) |
|
2039 act.triggered.connect(self.esm.map) |
|
2040 self.editActions.append(act) |
|
2041 |
|
2042 act = E5Action( |
|
2043 QCoreApplication.translate('ViewManager', 'Delete word to right'), |
|
2044 QCoreApplication.translate('ViewManager', 'Delete word to right'), |
|
2045 QKeySequence(QCoreApplication.translate('ViewManager', |
|
2046 'Ctrl+Del')), |
|
2047 0, self.editorActGrp, 'vm_edit_delete_word_right') |
|
2048 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHT) |
|
2049 act.triggered.connect(self.esm.map) |
|
2050 self.editActions.append(act) |
|
2051 |
|
2052 act = E5Action( |
|
2053 QCoreApplication.translate('ViewManager', 'Delete line to left'), |
|
2054 QCoreApplication.translate('ViewManager', 'Delete line to left'), |
|
2055 QKeySequence(QCoreApplication.translate( |
|
2056 'ViewManager', 'Ctrl+Shift+Backspace')), |
|
2057 0, |
|
2058 self.editorActGrp, 'vm_edit_delete_line_left') |
|
2059 self.esm.setMapping(act, QsciScintilla.SCI_DELLINELEFT) |
|
2060 act.triggered.connect(self.esm.map) |
|
2061 self.editActions.append(act) |
|
2062 |
|
2063 act = E5Action( |
|
2064 QCoreApplication.translate('ViewManager', 'Delete line to right'), |
|
2065 QCoreApplication.translate('ViewManager', 'Delete line to right'), |
|
2066 0, 0, |
|
2067 self.editorActGrp, 'vm_edit_delete_line_right') |
|
2068 if isMacPlatform(): |
|
2069 act.setShortcut(QKeySequence( |
|
2070 QCoreApplication.translate('ViewManager', 'Meta+K'))) |
|
2071 else: |
|
2072 act.setShortcut(QKeySequence( |
|
2073 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Del'))) |
|
2074 self.esm.setMapping(act, QsciScintilla.SCI_DELLINERIGHT) |
|
2075 act.triggered.connect(self.esm.map) |
|
2076 self.editActions.append(act) |
|
2077 |
|
2078 act = E5Action( |
|
2079 QCoreApplication.translate('ViewManager', 'Insert new line'), |
|
2080 QCoreApplication.translate('ViewManager', 'Insert new line'), |
|
2081 QKeySequence(QCoreApplication.translate('ViewManager', 'Return')), |
|
2082 QKeySequence(QCoreApplication.translate('ViewManager', 'Enter')), |
|
2083 self.editorActGrp, 'vm_edit_insert_line') |
|
2084 self.esm.setMapping(act, QsciScintilla.SCI_NEWLINE) |
|
2085 act.triggered.connect(self.esm.map) |
|
2086 self.editActions.append(act) |
|
2087 |
|
2088 act = E5Action( |
|
2089 QCoreApplication.translate( |
|
2090 'ViewManager', 'Insert new line below current line'), |
|
2091 QCoreApplication.translate( |
|
2092 'ViewManager', 'Insert new line below current line'), |
|
2093 QKeySequence(QCoreApplication.translate( |
|
2094 'ViewManager', 'Shift+Return')), |
|
2095 QKeySequence(QCoreApplication.translate('ViewManager', |
|
2096 'Shift+Enter')), |
|
2097 self.editorActGrp, 'vm_edit_insert_line_below') |
|
2098 act.triggered.connect(self.__newLineBelow) |
|
2099 self.editActions.append(act) |
|
2100 |
|
2101 act = E5Action( |
|
2102 QCoreApplication.translate('ViewManager', 'Delete current line'), |
|
2103 QCoreApplication.translate('ViewManager', 'Delete current line'), |
|
2104 QKeySequence(QCoreApplication.translate( |
|
2105 'ViewManager', 'Ctrl+Shift+L')), |
|
2106 0, |
|
2107 self.editorActGrp, 'vm_edit_delete_current_line') |
|
2108 self.esm.setMapping(act, QsciScintilla.SCI_LINEDELETE) |
|
2109 act.triggered.connect(self.esm.map) |
|
2110 self.editActions.append(act) |
|
2111 |
|
2112 act = E5Action( |
|
2113 QCoreApplication.translate( |
|
2114 'ViewManager', 'Duplicate current line'), |
|
2115 QCoreApplication.translate( |
|
2116 'ViewManager', 'Duplicate current line'), |
|
2117 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+D')), |
|
2118 0, self.editorActGrp, 'vm_edit_duplicate_current_line') |
|
2119 self.esm.setMapping(act, QsciScintilla.SCI_LINEDUPLICATE) |
|
2120 act.triggered.connect(self.esm.map) |
|
2121 self.editActions.append(act) |
|
2122 |
|
2123 act = E5Action( |
|
2124 QCoreApplication.translate( |
|
2125 'ViewManager', 'Swap current and previous lines'), |
|
2126 QCoreApplication.translate( |
|
2127 'ViewManager', 'Swap current and previous lines'), |
|
2128 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+T')), |
|
2129 0, self.editorActGrp, 'vm_edit_swap_current_previous_line') |
|
2130 self.esm.setMapping(act, QsciScintilla.SCI_LINETRANSPOSE) |
|
2131 act.triggered.connect(self.esm.map) |
|
2132 self.editActions.append(act) |
|
2133 |
|
2134 if QSCINTILLA_VERSION() >= 0x020B00: |
|
2135 act = E5Action( |
|
2136 QCoreApplication.translate('ViewManager', |
|
2137 'Reverse selected lines'), |
|
2138 QCoreApplication.translate('ViewManager', |
|
2139 'Reverse selected lines'), |
|
2140 QKeySequence(QCoreApplication.translate('ViewManager', |
|
2141 'Meta+Alt+R')), |
|
2142 0, self.editorActGrp, 'vm_edit_reverse selected_lines') |
|
2143 self.esm.setMapping(act, QsciScintilla.SCI_LINEREVERSE) |
|
2144 act.triggered.connect(self.esm.map) |
|
2145 self.editActions.append(act) |
|
2146 |
|
2147 act = E5Action( |
|
2148 QCoreApplication.translate('ViewManager', 'Cut current line'), |
|
2149 QCoreApplication.translate('ViewManager', 'Cut current line'), |
|
2150 QKeySequence(QCoreApplication.translate('ViewManager', |
|
2151 'Alt+Shift+L')), |
|
2152 0, self.editorActGrp, 'vm_edit_cut_current_line') |
|
2153 self.esm.setMapping(act, QsciScintilla.SCI_LINECUT) |
|
2154 act.triggered.connect(self.esm.map) |
|
2155 self.editActions.append(act) |
|
2156 |
|
2157 act = E5Action( |
|
2158 QCoreApplication.translate('ViewManager', 'Copy current line'), |
|
2159 QCoreApplication.translate('ViewManager', 'Copy current line'), |
|
2160 QKeySequence(QCoreApplication.translate( |
|
2161 'ViewManager', 'Ctrl+Shift+T')), |
|
2162 0, |
|
2163 self.editorActGrp, 'vm_edit_copy_current_line') |
|
2164 self.esm.setMapping(act, QsciScintilla.SCI_LINECOPY) |
|
2165 act.triggered.connect(self.esm.map) |
|
2166 self.editActions.append(act) |
|
2167 |
|
2168 act = E5Action( |
|
2169 QCoreApplication.translate( |
|
2170 'ViewManager', 'Toggle insert/overtype'), |
|
2171 QCoreApplication.translate( |
|
2172 'ViewManager', 'Toggle insert/overtype'), |
|
2173 QKeySequence(QCoreApplication.translate('ViewManager', 'Ins')), |
|
2174 0, self.editorActGrp, 'vm_edit_toggle_insert_overtype') |
|
2175 self.esm.setMapping(act, QsciScintilla.SCI_EDITTOGGLEOVERTYPE) |
|
2176 act.triggered.connect(self.esm.map) |
|
2177 self.editActions.append(act) |
|
2178 |
|
2179 act = E5Action( |
|
2180 QCoreApplication.translate( |
|
2181 'ViewManager', 'Move to end of display line'), |
|
2182 QCoreApplication.translate( |
|
2183 'ViewManager', 'Move to end of display line'), |
|
2184 0, 0, |
|
2185 self.editorActGrp, 'vm_edit_move_end_displayed_line') |
|
2186 if isMacPlatform(): |
|
2187 act.setShortcut(QKeySequence( |
|
2188 QCoreApplication.translate('ViewManager', 'Ctrl+Right'))) |
|
2189 else: |
|
2190 act.setShortcut(QKeySequence( |
|
2191 QCoreApplication.translate('ViewManager', 'Alt+End'))) |
|
2192 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAY) |
|
2193 act.triggered.connect(self.esm.map) |
|
2194 self.editActions.append(act) |
|
2195 |
|
2196 act = E5Action( |
|
2197 QCoreApplication.translate( |
|
2198 'ViewManager', 'Extend selection to end of display line'), |
|
2199 QCoreApplication.translate( |
|
2200 'ViewManager', 'Extend selection to end of display line'), |
|
2201 0, 0, |
|
2202 self.editorActGrp, 'vm_edit_extend_selection_end_displayed_line') |
|
2203 if isMacPlatform(): |
|
2204 act.setShortcut(QKeySequence( |
|
2205 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Right'))) |
|
2206 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAYEXTEND) |
|
2207 act.triggered.connect(self.esm.map) |
|
2208 self.editActions.append(act) |
|
2209 |
|
2210 act = E5Action( |
|
2211 QCoreApplication.translate('ViewManager', 'Formfeed'), |
|
2212 QCoreApplication.translate('ViewManager', 'Formfeed'), |
|
2213 0, 0, |
|
2214 self.editorActGrp, 'vm_edit_formfeed') |
|
2215 self.esm.setMapping(act, QsciScintilla.SCI_FORMFEED) |
|
2216 act.triggered.connect(self.esm.map) |
|
2217 self.editActions.append(act) |
|
2218 |
|
2219 act = E5Action( |
|
2220 QCoreApplication.translate('ViewManager', 'Escape'), |
|
2221 QCoreApplication.translate('ViewManager', 'Escape'), |
|
2222 QKeySequence(QCoreApplication.translate('ViewManager', 'Esc')), 0, |
|
2223 self.editorActGrp, 'vm_edit_escape') |
|
2224 self.esm.setMapping(act, QsciScintilla.SCI_CANCEL) |
|
2225 act.triggered.connect(self.esm.map) |
|
2226 self.editActions.append(act) |
|
2227 |
|
2228 act = E5Action( |
|
2229 QCoreApplication.translate( |
|
2230 'ViewManager', 'Extend rectangular selection down one line'), |
|
2231 QCoreApplication.translate( |
|
2232 'ViewManager', 'Extend rectangular selection down one line'), |
|
2233 QKeySequence(QCoreApplication.translate( |
|
2234 'ViewManager', 'Alt+Ctrl+Down')), |
|
2235 0, |
|
2236 self.editorActGrp, 'vm_edit_extend_rect_selection_down_line') |
|
2237 if isMacPlatform(): |
|
2238 act.setAlternateShortcut(QKeySequence( |
|
2239 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+N'))) |
|
2240 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNRECTEXTEND) |
|
2241 act.triggered.connect(self.esm.map) |
|
2242 self.editActions.append(act) |
|
2243 |
|
2244 act = E5Action( |
|
2245 QCoreApplication.translate( |
|
2246 'ViewManager', 'Extend rectangular selection up one line'), |
|
2247 QCoreApplication.translate( |
|
2248 'ViewManager', 'Extend rectangular selection up one line'), |
|
2249 QKeySequence(QCoreApplication.translate('ViewManager', |
|
2250 'Alt+Ctrl+Up')), |
|
2251 0, self.editorActGrp, 'vm_edit_extend_rect_selection_up_line') |
|
2252 if isMacPlatform(): |
|
2253 act.setAlternateShortcut(QKeySequence( |
|
2254 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+P'))) |
|
2255 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPRECTEXTEND) |
|
2256 act.triggered.connect(self.esm.map) |
|
2257 self.editActions.append(act) |
|
2258 |
|
2259 act = E5Action( |
|
2260 QCoreApplication.translate( |
|
2261 'ViewManager', |
|
2262 'Extend rectangular selection left one character'), |
|
2263 QCoreApplication.translate( |
|
2264 'ViewManager', |
|
2265 'Extend rectangular selection left one character'), |
|
2266 QKeySequence(QCoreApplication.translate( |
|
2267 'ViewManager', 'Alt+Ctrl+Left')), |
|
2268 0, |
|
2269 self.editorActGrp, 'vm_edit_extend_rect_selection_left_char') |
|
2270 if isMacPlatform(): |
|
2271 act.setAlternateShortcut(QKeySequence( |
|
2272 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+B'))) |
|
2273 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTRECTEXTEND) |
|
2274 act.triggered.connect(self.esm.map) |
|
2275 self.editActions.append(act) |
|
2276 |
|
2277 act = E5Action( |
|
2278 QCoreApplication.translate( |
|
2279 'ViewManager', |
|
2280 'Extend rectangular selection right one character'), |
|
2281 QCoreApplication.translate( |
|
2282 'ViewManager', |
|
2283 'Extend rectangular selection right one character'), |
|
2284 QKeySequence(QCoreApplication.translate( |
|
2285 'ViewManager', 'Alt+Ctrl+Right')), |
|
2286 0, |
|
2287 self.editorActGrp, 'vm_edit_extend_rect_selection_right_char') |
|
2288 if isMacPlatform(): |
|
2289 act.setAlternateShortcut(QKeySequence( |
|
2290 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+F'))) |
|
2291 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTRECTEXTEND) |
|
2292 act.triggered.connect(self.esm.map) |
|
2293 self.editActions.append(act) |
|
2294 |
|
2295 act = E5Action( |
|
2296 QCoreApplication.translate( |
|
2297 'ViewManager', |
|
2298 'Extend rectangular selection to first visible character in' |
|
2299 ' document line'), |
|
2300 QCoreApplication.translate( |
|
2301 'ViewManager', |
|
2302 'Extend rectangular selection to first visible character in' |
|
2303 ' document line'), |
|
2304 0, 0, |
|
2305 self.editorActGrp, |
|
2306 'vm_edit_extend_rect_selection_first_visible_char') |
|
2307 if not isMacPlatform(): |
|
2308 act.setShortcut(QKeySequence( |
|
2309 QCoreApplication.translate('ViewManager', 'Alt+Shift+Home'))) |
|
2310 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMERECTEXTEND) |
|
2311 act.triggered.connect(self.esm.map) |
|
2312 self.editActions.append(act) |
|
2313 |
|
2314 act = E5Action( |
|
2315 QCoreApplication.translate( |
|
2316 'ViewManager', |
|
2317 'Extend rectangular selection to end of document line'), |
|
2318 QCoreApplication.translate( |
|
2319 'ViewManager', |
|
2320 'Extend rectangular selection to end of document line'), |
|
2321 0, 0, |
|
2322 self.editorActGrp, 'vm_edit_extend_rect_selection_end_line') |
|
2323 if isMacPlatform(): |
|
2324 act.setShortcut(QKeySequence( |
|
2325 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+E'))) |
|
2326 else: |
|
2327 act.setShortcut(QKeySequence( |
|
2328 QCoreApplication.translate('ViewManager', 'Alt+Shift+End'))) |
|
2329 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDRECTEXTEND) |
|
2330 act.triggered.connect(self.esm.map) |
|
2331 self.editActions.append(act) |
|
2332 |
|
2333 act = E5Action( |
|
2334 QCoreApplication.translate( |
|
2335 'ViewManager', |
|
2336 'Extend rectangular selection up one page'), |
|
2337 QCoreApplication.translate( |
|
2338 'ViewManager', |
|
2339 'Extend rectangular selection up one page'), |
|
2340 QKeySequence(QCoreApplication.translate( |
|
2341 'ViewManager', 'Alt+Shift+PgUp')), |
|
2342 0, |
|
2343 self.editorActGrp, 'vm_edit_extend_rect_selection_up_page') |
|
2344 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPRECTEXTEND) |
|
2345 act.triggered.connect(self.esm.map) |
|
2346 self.editActions.append(act) |
|
2347 |
|
2348 act = E5Action( |
|
2349 QCoreApplication.translate( |
|
2350 'ViewManager', |
|
2351 'Extend rectangular selection down one page'), |
|
2352 QCoreApplication.translate( |
|
2353 'ViewManager', |
|
2354 'Extend rectangular selection down one page'), |
|
2355 QKeySequence(QCoreApplication.translate( |
|
2356 'ViewManager', 'Alt+Shift+PgDown')), |
|
2357 0, |
|
2358 self.editorActGrp, 'vm_edit_extend_rect_selection_down_page') |
|
2359 if isMacPlatform(): |
|
2360 act.setAlternateShortcut(QKeySequence( |
|
2361 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+V'))) |
|
2362 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNRECTEXTEND) |
|
2363 act.triggered.connect(self.esm.map) |
|
2364 self.editActions.append(act) |
|
2365 |
|
2366 act = E5Action( |
|
2367 QCoreApplication.translate( |
|
2368 'ViewManager', 'Duplicate current selection'), |
|
2369 QCoreApplication.translate( |
|
2370 'ViewManager', 'Duplicate current selection'), |
|
2371 QKeySequence(QCoreApplication.translate( |
|
2372 'ViewManager', 'Ctrl+Shift+D')), |
|
2373 0, |
|
2374 self.editorActGrp, 'vm_edit_duplicate_current_selection') |
|
2375 self.esm.setMapping(act, QsciScintilla.SCI_SELECTIONDUPLICATE) |
|
2376 act.triggered.connect(self.esm.map) |
|
2377 self.editActions.append(act) |
|
2378 |
|
2379 if hasattr(QsciScintilla, "SCI_SCROLLTOSTART"): |
|
2380 act = E5Action( |
|
2381 QCoreApplication.translate( |
|
2382 'ViewManager', 'Scroll to start of document'), |
|
2383 QCoreApplication.translate( |
|
2384 'ViewManager', 'Scroll to start of document'), |
|
2385 0, 0, |
|
2386 self.editorActGrp, 'vm_edit_scroll_start_text') |
|
2387 if isMacPlatform(): |
|
2388 act.setShortcut(QKeySequence( |
|
2389 QCoreApplication.translate('ViewManager', 'Home'))) |
|
2390 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOSTART) |
|
2391 act.triggered.connect(self.esm.map) |
|
2392 self.editActions.append(act) |
|
2393 |
|
2394 if hasattr(QsciScintilla, "SCI_SCROLLTOEND"): |
|
2395 act = E5Action( |
|
2396 QCoreApplication.translate( |
|
2397 'ViewManager', 'Scroll to end of document'), |
|
2398 QCoreApplication.translate( |
|
2399 'ViewManager', 'Scroll to end of document'), |
|
2400 0, 0, |
|
2401 self.editorActGrp, 'vm_edit_scroll_end_text') |
|
2402 if isMacPlatform(): |
|
2403 act.setShortcut(QKeySequence( |
|
2404 QCoreApplication.translate('ViewManager', 'End'))) |
|
2405 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOEND) |
|
2406 act.triggered.connect(self.esm.map) |
|
2407 self.editActions.append(act) |
|
2408 |
|
2409 if hasattr(QsciScintilla, "SCI_VERTICALCENTRECARET"): |
|
2410 act = E5Action( |
|
2411 QCoreApplication.translate( |
|
2412 'ViewManager', 'Scroll vertically to center current line'), |
|
2413 QCoreApplication.translate( |
|
2414 'ViewManager', 'Scroll vertically to center current line'), |
|
2415 0, 0, |
|
2416 self.editorActGrp, 'vm_edit_scroll_vertically_center') |
|
2417 if isMacPlatform(): |
|
2418 act.setShortcut(QKeySequence( |
|
2419 QCoreApplication.translate('ViewManager', 'Meta+L'))) |
|
2420 self.esm.setMapping(act, QsciScintilla.SCI_VERTICALCENTRECARET) |
|
2421 act.triggered.connect(self.esm.map) |
|
2422 self.editActions.append(act) |
|
2423 |
|
2424 if hasattr(QsciScintilla, "SCI_WORDRIGHTEND"): |
|
2425 act = E5Action( |
|
2426 QCoreApplication.translate( |
|
2427 'ViewManager', 'Move to end of next word'), |
|
2428 QCoreApplication.translate( |
|
2429 'ViewManager', 'Move to end of next word'), |
|
2430 0, 0, |
|
2431 self.editorActGrp, 'vm_edit_move_end_next_word') |
|
2432 if isMacPlatform(): |
|
2433 act.setShortcut(QKeySequence( |
|
2434 QCoreApplication.translate('ViewManager', 'Alt+Right'))) |
|
2435 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEND) |
|
2436 act.triggered.connect(self.esm.map) |
|
2437 self.editActions.append(act) |
|
2438 |
|
2439 if hasattr(QsciScintilla, "SCI_WORDRIGHTENDEXTEND"): |
|
2440 act = E5Action( |
|
2441 QCoreApplication.translate( |
|
2442 'ViewManager', 'Extend selection to end of next word'), |
|
2443 QCoreApplication.translate( |
|
2444 'ViewManager', 'Extend selection to end of next word'), |
|
2445 0, 0, |
|
2446 self.editorActGrp, 'vm_edit_select_end_next_word') |
|
2447 if isMacPlatform(): |
|
2448 act.setShortcut(QKeySequence( |
|
2449 QCoreApplication.translate('ViewManager', |
|
2450 'Alt+Shift+Right'))) |
|
2451 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTENDEXTEND) |
|
2452 act.triggered.connect(self.esm.map) |
|
2453 self.editActions.append(act) |
|
2454 |
|
2455 if hasattr(QsciScintilla, "SCI_WORDLEFTEND"): |
|
2456 act = E5Action( |
|
2457 QCoreApplication.translate( |
|
2458 'ViewManager', 'Move to end of previous word'), |
|
2459 QCoreApplication.translate( |
|
2460 'ViewManager', 'Move to end of previous word'), |
|
2461 0, 0, |
|
2462 self.editorActGrp, 'vm_edit_move_end_previous_word') |
|
2463 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEND) |
|
2464 act.triggered.connect(self.esm.map) |
|
2465 self.editActions.append(act) |
|
2466 |
|
2467 if hasattr(QsciScintilla, "SCI_WORDLEFTENDEXTEND"): |
|
2468 act = E5Action( |
|
2469 QCoreApplication.translate( |
|
2470 'ViewManager', 'Extend selection to end of previous word'), |
|
2471 QCoreApplication.translate( |
|
2472 'ViewManager', 'Extend selection to end of previous word'), |
|
2473 0, 0, |
|
2474 self.editorActGrp, 'vm_edit_select_end_previous_word') |
|
2475 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTENDEXTEND) |
|
2476 act.triggered.connect(self.esm.map) |
|
2477 self.editActions.append(act) |
|
2478 |
|
2479 if hasattr(QsciScintilla, "SCI_HOME"): |
|
2480 act = E5Action( |
|
2481 QCoreApplication.translate( |
|
2482 'ViewManager', 'Move to start of document line'), |
|
2483 QCoreApplication.translate( |
|
2484 'ViewManager', 'Move to start of document line'), |
|
2485 0, 0, |
|
2486 self.editorActGrp, 'vm_edit_move_start_document_line') |
|
2487 if isMacPlatform(): |
|
2488 act.setShortcut(QKeySequence( |
|
2489 QCoreApplication.translate('ViewManager', 'Meta+A'))) |
|
2490 self.esm.setMapping(act, QsciScintilla.SCI_HOME) |
|
2491 act.triggered.connect(self.esm.map) |
|
2492 self.editActions.append(act) |
|
2493 |
|
2494 if hasattr(QsciScintilla, "SCI_HOMEEXTEND"): |
|
2495 act = E5Action( |
|
2496 QCoreApplication.translate( |
|
2497 'ViewManager', |
|
2498 'Extend selection to start of document line'), |
|
2499 QCoreApplication.translate( |
|
2500 'ViewManager', |
|
2501 'Extend selection to start of document line'), |
|
2502 0, 0, |
|
2503 self.editorActGrp, |
|
2504 'vm_edit_extend_selection_start_document_line') |
|
2505 if isMacPlatform(): |
|
2506 act.setShortcut(QKeySequence( |
|
2507 QCoreApplication.translate('ViewManager', 'Meta+Shift+A'))) |
|
2508 self.esm.setMapping(act, QsciScintilla.SCI_HOMEEXTEND) |
|
2509 act.triggered.connect(self.esm.map) |
|
2510 self.editActions.append(act) |
|
2511 |
|
2512 if hasattr(QsciScintilla, "SCI_HOMERECTEXTEND"): |
|
2513 act = E5Action( |
|
2514 QCoreApplication.translate( |
|
2515 'ViewManager', |
|
2516 'Extend rectangular selection to start of document line'), |
|
2517 QCoreApplication.translate( |
|
2518 'ViewManager', |
|
2519 'Extend rectangular selection to start of document line'), |
|
2520 0, 0, |
|
2521 self.editorActGrp, 'vm_edit_select_rect_start_line') |
|
2522 if isMacPlatform(): |
|
2523 act.setShortcut(QKeySequence( |
|
2524 QCoreApplication.translate('ViewManager', |
|
2525 'Meta+Alt+Shift+A'))) |
|
2526 self.esm.setMapping(act, QsciScintilla.SCI_HOMERECTEXTEND) |
|
2527 act.triggered.connect(self.esm.map) |
|
2528 self.editActions.append(act) |
|
2529 |
|
2530 if hasattr(QsciScintilla, "SCI_HOMEDISPLAYEXTEND"): |
|
2531 act = E5Action( |
|
2532 QCoreApplication.translate( |
|
2533 'ViewManager', |
|
2534 'Extend selection to start of display line'), |
|
2535 QCoreApplication.translate( |
|
2536 'ViewManager', |
|
2537 'Extend selection to start of display line'), |
|
2538 0, 0, |
|
2539 self.editorActGrp, |
|
2540 'vm_edit_extend_selection_start_display_line') |
|
2541 if isMacPlatform(): |
|
2542 act.setShortcut(QKeySequence( |
|
2543 QCoreApplication.translate('ViewManager', |
|
2544 'Ctrl+Shift+Left'))) |
|
2545 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAYEXTEND) |
|
2546 act.triggered.connect(self.esm.map) |
|
2547 self.editActions.append(act) |
|
2548 |
|
2549 if hasattr(QsciScintilla, "SCI_HOMEWRAP"): |
|
2550 act = E5Action( |
|
2551 QCoreApplication.translate( |
|
2552 'ViewManager', |
|
2553 'Move to start of display or document line'), |
|
2554 QCoreApplication.translate( |
|
2555 'ViewManager', |
|
2556 'Move to start of display or document line'), |
|
2557 0, 0, |
|
2558 self.editorActGrp, 'vm_edit_move_start_display_document_line') |
|
2559 self.esm.setMapping(act, QsciScintilla.SCI_HOMEWRAP) |
|
2560 act.triggered.connect(self.esm.map) |
|
2561 self.editActions.append(act) |
|
2562 |
|
2563 if hasattr(QsciScintilla, "SCI_HOMEWRAPEXTEND"): |
|
2564 act = E5Action( |
|
2565 QCoreApplication.translate( |
|
2566 'ViewManager', |
|
2567 'Extend selection to start of display or document line'), |
|
2568 QCoreApplication.translate( |
|
2569 'ViewManager', |
|
2570 'Extend selection to start of display or document line'), |
|
2571 0, 0, |
|
2572 self.editorActGrp, |
|
2573 'vm_edit_extend_selection_start_display_document_line') |
|
2574 self.esm.setMapping(act, QsciScintilla.SCI_HOMEWRAPEXTEND) |
|
2575 act.triggered.connect(self.esm.map) |
|
2576 self.editActions.append(act) |
|
2577 |
|
2578 if hasattr(QsciScintilla, "SCI_VCHOMEWRAP"): |
|
2579 act = E5Action( |
|
2580 QCoreApplication.translate( |
|
2581 'ViewManager', |
|
2582 'Move to first visible character in display or document' |
|
2583 ' line'), |
|
2584 QCoreApplication.translate( |
|
2585 'ViewManager', |
|
2586 'Move to first visible character in display or document' |
|
2587 ' line'), |
|
2588 0, 0, |
|
2589 self.editorActGrp, |
|
2590 'vm_edit_move_first_visible_char_document_line') |
|
2591 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEWRAP) |
|
2592 act.triggered.connect(self.esm.map) |
|
2593 self.editActions.append(act) |
|
2594 |
|
2595 if hasattr(QsciScintilla, "SCI_VCHOMEWRAPEXTEND"): |
|
2596 act = E5Action( |
|
2597 QCoreApplication.translate( |
|
2598 'ViewManager', |
|
2599 'Extend selection to first visible character in' |
|
2600 ' display or document line'), |
|
2601 QCoreApplication.translate( |
|
2602 'ViewManager', |
|
2603 'Extend selection to first visible character in' |
|
2604 ' display or document line'), |
|
2605 0, 0, |
|
2606 self.editorActGrp, |
|
2607 'vm_edit_extend_selection_first_visible_char_document_line') |
|
2608 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEWRAPEXTEND) |
|
2609 act.triggered.connect(self.esm.map) |
|
2610 self.editActions.append(act) |
|
2611 |
|
2612 if hasattr(QsciScintilla, "SCI_LINEENDWRAP"): |
|
2613 act = E5Action( |
|
2614 QCoreApplication.translate( |
|
2615 'ViewManager', |
|
2616 'Move to end of display or document line'), |
|
2617 QCoreApplication.translate( |
|
2618 'ViewManager', |
|
2619 'Move to end of display or document line'), |
|
2620 0, 0, |
|
2621 self.editorActGrp, 'vm_edit_end_start_display_document_line') |
|
2622 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDWRAP) |
|
2623 act.triggered.connect(self.esm.map) |
|
2624 self.editActions.append(act) |
|
2625 |
|
2626 if hasattr(QsciScintilla, "SCI_LINEENDWRAPEXTEND"): |
|
2627 act = E5Action( |
|
2628 QCoreApplication.translate( |
|
2629 'ViewManager', |
|
2630 'Extend selection to end of display or document line'), |
|
2631 QCoreApplication.translate( |
|
2632 'ViewManager', |
|
2633 'Extend selection to end of display or document line'), |
|
2634 0, 0, |
|
2635 self.editorActGrp, |
|
2636 'vm_edit_extend_selection_end_display_document_line') |
|
2637 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDWRAPEXTEND) |
|
2638 act.triggered.connect(self.esm.map) |
|
2639 self.editActions.append(act) |
|
2640 |
|
2641 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEUP"): |
|
2642 act = E5Action( |
|
2643 QCoreApplication.translate( |
|
2644 'ViewManager', 'Stuttered move up one page'), |
|
2645 QCoreApplication.translate( |
|
2646 'ViewManager', 'Stuttered move up one page'), |
|
2647 0, 0, |
|
2648 self.editorActGrp, 'vm_edit_stuttered_move_up_page') |
|
2649 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEUP) |
|
2650 act.triggered.connect(self.esm.map) |
|
2651 self.editActions.append(act) |
|
2652 |
|
2653 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEUPEXTEND"): |
|
2654 act = E5Action( |
|
2655 QCoreApplication.translate( |
|
2656 'ViewManager', 'Stuttered extend selection up one page'), |
|
2657 QCoreApplication.translate( |
|
2658 'ViewManager', 'Stuttered extend selection up one page'), |
|
2659 0, 0, |
|
2660 self.editorActGrp, |
|
2661 'vm_edit_stuttered_extend_selection_up_page') |
|
2662 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEUPEXTEND) |
|
2663 act.triggered.connect(self.esm.map) |
|
2664 self.editActions.append(act) |
|
2665 |
|
2666 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEDOWN"): |
|
2667 act = E5Action( |
|
2668 QCoreApplication.translate( |
|
2669 'ViewManager', 'Stuttered move down one page'), |
|
2670 QCoreApplication.translate( |
|
2671 'ViewManager', 'Stuttered move down one page'), |
|
2672 0, 0, |
|
2673 self.editorActGrp, 'vm_edit_stuttered_move_down_page') |
|
2674 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEDOWN) |
|
2675 act.triggered.connect(self.esm.map) |
|
2676 self.editActions.append(act) |
|
2677 |
|
2678 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEDOWNEXTEND"): |
|
2679 act = E5Action( |
|
2680 QCoreApplication.translate( |
|
2681 'ViewManager', 'Stuttered extend selection down one page'), |
|
2682 QCoreApplication.translate( |
|
2683 'ViewManager', 'Stuttered extend selection down one page'), |
|
2684 0, 0, |
|
2685 self.editorActGrp, |
|
2686 'vm_edit_stuttered_extend_selection_down_page') |
|
2687 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEDOWNEXTEND) |
|
2688 act.triggered.connect(self.esm.map) |
|
2689 self.editActions.append(act) |
|
2690 |
|
2691 if hasattr(QsciScintilla, "SCI_DELWORDRIGHTEND"): |
|
2692 act = E5Action( |
|
2693 QCoreApplication.translate( |
|
2694 'ViewManager', 'Delete right to end of next word'), |
|
2695 QCoreApplication.translate( |
|
2696 'ViewManager', 'Delete right to end of next word'), |
|
2697 0, 0, |
|
2698 self.editorActGrp, 'vm_edit_delete_right_end_next_word') |
|
2699 if isMacPlatform(): |
|
2700 act.setShortcut(QKeySequence( |
|
2701 QCoreApplication.translate('ViewManager', 'Alt+Del'))) |
|
2702 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHTEND) |
|
2703 act.triggered.connect(self.esm.map) |
|
2704 self.editActions.append(act) |
|
2705 |
|
2706 if hasattr(QsciScintilla, "SCI_MOVESELECTEDLINESUP"): |
|
2707 act = E5Action( |
|
2708 QCoreApplication.translate( |
|
2709 'ViewManager', 'Move selected lines up one line'), |
|
2710 QCoreApplication.translate( |
|
2711 'ViewManager', 'Move selected lines up one line'), |
|
2712 0, 0, |
|
2713 self.editorActGrp, 'vm_edit_move_selection_up_one_line') |
|
2714 self.esm.setMapping(act, QsciScintilla.SCI_MOVESELECTEDLINESUP) |
|
2715 act.triggered.connect(self.esm.map) |
|
2716 self.editActions.append(act) |
|
2717 |
|
2718 if hasattr(QsciScintilla, "SCI_MOVESELECTEDLINESDOWN"): |
|
2719 act = E5Action( |
|
2720 QCoreApplication.translate( |
|
2721 'ViewManager', 'Move selected lines down one line'), |
|
2722 QCoreApplication.translate( |
|
2723 'ViewManager', 'Move selected lines down one line'), |
|
2724 0, 0, |
|
2725 self.editorActGrp, 'vm_edit_move_selection_down_one_line') |
|
2726 self.esm.setMapping(act, QsciScintilla.SCI_MOVESELECTEDLINESDOWN) |
|
2727 act.triggered.connect(self.esm.map) |
|
2728 self.editActions.append(act) |
|
2729 |
|
2730 self.editorActGrp.setEnabled(False) |
|
2731 |
|
2732 self.editLowerCaseAct = E5Action( |
|
2733 QCoreApplication.translate( |
|
2734 'ViewManager', 'Convert selection to lower case'), |
|
2735 QCoreApplication.translate( |
|
2736 'ViewManager', 'Convert selection to lower case'), |
|
2737 QKeySequence(QCoreApplication.translate('ViewManager', |
|
2738 'Alt+Shift+U')), |
|
2739 0, self.editActGrp, 'vm_edit_convert_selection_lower') |
|
2740 self.esm.setMapping(self.editLowerCaseAct, QsciScintilla.SCI_LOWERCASE) |
|
2741 self.editLowerCaseAct.triggered.connect(self.esm.map) |
|
2742 self.editActions.append(self.editLowerCaseAct) |
|
2743 |
|
2744 self.editUpperCaseAct = E5Action( |
|
2745 QCoreApplication.translate( |
|
2746 'ViewManager', 'Convert selection to upper case'), |
|
2747 QCoreApplication.translate( |
|
2748 'ViewManager', 'Convert selection to upper case'), |
|
2749 QKeySequence(QCoreApplication.translate( |
|
2750 'ViewManager', 'Ctrl+Shift+U')), |
|
2751 0, |
|
2752 self.editActGrp, 'vm_edit_convert_selection_upper') |
|
2753 self.esm.setMapping(self.editUpperCaseAct, QsciScintilla.SCI_UPPERCASE) |
|
2754 self.editUpperCaseAct.triggered.connect(self.esm.map) |
|
2755 self.editActions.append(self.editUpperCaseAct) |
|
2756 |
|
2757 def initEditMenu(self): |
|
2758 """ |
|
2759 Public method to create the Edit menu. |
|
2760 |
|
2761 @return the generated menu |
|
2762 """ |
|
2763 autocompletionMenu = QMenu( |
|
2764 QCoreApplication.translate('ViewManager', 'Complete'), |
|
2765 self.ui) |
|
2766 autocompletionMenu.setTearOffEnabled(True) |
|
2767 autocompletionMenu.addAction(self.autoCompleteAct) |
|
2768 autocompletionMenu.addSeparator() |
|
2769 autocompletionMenu.addAction(self.autoCompleteFromDocAct) |
|
2770 autocompletionMenu.addAction(self.autoCompleteFromAPIsAct) |
|
2771 autocompletionMenu.addAction(self.autoCompleteFromAllAct) |
|
2772 |
|
2773 searchMenu = QMenu( |
|
2774 QCoreApplication.translate('ViewManager', '&Search'), |
|
2775 self.ui) |
|
2776 searchMenu.setTearOffEnabled(True) |
|
2777 searchMenu.addAction(self.quickSearchAct) |
|
2778 searchMenu.addAction(self.quickSearchBackAct) |
|
2779 searchMenu.addAction(self.searchAct) |
|
2780 searchMenu.addAction(self.searchNextAct) |
|
2781 searchMenu.addAction(self.searchPrevAct) |
|
2782 searchMenu.addAction(self.searchNextWordAct) |
|
2783 searchMenu.addAction(self.searchPrevWordAct) |
|
2784 searchMenu.addAction(self.replaceAct) |
|
2785 searchMenu.addSeparator() |
|
2786 searchMenu.addAction(self.searchClearMarkersAct) |
|
2787 searchMenu.addSeparator() |
|
2788 searchMenu.addAction(self.searchFilesAct) |
|
2789 searchMenu.addAction(self.replaceFilesAct) |
|
2790 searchMenu.addSeparator() |
|
2791 searchMenu.addAction(self.searchOpenFilesAct) |
|
2792 searchMenu.addAction(self.replaceOpenFilesAct) |
|
2793 |
|
2794 menu = QMenu(QCoreApplication.translate('ViewManager', '&Edit'), |
|
2795 self.ui) |
|
2796 menu.setTearOffEnabled(True) |
|
2797 menu.addAction(self.undoAct) |
|
2798 menu.addAction(self.redoAct) |
|
2799 menu.addAction(self.revertAct) |
|
2800 menu.addSeparator() |
|
2801 menu.addAction(self.cutAct) |
|
2802 menu.addAction(self.copyAct) |
|
2803 menu.addAction(self.pasteAct) |
|
2804 menu.addAction(self.deleteAct) |
|
2805 menu.addSeparator() |
|
2806 menu.addAction(self.indentAct) |
|
2807 menu.addAction(self.unindentAct) |
|
2808 menu.addAction(self.smartIndentAct) |
|
2809 menu.addSeparator() |
|
2810 menu.addAction(self.commentAct) |
|
2811 menu.addAction(self.uncommentAct) |
|
2812 menu.addAction(self.toggleCommentAct) |
|
2813 menu.addAction(self.streamCommentAct) |
|
2814 menu.addAction(self.boxCommentAct) |
|
2815 menu.addSeparator() |
|
2816 menu.addAction(self.editUpperCaseAct) |
|
2817 menu.addAction(self.editLowerCaseAct) |
|
2818 menu.addAction(self.sortAct) |
|
2819 menu.addSeparator() |
|
2820 menu.addMenu(autocompletionMenu) |
|
2821 menu.addAction(self.calltipsAct) |
|
2822 menu.addAction(self.codeInfoAct) |
|
2823 menu.addSeparator() |
|
2824 menu.addMenu(searchMenu) |
|
2825 menu.addSeparator() |
|
2826 menu.addAction(self.gotoAct) |
|
2827 menu.addAction(self.gotoBraceAct) |
|
2828 menu.addAction(self.gotoLastEditAct) |
|
2829 menu.addAction(self.gotoPreviousDefAct) |
|
2830 menu.addAction(self.gotoNextDefAct) |
|
2831 menu.addSeparator() |
|
2832 menu.addAction(self.selectBraceAct) |
|
2833 menu.addAction(self.selectAllAct) |
|
2834 menu.addAction(self.deselectAllAct) |
|
2835 menu.addSeparator() |
|
2836 menu.addAction(self.shortenEmptyAct) |
|
2837 menu.addAction(self.convertEOLAct) |
|
2838 |
|
2839 return menu |
|
2840 |
|
2841 def initEditToolbar(self, toolbarManager): |
|
2842 """ |
|
2843 Public method to create the Edit toolbar. |
|
2844 |
|
2845 @param toolbarManager reference to a toolbar manager object |
|
2846 (E5ToolBarManager) |
|
2847 @return the generated toolbar |
|
2848 """ |
|
2849 tb = QToolBar(QCoreApplication.translate('ViewManager', 'Edit'), |
|
2850 self.ui) |
|
2851 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
2852 tb.setObjectName("EditToolbar") |
|
2853 tb.setToolTip(QCoreApplication.translate('ViewManager', 'Edit')) |
|
2854 |
|
2855 tb.addAction(self.undoAct) |
|
2856 tb.addAction(self.redoAct) |
|
2857 tb.addSeparator() |
|
2858 tb.addAction(self.cutAct) |
|
2859 tb.addAction(self.copyAct) |
|
2860 tb.addAction(self.pasteAct) |
|
2861 tb.addAction(self.deleteAct) |
|
2862 tb.addSeparator() |
|
2863 tb.addAction(self.commentAct) |
|
2864 tb.addAction(self.uncommentAct) |
|
2865 tb.addAction(self.toggleCommentAct) |
|
2866 |
|
2867 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
2868 toolbarManager.addAction(self.smartIndentAct, tb.windowTitle()) |
|
2869 toolbarManager.addAction(self.indentAct, tb.windowTitle()) |
|
2870 toolbarManager.addAction(self.unindentAct, tb.windowTitle()) |
|
2871 |
|
2872 return tb |
|
2873 |
|
2874 ################################################################## |
|
2875 ## Initialize the search related actions and the search toolbar |
|
2876 ################################################################## |
|
2877 |
|
2878 def __initSearchActions(self): |
|
2879 """ |
|
2880 Private method defining the user interface actions for the search |
|
2881 commands. |
|
2882 """ |
|
2883 self.searchActGrp = createActionGroup(self) |
|
2884 |
|
2885 self.searchAct = E5Action( |
|
2886 QCoreApplication.translate('ViewManager', 'Search'), |
|
2887 UI.PixmapCache.getIcon("find.png"), |
|
2888 QCoreApplication.translate('ViewManager', '&Search...'), |
|
2889 QKeySequence(QCoreApplication.translate( |
|
2890 'ViewManager', "Ctrl+F", "Search|Search")), |
|
2891 0, |
|
2892 self.searchActGrp, 'vm_search') |
|
2893 self.searchAct.setStatusTip(QCoreApplication.translate( |
|
2894 'ViewManager', 'Search for a text')) |
|
2895 self.searchAct.setWhatsThis(QCoreApplication.translate( |
|
2896 'ViewManager', |
|
2897 """<b>Search</b>""" |
|
2898 """<p>Search for some text in the current editor. A""" |
|
2899 """ dialog is shown to enter the searchtext and options""" |
|
2900 """ for the search.</p>""" |
|
2901 )) |
|
2902 self.searchAct.triggered.connect(self.showSearchWidget) |
|
2903 self.searchActions.append(self.searchAct) |
|
2904 |
|
2905 self.searchNextAct = E5Action( |
|
2906 QCoreApplication.translate( |
|
2907 'ViewManager', 'Search next'), |
|
2908 UI.PixmapCache.getIcon("findNext.png"), |
|
2909 QCoreApplication.translate('ViewManager', 'Search &next'), |
|
2910 QKeySequence(QCoreApplication.translate( |
|
2911 'ViewManager', "F3", "Search|Search next")), |
|
2912 0, |
|
2913 self.searchActGrp, 'vm_search_next') |
|
2914 self.searchNextAct.setStatusTip(QCoreApplication.translate( |
|
2915 'ViewManager', 'Search next occurrence of text')) |
|
2916 self.searchNextAct.setWhatsThis(QCoreApplication.translate( |
|
2917 'ViewManager', |
|
2918 """<b>Search next</b>""" |
|
2919 """<p>Search the next occurrence of some text in the current""" |
|
2920 """ editor. The previously entered searchtext and options are""" |
|
2921 """ reused.</p>""" |
|
2922 )) |
|
2923 self.searchNextAct.triggered.connect(self.__searchNext) |
|
2924 self.searchActions.append(self.searchNextAct) |
|
2925 |
|
2926 self.searchPrevAct = E5Action( |
|
2927 QCoreApplication.translate('ViewManager', 'Search previous'), |
|
2928 UI.PixmapCache.getIcon("findPrev.png"), |
|
2929 QCoreApplication.translate('ViewManager', 'Search &previous'), |
|
2930 QKeySequence(QCoreApplication.translate( |
|
2931 'ViewManager', "Shift+F3", "Search|Search previous")), |
|
2932 0, |
|
2933 self.searchActGrp, 'vm_search_previous') |
|
2934 self.searchPrevAct.setStatusTip(QCoreApplication.translate( |
|
2935 'ViewManager', 'Search previous occurrence of text')) |
|
2936 self.searchPrevAct.setWhatsThis(QCoreApplication.translate( |
|
2937 'ViewManager', |
|
2938 """<b>Search previous</b>""" |
|
2939 """<p>Search the previous occurrence of some text in the current""" |
|
2940 """ editor. The previously entered searchtext and options are""" |
|
2941 """ reused.</p>""" |
|
2942 )) |
|
2943 self.searchPrevAct.triggered.connect(self.__searchPrev) |
|
2944 self.searchActions.append(self.searchPrevAct) |
|
2945 |
|
2946 self.searchClearMarkersAct = E5Action( |
|
2947 QCoreApplication.translate('ViewManager', 'Clear search markers'), |
|
2948 UI.PixmapCache.getIcon("findClear.png"), |
|
2949 QCoreApplication.translate('ViewManager', 'Clear search markers'), |
|
2950 QKeySequence(QCoreApplication.translate( |
|
2951 'ViewManager', "Ctrl+3", "Search|Clear search markers")), |
|
2952 0, |
|
2953 self.searchActGrp, 'vm_clear_search_markers') |
|
2954 self.searchClearMarkersAct.setStatusTip(QCoreApplication.translate( |
|
2955 'ViewManager', 'Clear all displayed search markers')) |
|
2956 self.searchClearMarkersAct.setWhatsThis(QCoreApplication.translate( |
|
2957 'ViewManager', |
|
2958 """<b>Clear search markers</b>""" |
|
2959 """<p>Clear all displayed search markers.</p>""" |
|
2960 )) |
|
2961 self.searchClearMarkersAct.triggered.connect( |
|
2962 self.__searchClearMarkers) |
|
2963 self.searchActions.append(self.searchClearMarkersAct) |
|
2964 |
|
2965 self.searchNextWordAct = E5Action( |
|
2966 QCoreApplication.translate( |
|
2967 'ViewManager', 'Search current word forward'), |
|
2968 UI.PixmapCache.getIcon("findWordNext.png"), |
|
2969 QCoreApplication.translate( |
|
2970 'ViewManager', 'Search current word forward'), |
|
2971 QKeySequence(QCoreApplication.translate( |
|
2972 'ViewManager', |
|
2973 "Ctrl+.", "Search|Search current word forward")), |
|
2974 0, |
|
2975 self.searchActGrp, 'vm_search_word_next') |
|
2976 self.searchNextWordAct.setStatusTip(QCoreApplication.translate( |
|
2977 'ViewManager', |
|
2978 'Search next occurrence of the current word')) |
|
2979 self.searchNextWordAct.setWhatsThis(QCoreApplication.translate( |
|
2980 'ViewManager', |
|
2981 """<b>Search current word forward</b>""" |
|
2982 """<p>Search the next occurrence of the current word of the""" |
|
2983 """ current editor.</p>""" |
|
2984 )) |
|
2985 self.searchNextWordAct.triggered.connect(self.__findNextWord) |
|
2986 self.searchActions.append(self.searchNextWordAct) |
|
2987 |
|
2988 self.searchPrevWordAct = E5Action( |
|
2989 QCoreApplication.translate( |
|
2990 'ViewManager', 'Search current word backward'), |
|
2991 UI.PixmapCache.getIcon("findWordPrev.png"), |
|
2992 QCoreApplication.translate( |
|
2993 'ViewManager', 'Search current word backward'), |
|
2994 QKeySequence(QCoreApplication.translate( |
|
2995 'ViewManager', |
|
2996 "Ctrl+,", "Search|Search current word backward")), |
|
2997 0, |
|
2998 self.searchActGrp, 'vm_search_word_previous') |
|
2999 self.searchPrevWordAct.setStatusTip(QCoreApplication.translate( |
|
3000 'ViewManager', |
|
3001 'Search previous occurrence of the current word')) |
|
3002 self.searchPrevWordAct.setWhatsThis(QCoreApplication.translate( |
|
3003 'ViewManager', |
|
3004 """<b>Search current word backward</b>""" |
|
3005 """<p>Search the previous occurrence of the current word of the""" |
|
3006 """ current editor.</p>""" |
|
3007 )) |
|
3008 self.searchPrevWordAct.triggered.connect(self.__findPrevWord) |
|
3009 self.searchActions.append(self.searchPrevWordAct) |
|
3010 |
|
3011 self.replaceAct = E5Action( |
|
3012 QCoreApplication.translate('ViewManager', 'Replace'), |
|
3013 QCoreApplication.translate('ViewManager', '&Replace...'), |
|
3014 QKeySequence(QCoreApplication.translate( |
|
3015 'ViewManager', "Ctrl+R", "Search|Replace")), |
|
3016 0, |
|
3017 self.searchActGrp, 'vm_search_replace') |
|
3018 self.replaceAct.setStatusTip(QCoreApplication.translate( |
|
3019 'ViewManager', 'Replace some text')) |
|
3020 self.replaceAct.setWhatsThis(QCoreApplication.translate( |
|
3021 'ViewManager', |
|
3022 """<b>Replace</b>""" |
|
3023 """<p>Search for some text in the current editor and replace it.""" |
|
3024 """ A dialog is shown to enter the searchtext, the replacement""" |
|
3025 """ text and options for the search and replace.</p>""" |
|
3026 )) |
|
3027 self.replaceAct.triggered.connect(self.showReplaceWidget) |
|
3028 self.searchActions.append(self.replaceAct) |
|
3029 |
|
3030 self.replaceAndSearchAct = E5Action( |
|
3031 QCoreApplication.translate( |
|
3032 'ViewManager', 'Replace and Search'), |
|
3033 UI.PixmapCache.getIcon("editReplaceSearch.png"), |
|
3034 QCoreApplication.translate( |
|
3035 'ViewManager', 'Replace and Search'), |
|
3036 QKeySequence(QCoreApplication.translate( |
|
3037 'ViewManager', "Meta+R", "Search|Replace and Search")), |
|
3038 0, |
|
3039 self.searchActGrp, 'vm_replace_search') |
|
3040 self.replaceAndSearchAct.setStatusTip(QCoreApplication.translate( |
|
3041 'ViewManager', |
|
3042 'Replace the found text and search the next occurrence')) |
|
3043 self.replaceAndSearchAct.setWhatsThis(QCoreApplication.translate( |
|
3044 'ViewManager', |
|
3045 """<b>Replace and Search</b>""" |
|
3046 """<p>Replace the found occurrence of text in the current""" |
|
3047 """ editor and search for the next one. The previously entered""" |
|
3048 """ search text and options are reused.</p>""" |
|
3049 )) |
|
3050 self.replaceAndSearchAct.triggered.connect( |
|
3051 self.__replaceWidget.replaceSearch) |
|
3052 self.searchActions.append(self.replaceAndSearchAct) |
|
3053 |
|
3054 self.replaceSelectionAct = E5Action( |
|
3055 QCoreApplication.translate( |
|
3056 'ViewManager', 'Replace Occurrence'), |
|
3057 UI.PixmapCache.getIcon("editReplace.png"), |
|
3058 QCoreApplication.translate( |
|
3059 'ViewManager', 'Replace Occurrence'), |
|
3060 QKeySequence(QCoreApplication.translate( |
|
3061 'ViewManager', "Ctrl+Meta+R", "Search|Replace Occurrence")), |
|
3062 0, |
|
3063 self.searchActGrp, 'vm_replace_occurrence') |
|
3064 self.replaceSelectionAct.setStatusTip(QCoreApplication.translate( |
|
3065 'ViewManager', 'Replace the found text')) |
|
3066 self.replaceSelectionAct.setWhatsThis(QCoreApplication.translate( |
|
3067 'ViewManager', |
|
3068 """<b>Replace Occurrence</b>""" |
|
3069 """<p>Replace the found occurrence of the search text in the""" |
|
3070 """ current editor.</p>""" |
|
3071 )) |
|
3072 self.replaceSelectionAct.triggered.connect( |
|
3073 self.__replaceWidget.replace) |
|
3074 self.searchActions.append(self.replaceSelectionAct) |
|
3075 |
|
3076 self.replaceAllAct = E5Action( |
|
3077 QCoreApplication.translate( |
|
3078 'ViewManager', 'Replace All'), |
|
3079 UI.PixmapCache.getIcon("editReplaceAll.png"), |
|
3080 QCoreApplication.translate( |
|
3081 'ViewManager', 'Replace All'), |
|
3082 QKeySequence(QCoreApplication.translate( |
|
3083 'ViewManager', "Shift+Meta+R", "Search|Replace All")), |
|
3084 0, |
|
3085 self.searchActGrp, 'vm_replace_all') |
|
3086 self.replaceAllAct.setStatusTip(QCoreApplication.translate( |
|
3087 'ViewManager', 'Replace search text occurrences')) |
|
3088 self.replaceAllAct.setWhatsThis(QCoreApplication.translate( |
|
3089 'ViewManager', |
|
3090 """<b>Replace All</b>""" |
|
3091 """<p>Replace all occurrences of the search text in the current""" |
|
3092 """ editor.</p>""" |
|
3093 )) |
|
3094 self.replaceAllAct.triggered.connect( |
|
3095 self.__replaceWidget.replaceAll) |
|
3096 self.searchActions.append(self.replaceAllAct) |
|
3097 |
|
3098 self.quickSearchAct = E5Action( |
|
3099 QCoreApplication.translate('ViewManager', 'Quicksearch'), |
|
3100 UI.PixmapCache.getIcon("quickFindNext.png"), |
|
3101 QCoreApplication.translate('ViewManager', '&Quicksearch'), |
|
3102 QKeySequence(QCoreApplication.translate( |
|
3103 'ViewManager', "Ctrl+Shift+K", "Search|Quicksearch")), |
|
3104 0, |
|
3105 self.searchActGrp, 'vm_quicksearch') |
|
3106 self.quickSearchAct.setStatusTip(QCoreApplication.translate( |
|
3107 'ViewManager', 'Perform a quicksearch')) |
|
3108 self.quickSearchAct.setWhatsThis(QCoreApplication.translate( |
|
3109 'ViewManager', |
|
3110 """<b>Quicksearch</b>""" |
|
3111 """<p>This activates the quicksearch function of the IDE by""" |
|
3112 """ giving focus to the quicksearch entry field. If this field""" |
|
3113 """ is already active and contains text, it searches for the""" |
|
3114 """ next occurrence of this text.</p>""" |
|
3115 )) |
|
3116 self.quickSearchAct.triggered.connect(self.__quickSearch) |
|
3117 self.searchActions.append(self.quickSearchAct) |
|
3118 |
|
3119 self.quickSearchBackAct = E5Action( |
|
3120 QCoreApplication.translate( |
|
3121 'ViewManager', 'Quicksearch backwards'), |
|
3122 UI.PixmapCache.getIcon("quickFindPrev.png"), |
|
3123 QCoreApplication.translate( |
|
3124 'ViewManager', 'Quicksearch &backwards'), |
|
3125 QKeySequence(QCoreApplication.translate( |
|
3126 'ViewManager', |
|
3127 "Ctrl+Shift+J", "Search|Quicksearch backwards")), |
|
3128 0, self.searchActGrp, 'vm_quicksearch_backwards') |
|
3129 self.quickSearchBackAct.setStatusTip(QCoreApplication.translate( |
|
3130 'ViewManager', |
|
3131 'Perform a quicksearch backwards')) |
|
3132 self.quickSearchBackAct.setWhatsThis(QCoreApplication.translate( |
|
3133 'ViewManager', |
|
3134 """<b>Quicksearch backwards</b>""" |
|
3135 """<p>This searches the previous occurrence of the quicksearch""" |
|
3136 """ text.</p>""" |
|
3137 )) |
|
3138 self.quickSearchBackAct.triggered.connect(self.__quickSearchPrev) |
|
3139 self.searchActions.append(self.quickSearchBackAct) |
|
3140 |
|
3141 self.quickSearchExtendAct = E5Action( |
|
3142 QCoreApplication.translate('ViewManager', 'Quicksearch extend'), |
|
3143 UI.PixmapCache.getIcon("quickFindExtend.png"), |
|
3144 QCoreApplication.translate('ViewManager', 'Quicksearch e&xtend'), |
|
3145 QKeySequence(QCoreApplication.translate( |
|
3146 'ViewManager', "Ctrl+Shift+H", "Search|Quicksearch extend")), |
|
3147 0, |
|
3148 self.searchActGrp, 'vm_quicksearch_extend') |
|
3149 self.quickSearchExtendAct.setStatusTip(QCoreApplication.translate( |
|
3150 'ViewManager', |
|
3151 'Extend the quicksearch to the end of the current word')) |
|
3152 self.quickSearchExtendAct.setWhatsThis(QCoreApplication.translate( |
|
3153 'ViewManager', |
|
3154 """<b>Quicksearch extend</b>""" |
|
3155 """<p>This extends the quicksearch text to the end of the word""" |
|
3156 """ currently found.</p>""" |
|
3157 )) |
|
3158 self.quickSearchExtendAct.triggered.connect( |
|
3159 self.__quickSearchExtend) |
|
3160 self.searchActions.append(self.quickSearchExtendAct) |
|
3161 |
|
3162 self.gotoAct = E5Action( |
|
3163 QCoreApplication.translate('ViewManager', 'Goto Line'), |
|
3164 UI.PixmapCache.getIcon("goto.png"), |
|
3165 QCoreApplication.translate('ViewManager', '&Goto Line...'), |
|
3166 QKeySequence(QCoreApplication.translate( |
|
3167 'ViewManager', "Ctrl+G", "Search|Goto Line")), |
|
3168 0, |
|
3169 self.searchActGrp, 'vm_search_goto_line') |
|
3170 self.gotoAct.setStatusTip(QCoreApplication.translate( |
|
3171 'ViewManager', 'Goto Line')) |
|
3172 self.gotoAct.setWhatsThis(QCoreApplication.translate( |
|
3173 'ViewManager', |
|
3174 """<b>Goto Line</b>""" |
|
3175 """<p>Go to a specific line of text in the current editor.""" |
|
3176 """ A dialog is shown to enter the linenumber.</p>""" |
|
3177 )) |
|
3178 self.gotoAct.triggered.connect(self.__goto) |
|
3179 self.searchActions.append(self.gotoAct) |
|
3180 |
|
3181 self.gotoBraceAct = E5Action( |
|
3182 QCoreApplication.translate('ViewManager', 'Goto Brace'), |
|
3183 UI.PixmapCache.getIcon("gotoBrace.png"), |
|
3184 QCoreApplication.translate('ViewManager', 'Goto &Brace'), |
|
3185 QKeySequence(QCoreApplication.translate( |
|
3186 'ViewManager', "Ctrl+L", "Search|Goto Brace")), |
|
3187 0, |
|
3188 self.searchActGrp, 'vm_search_goto_brace') |
|
3189 self.gotoBraceAct.setStatusTip(QCoreApplication.translate( |
|
3190 'ViewManager', 'Goto Brace')) |
|
3191 self.gotoBraceAct.setWhatsThis(QCoreApplication.translate( |
|
3192 'ViewManager', |
|
3193 """<b>Goto Brace</b>""" |
|
3194 """<p>Go to the matching brace in the current editor.</p>""" |
|
3195 )) |
|
3196 self.gotoBraceAct.triggered.connect(self.__gotoBrace) |
|
3197 self.searchActions.append(self.gotoBraceAct) |
|
3198 |
|
3199 self.gotoLastEditAct = E5Action( |
|
3200 QCoreApplication.translate( |
|
3201 'ViewManager', 'Goto Last Edit Location'), |
|
3202 UI.PixmapCache.getIcon("gotoLastEditPosition.png"), |
|
3203 QCoreApplication.translate( |
|
3204 'ViewManager', 'Goto Last &Edit Location'), |
|
3205 QKeySequence(QCoreApplication.translate( |
|
3206 'ViewManager', |
|
3207 "Ctrl+Shift+G", "Search|Goto Last Edit Location")), |
|
3208 0, |
|
3209 self.searchActGrp, 'vm_search_goto_last_edit_location') |
|
3210 self.gotoLastEditAct.setStatusTip( |
|
3211 QCoreApplication.translate( |
|
3212 'ViewManager', 'Goto Last Edit Location')) |
|
3213 self.gotoLastEditAct.setWhatsThis(QCoreApplication.translate( |
|
3214 'ViewManager', |
|
3215 """<b>Goto Last Edit Location</b>""" |
|
3216 """<p>Go to the location of the last edit in the current""" |
|
3217 """ editor.</p>""" |
|
3218 )) |
|
3219 self.gotoLastEditAct.triggered.connect(self.__gotoLastEditPosition) |
|
3220 self.searchActions.append(self.gotoLastEditAct) |
|
3221 |
|
3222 self.gotoPreviousDefAct = E5Action( |
|
3223 QCoreApplication.translate( |
|
3224 'ViewManager', 'Goto Previous Method or Class'), |
|
3225 QCoreApplication.translate( |
|
3226 'ViewManager', 'Goto Previous Method or Class'), |
|
3227 QKeySequence(QCoreApplication.translate( |
|
3228 'ViewManager', |
|
3229 "Ctrl+Shift+Up", "Search|Goto Previous Method or Class")), |
|
3230 0, |
|
3231 self.searchActGrp, 'vm_search_goto_previous_method_or_class') |
|
3232 self.gotoPreviousDefAct.setStatusTip( |
|
3233 QCoreApplication.translate( |
|
3234 'ViewManager', |
|
3235 'Go to the previous method or class definition')) |
|
3236 self.gotoPreviousDefAct.setWhatsThis(QCoreApplication.translate( |
|
3237 'ViewManager', |
|
3238 """<b>Goto Previous Method or Class</b>""" |
|
3239 """<p>Goes to the line of the previous method or class""" |
|
3240 """ definition and highlights the name.</p>""" |
|
3241 )) |
|
3242 self.gotoPreviousDefAct.triggered.connect( |
|
3243 self.__gotoPreviousMethodClass) |
|
3244 self.searchActions.append(self.gotoPreviousDefAct) |
|
3245 |
|
3246 self.gotoNextDefAct = E5Action( |
|
3247 QCoreApplication.translate( |
|
3248 'ViewManager', 'Goto Next Method or Class'), |
|
3249 QCoreApplication.translate( |
|
3250 'ViewManager', 'Goto Next Method or Class'), |
|
3251 QKeySequence(QCoreApplication.translate( |
|
3252 'ViewManager', |
|
3253 "Ctrl+Shift+Down", "Search|Goto Next Method or Class")), |
|
3254 0, |
|
3255 self.searchActGrp, 'vm_search_goto_next_method_or_class') |
|
3256 self.gotoNextDefAct.setStatusTip(QCoreApplication.translate( |
|
3257 'ViewManager', 'Go to the next method or class definition')) |
|
3258 self.gotoNextDefAct.setWhatsThis(QCoreApplication.translate( |
|
3259 'ViewManager', |
|
3260 """<b>Goto Next Method or Class</b>""" |
|
3261 """<p>Goes to the line of the next method or class definition""" |
|
3262 """ and highlights the name.</p>""" |
|
3263 )) |
|
3264 self.gotoNextDefAct.triggered.connect(self.__gotoNextMethodClass) |
|
3265 self.searchActions.append(self.gotoNextDefAct) |
|
3266 |
|
3267 self.searchActGrp.setEnabled(False) |
|
3268 |
|
3269 self.searchFilesAct = E5Action( |
|
3270 QCoreApplication.translate('ViewManager', 'Search in Files'), |
|
3271 UI.PixmapCache.getIcon("projectFind.png"), |
|
3272 QCoreApplication.translate('ViewManager', 'Search in &Files...'), |
|
3273 QKeySequence(QCoreApplication.translate( |
|
3274 'ViewManager', "Shift+Ctrl+F", "Search|Search Files")), |
|
3275 0, |
|
3276 self, 'vm_search_in_files') |
|
3277 self.searchFilesAct.setStatusTip(QCoreApplication.translate( |
|
3278 'ViewManager', 'Search for a text in files')) |
|
3279 self.searchFilesAct.setWhatsThis(QCoreApplication.translate( |
|
3280 'ViewManager', |
|
3281 """<b>Search in Files</b>""" |
|
3282 """<p>Search for some text in the files of a directory tree""" |
|
3283 """ or the project. A dialog is shown to enter the searchtext""" |
|
3284 """ and options for the search and to display the result.</p>""" |
|
3285 )) |
|
3286 self.searchFilesAct.triggered.connect(self.__searchFiles) |
|
3287 self.searchActions.append(self.searchFilesAct) |
|
3288 |
|
3289 self.replaceFilesAct = E5Action( |
|
3290 QCoreApplication.translate('ViewManager', 'Replace in Files'), |
|
3291 QCoreApplication.translate('ViewManager', 'Replace in F&iles...'), |
|
3292 QKeySequence(QCoreApplication.translate( |
|
3293 'ViewManager', "Shift+Ctrl+R", "Search|Replace in Files")), |
|
3294 0, |
|
3295 self, 'vm_replace_in_files') |
|
3296 self.replaceFilesAct.setStatusTip(QCoreApplication.translate( |
|
3297 'ViewManager', 'Search for a text in files and replace it')) |
|
3298 self.replaceFilesAct.setWhatsThis(QCoreApplication.translate( |
|
3299 'ViewManager', |
|
3300 """<b>Replace in Files</b>""" |
|
3301 """<p>Search for some text in the files of a directory tree""" |
|
3302 """ or the project and replace it. A dialog is shown to enter""" |
|
3303 """ the searchtext, the replacement text and options for the""" |
|
3304 """ search and to display the result.</p>""" |
|
3305 )) |
|
3306 self.replaceFilesAct.triggered.connect(self.__replaceFiles) |
|
3307 self.searchActions.append(self.replaceFilesAct) |
|
3308 |
|
3309 self.searchOpenFilesAct = E5Action( |
|
3310 QCoreApplication.translate( |
|
3311 'ViewManager', 'Search in Open Files'), |
|
3312 UI.PixmapCache.getIcon("documentFind.png"), |
|
3313 QCoreApplication.translate( |
|
3314 'ViewManager', 'Search in Open Files...'), |
|
3315 QKeySequence(QCoreApplication.translate( |
|
3316 'ViewManager', |
|
3317 "Meta+Ctrl+Alt+F", "Search|Search Open Files")), |
|
3318 0, |
|
3319 self.searchActGrp, 'vm_search_in_open_files') |
|
3320 self.searchOpenFilesAct.setStatusTip(QCoreApplication.translate( |
|
3321 'ViewManager', 'Search for a text in open files')) |
|
3322 self.searchOpenFilesAct.setWhatsThis(QCoreApplication.translate( |
|
3323 'ViewManager', |
|
3324 """<b>Search in Open Files</b>""" |
|
3325 """<p>Search for some text in the currently opened files.""" |
|
3326 """ A dialog is shown to enter the searchtext""" |
|
3327 """ and options for the search and to display the result.</p>""" |
|
3328 )) |
|
3329 self.searchOpenFilesAct.triggered.connect(self.__searchOpenFiles) |
|
3330 self.searchActions.append(self.searchOpenFilesAct) |
|
3331 |
|
3332 self.replaceOpenFilesAct = E5Action( |
|
3333 QCoreApplication.translate( |
|
3334 'ViewManager', 'Replace in Open Files'), |
|
3335 QCoreApplication.translate( |
|
3336 'ViewManager', 'Replace in Open Files...'), |
|
3337 QKeySequence(QCoreApplication.translate( |
|
3338 'ViewManager', |
|
3339 "Meta+Ctrl+Alt+R", "Search|Replace in Open Files")), |
|
3340 0, |
|
3341 self.searchActGrp, 'vm_replace_in_open_files') |
|
3342 self.replaceOpenFilesAct.setStatusTip(QCoreApplication.translate( |
|
3343 'ViewManager', 'Search for a text in open files and replace it')) |
|
3344 self.replaceOpenFilesAct.setWhatsThis(QCoreApplication.translate( |
|
3345 'ViewManager', |
|
3346 """<b>Replace in Open Files</b>""" |
|
3347 """<p>Search for some text in the currently opened files""" |
|
3348 """ and replace it. A dialog is shown to enter""" |
|
3349 """ the searchtext, the replacement text and options for the""" |
|
3350 """ search and to display the result.</p>""" |
|
3351 )) |
|
3352 self.replaceOpenFilesAct.triggered.connect(self.__replaceOpenFiles) |
|
3353 self.searchActions.append(self.replaceOpenFilesAct) |
|
3354 |
|
3355 def initSearchToolbars(self, toolbarManager): |
|
3356 """ |
|
3357 Public method to create the Search toolbars. |
|
3358 |
|
3359 @param toolbarManager reference to a toolbar manager object |
|
3360 (E5ToolBarManager) |
|
3361 @return a tuple of the generated toolbar (search, quicksearch) |
|
3362 """ |
|
3363 qtb = QToolBar(QCoreApplication.translate( |
|
3364 'ViewManager', 'Quicksearch'), self.ui) |
|
3365 qtb.setIconSize(UI.Config.ToolBarIconSize) |
|
3366 qtb.setObjectName("QuicksearchToolbar") |
|
3367 qtb.setToolTip(QCoreApplication.translate( |
|
3368 'ViewManager', 'Quicksearch')) |
|
3369 |
|
3370 self.quickFindLineEdit = QuickSearchLineEdit(self) |
|
3371 self.quickFindtextCombo = QComboBox(self) |
|
3372 self.quickFindtextCombo.setEditable(True) |
|
3373 self.quickFindtextCombo.setLineEdit(self.quickFindLineEdit) |
|
3374 self.quickFindtextCombo.setDuplicatesEnabled(False) |
|
3375 self.quickFindtextCombo.setInsertPolicy(QComboBox.InsertAtTop) |
|
3376 self.quickFindtextCombo.lastActive = None |
|
3377 self.quickFindtextCombo.lastCursorPos = None |
|
3378 self.quickFindtextCombo.lastSearchText = "" |
|
3379 self.quickFindtextCombo._editor = self.quickFindtextCombo.lineEdit() |
|
3380 # this allows us not to jump across searched text |
|
3381 # just because of autocompletion enabled |
|
3382 self.quickFindtextCombo.setMinimumWidth(250) |
|
3383 self.quickFindtextCombo.setSizeAdjustPolicy( |
|
3384 QComboBox.AdjustToMinimumContentsLengthWithIcon) |
|
3385 self.quickFindtextCombo.addItem("") |
|
3386 self.quickFindtextCombo.setWhatsThis(QCoreApplication.translate( |
|
3387 'ViewManager', |
|
3388 """<p>Enter the searchtext directly into this field.""" |
|
3389 """ The search will be performed case insensitive.""" |
|
3390 """ The quicksearch function is activated upon activation""" |
|
3391 """ of the quicksearch next action (default key Ctrl+Shift+K),""" |
|
3392 """ if this entry field does not have the input focus.""" |
|
3393 """ Otherwise it searches for the next occurrence of the""" |
|
3394 """ text entered. The quicksearch backwards action""" |
|
3395 """ (default key Ctrl+Shift+J) searches backward.""" |
|
3396 """ Activating the 'quicksearch extend' action""" |
|
3397 """ (default key Ctrl+Shift+H) extends the current""" |
|
3398 """ searchtext to the end of the currently found word.""" |
|
3399 """ The quicksearch can be ended by pressing the Return key""" |
|
3400 """ while the quicksearch entry has the the input focus.</p>""" |
|
3401 )) |
|
3402 self.quickFindtextCombo._editor.returnPressed.connect( |
|
3403 self.__quickSearchEnter) |
|
3404 self.quickFindtextCombo._editor.textChanged.connect( |
|
3405 self.__quickSearchText) |
|
3406 self.quickFindtextCombo._editor.escPressed.connect( |
|
3407 self.__quickSearchEscape) |
|
3408 self.quickFindtextCombo._editor.gotFocus.connect( |
|
3409 self.__quickSearchFocusIn) |
|
3410 self.quickFindtextAction = QWidgetAction(self) |
|
3411 self.quickFindtextAction.setDefaultWidget(self.quickFindtextCombo) |
|
3412 self.quickFindtextAction.setObjectName("vm_quickfindtext_action") |
|
3413 self.quickFindtextAction.setText(QCoreApplication.translate( |
|
3414 'ViewManager', "Quicksearch Textedit")) |
|
3415 qtb.addAction(self.quickFindtextAction) |
|
3416 qtb.addAction(self.quickSearchAct) |
|
3417 qtb.addAction(self.quickSearchBackAct) |
|
3418 qtb.addAction(self.quickSearchExtendAct) |
|
3419 self.quickFindtextCombo.setEnabled(False) |
|
3420 self.__quickSearchToolbar = qtb |
|
3421 self.__quickSearchToolbarVisibility = None |
|
3422 |
|
3423 tb = QToolBar(QCoreApplication.translate('ViewManager', 'Search'), |
|
3424 self.ui) |
|
3425 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
3426 tb.setObjectName("SearchToolbar") |
|
3427 tb.setToolTip(QCoreApplication.translate('ViewManager', 'Search')) |
|
3428 |
|
3429 tb.addAction(self.searchAct) |
|
3430 tb.addAction(self.searchNextAct) |
|
3431 tb.addAction(self.searchPrevAct) |
|
3432 tb.addAction(self.searchNextWordAct) |
|
3433 tb.addAction(self.searchPrevWordAct) |
|
3434 tb.addSeparator() |
|
3435 tb.addAction(self.searchClearMarkersAct) |
|
3436 tb.addSeparator() |
|
3437 tb.addAction(self.searchFilesAct) |
|
3438 tb.addAction(self.searchOpenFilesAct) |
|
3439 tb.addSeparator() |
|
3440 tb.addAction(self.gotoLastEditAct) |
|
3441 |
|
3442 tb.setAllowedAreas( |
|
3443 Qt.ToolBarAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea)) |
|
3444 |
|
3445 toolbarManager.addToolBar(qtb, qtb.windowTitle()) |
|
3446 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
3447 toolbarManager.addAction(self.gotoAct, tb.windowTitle()) |
|
3448 toolbarManager.addAction(self.gotoBraceAct, tb.windowTitle()) |
|
3449 toolbarManager.addAction(self.replaceSelectionAct, tb.windowTitle()) |
|
3450 toolbarManager.addAction(self.replaceAllAct, tb.windowTitle()) |
|
3451 toolbarManager.addAction(self.replaceAndSearchAct, tb.windowTitle()) |
|
3452 |
|
3453 return tb, qtb |
|
3454 |
|
3455 ################################################################## |
|
3456 ## Initialize the view related actions, view menu and toolbar |
|
3457 ################################################################## |
|
3458 |
|
3459 def __initViewActions(self): |
|
3460 """ |
|
3461 Private method defining the user interface actions for the view |
|
3462 commands. |
|
3463 """ |
|
3464 self.viewActGrp = createActionGroup(self) |
|
3465 self.viewFoldActGrp = createActionGroup(self) |
|
3466 |
|
3467 self.zoomInAct = E5Action( |
|
3468 QCoreApplication.translate('ViewManager', 'Zoom in'), |
|
3469 UI.PixmapCache.getIcon("zoomIn.png"), |
|
3470 QCoreApplication.translate('ViewManager', 'Zoom &in'), |
|
3471 QKeySequence(QCoreApplication.translate( |
|
3472 'ViewManager', "Ctrl++", "View|Zoom in")), |
|
3473 QKeySequence(QCoreApplication.translate( |
|
3474 'ViewManager', "Zoom In", "View|Zoom in")), |
|
3475 self.viewActGrp, 'vm_view_zoom_in') |
|
3476 self.zoomInAct.setStatusTip(QCoreApplication.translate( |
|
3477 'ViewManager', 'Zoom in on the text')) |
|
3478 self.zoomInAct.setWhatsThis(QCoreApplication.translate( |
|
3479 'ViewManager', |
|
3480 """<b>Zoom in</b>""" |
|
3481 """<p>Zoom in on the text. This makes the text bigger.</p>""" |
|
3482 )) |
|
3483 self.zoomInAct.triggered.connect(self.__zoomIn) |
|
3484 self.viewActions.append(self.zoomInAct) |
|
3485 |
|
3486 self.zoomOutAct = E5Action( |
|
3487 QCoreApplication.translate('ViewManager', 'Zoom out'), |
|
3488 UI.PixmapCache.getIcon("zoomOut.png"), |
|
3489 QCoreApplication.translate('ViewManager', 'Zoom &out'), |
|
3490 QKeySequence(QCoreApplication.translate( |
|
3491 'ViewManager', "Ctrl+-", "View|Zoom out")), |
|
3492 QKeySequence(QCoreApplication.translate( |
|
3493 'ViewManager', "Zoom Out", "View|Zoom out")), |
|
3494 self.viewActGrp, 'vm_view_zoom_out') |
|
3495 self.zoomOutAct.setStatusTip(QCoreApplication.translate( |
|
3496 'ViewManager', 'Zoom out on the text')) |
|
3497 self.zoomOutAct.setWhatsThis(QCoreApplication.translate( |
|
3498 'ViewManager', |
|
3499 """<b>Zoom out</b>""" |
|
3500 """<p>Zoom out on the text. This makes the text smaller.</p>""" |
|
3501 )) |
|
3502 self.zoomOutAct.triggered.connect(self.__zoomOut) |
|
3503 self.viewActions.append(self.zoomOutAct) |
|
3504 |
|
3505 self.zoomResetAct = E5Action( |
|
3506 QCoreApplication.translate('ViewManager', 'Zoom reset'), |
|
3507 UI.PixmapCache.getIcon("zoomReset.png"), |
|
3508 QCoreApplication.translate('ViewManager', 'Zoom &reset'), |
|
3509 QKeySequence(QCoreApplication.translate( |
|
3510 'ViewManager', "Ctrl+0", "View|Zoom reset")), |
|
3511 0, |
|
3512 self.viewActGrp, 'vm_view_zoom_reset') |
|
3513 self.zoomResetAct.setStatusTip(QCoreApplication.translate( |
|
3514 'ViewManager', 'Reset the zoom of the text')) |
|
3515 self.zoomResetAct.setWhatsThis(QCoreApplication.translate( |
|
3516 'ViewManager', |
|
3517 """<b>Zoom reset</b>""" |
|
3518 """<p>Reset the zoom of the text. """ |
|
3519 """This sets the zoom factor to 100%.</p>""" |
|
3520 )) |
|
3521 self.zoomResetAct.triggered.connect(self.__zoomReset) |
|
3522 self.viewActions.append(self.zoomResetAct) |
|
3523 |
|
3524 self.zoomToAct = E5Action( |
|
3525 QCoreApplication.translate('ViewManager', 'Zoom'), |
|
3526 UI.PixmapCache.getIcon("zoomTo.png"), |
|
3527 QCoreApplication.translate('ViewManager', '&Zoom'), |
|
3528 QKeySequence(QCoreApplication.translate( |
|
3529 'ViewManager', "Ctrl+#", "View|Zoom")), |
|
3530 0, |
|
3531 self.viewActGrp, 'vm_view_zoom') |
|
3532 self.zoomToAct.setStatusTip(QCoreApplication.translate( |
|
3533 'ViewManager', 'Zoom the text')) |
|
3534 self.zoomToAct.setWhatsThis(QCoreApplication.translate( |
|
3535 'ViewManager', |
|
3536 """<b>Zoom</b>""" |
|
3537 """<p>Zoom the text. This opens a dialog where the""" |
|
3538 """ desired size can be entered.</p>""" |
|
3539 )) |
|
3540 self.zoomToAct.triggered.connect(self.__zoom) |
|
3541 self.viewActions.append(self.zoomToAct) |
|
3542 |
|
3543 self.toggleAllAct = E5Action( |
|
3544 QCoreApplication.translate('ViewManager', 'Toggle all folds'), |
|
3545 QCoreApplication.translate('ViewManager', '&Toggle all folds'), |
|
3546 0, 0, self.viewFoldActGrp, 'vm_view_toggle_all_folds') |
|
3547 self.toggleAllAct.setStatusTip(QCoreApplication.translate( |
|
3548 'ViewManager', 'Toggle all folds')) |
|
3549 self.toggleAllAct.setWhatsThis(QCoreApplication.translate( |
|
3550 'ViewManager', |
|
3551 """<b>Toggle all folds</b>""" |
|
3552 """<p>Toggle all folds of the current editor.</p>""" |
|
3553 )) |
|
3554 self.toggleAllAct.triggered.connect(self.__toggleAll) |
|
3555 self.viewActions.append(self.toggleAllAct) |
|
3556 |
|
3557 self.toggleAllChildrenAct = E5Action( |
|
3558 QCoreApplication.translate( |
|
3559 'ViewManager', 'Toggle all folds (including children)'), |
|
3560 QCoreApplication.translate( |
|
3561 'ViewManager', 'Toggle all &folds (including children)'), |
|
3562 0, 0, self.viewFoldActGrp, 'vm_view_toggle_all_folds_children') |
|
3563 self.toggleAllChildrenAct.setStatusTip(QCoreApplication.translate( |
|
3564 'ViewManager', 'Toggle all folds (including children)')) |
|
3565 self.toggleAllChildrenAct.setWhatsThis(QCoreApplication.translate( |
|
3566 'ViewManager', |
|
3567 """<b>Toggle all folds (including children)</b>""" |
|
3568 """<p>Toggle all folds of the current editor including""" |
|
3569 """ all children.</p>""" |
|
3570 )) |
|
3571 self.toggleAllChildrenAct.triggered.connect( |
|
3572 self.__toggleAllChildren) |
|
3573 self.viewActions.append(self.toggleAllChildrenAct) |
|
3574 |
|
3575 self.toggleCurrentAct = E5Action( |
|
3576 QCoreApplication.translate('ViewManager', 'Toggle current fold'), |
|
3577 QCoreApplication.translate('ViewManager', 'Toggle ¤t fold'), |
|
3578 0, 0, self.viewFoldActGrp, 'vm_view_toggle_current_fold') |
|
3579 self.toggleCurrentAct.setStatusTip(QCoreApplication.translate( |
|
3580 'ViewManager', 'Toggle current fold')) |
|
3581 self.toggleCurrentAct.setWhatsThis(QCoreApplication.translate( |
|
3582 'ViewManager', |
|
3583 """<b>Toggle current fold</b>""" |
|
3584 """<p>Toggle the folds of the current line of the current""" |
|
3585 """ editor.</p>""" |
|
3586 )) |
|
3587 self.toggleCurrentAct.triggered.connect(self.__toggleCurrent) |
|
3588 self.viewActions.append(self.toggleCurrentAct) |
|
3589 |
|
3590 self.clearAllFoldsAct = E5Action( |
|
3591 QCoreApplication.translate('ViewManager', 'Clear all folds'), |
|
3592 QCoreApplication.translate('ViewManager', 'Clear &all folds'), |
|
3593 0, 0, self.viewFoldActGrp, 'vm_view_clear_all_folds') |
|
3594 self.clearAllFoldsAct.setStatusTip(QCoreApplication.translate( |
|
3595 'ViewManager', 'Clear all folds')) |
|
3596 self.clearAllFoldsAct.setWhatsThis(QCoreApplication.translate( |
|
3597 'ViewManager', |
|
3598 """<b>Clear all folds</b>""" |
|
3599 """<p>Clear all folds of the current editor, i.e. ensure that""" |
|
3600 """ all lines are displayed unfolded.</p>""" |
|
3601 )) |
|
3602 self.clearAllFoldsAct.triggered.connect(self.__clearAllFolds) |
|
3603 self.viewActions.append(self.clearAllFoldsAct) |
|
3604 |
|
3605 self.unhighlightAct = E5Action( |
|
3606 QCoreApplication.translate('ViewManager', 'Remove all highlights'), |
|
3607 UI.PixmapCache.getIcon("unhighlight.png"), |
|
3608 QCoreApplication.translate('ViewManager', 'Remove all highlights'), |
|
3609 0, 0, |
|
3610 self, 'vm_view_unhighlight') |
|
3611 self.unhighlightAct.setStatusTip(QCoreApplication.translate( |
|
3612 'ViewManager', 'Remove all highlights')) |
|
3613 self.unhighlightAct.setWhatsThis(QCoreApplication.translate( |
|
3614 'ViewManager', |
|
3615 """<b>Remove all highlights</b>""" |
|
3616 """<p>Remove the highlights of all editors.</p>""" |
|
3617 )) |
|
3618 self.unhighlightAct.triggered.connect(self.__unhighlight) |
|
3619 self.viewActions.append(self.unhighlightAct) |
|
3620 |
|
3621 self.newDocumentViewAct = E5Action( |
|
3622 QCoreApplication.translate('ViewManager', 'New Document View'), |
|
3623 UI.PixmapCache.getIcon("documentNewView.png"), |
|
3624 QCoreApplication.translate('ViewManager', 'New &Document View'), |
|
3625 0, 0, self, 'vm_view_new_document_view') |
|
3626 self.newDocumentViewAct.setStatusTip(QCoreApplication.translate( |
|
3627 'ViewManager', 'Open a new view of the current document')) |
|
3628 self.newDocumentViewAct.setWhatsThis(QCoreApplication.translate( |
|
3629 'ViewManager', |
|
3630 """<b>New Document View</b>""" |
|
3631 """<p>Opens a new view of the current document. Both views show""" |
|
3632 """ the same document. However, the cursors may be positioned""" |
|
3633 """ independently.</p>""" |
|
3634 )) |
|
3635 self.newDocumentViewAct.triggered.connect(self.__newDocumentView) |
|
3636 self.viewActions.append(self.newDocumentViewAct) |
|
3637 |
|
3638 self.newDocumentSplitViewAct = E5Action( |
|
3639 QCoreApplication.translate( |
|
3640 'ViewManager', 'New Document View (with new split)'), |
|
3641 UI.PixmapCache.getIcon("splitVertical.png"), |
|
3642 QCoreApplication.translate( |
|
3643 'ViewManager', 'New Document View (with new split)'), |
|
3644 0, 0, self, 'vm_view_new_document_split_view') |
|
3645 self.newDocumentSplitViewAct.setStatusTip(QCoreApplication.translate( |
|
3646 'ViewManager', |
|
3647 'Open a new view of the current document in a new split')) |
|
3648 self.newDocumentSplitViewAct.setWhatsThis(QCoreApplication.translate( |
|
3649 'ViewManager', |
|
3650 """<b>New Document View</b>""" |
|
3651 """<p>Opens a new view of the current document in a new split.""" |
|
3652 """ Both views show the same document. However, the cursors may""" |
|
3653 """ be positioned independently.</p>""" |
|
3654 )) |
|
3655 self.newDocumentSplitViewAct.triggered.connect( |
|
3656 self.__newDocumentSplitView) |
|
3657 self.viewActions.append(self.newDocumentSplitViewAct) |
|
3658 |
|
3659 self.splitViewAct = E5Action( |
|
3660 QCoreApplication.translate('ViewManager', 'Split view'), |
|
3661 UI.PixmapCache.getIcon("splitVertical.png"), |
|
3662 QCoreApplication.translate('ViewManager', '&Split view'), |
|
3663 0, 0, self, 'vm_view_split_view') |
|
3664 self.splitViewAct.setStatusTip(QCoreApplication.translate( |
|
3665 'ViewManager', 'Add a split to the view')) |
|
3666 self.splitViewAct.setWhatsThis(QCoreApplication.translate( |
|
3667 'ViewManager', |
|
3668 """<b>Split view</b>""" |
|
3669 """<p>Add a split to the view.</p>""" |
|
3670 )) |
|
3671 self.splitViewAct.triggered.connect(self.__splitView) |
|
3672 self.viewActions.append(self.splitViewAct) |
|
3673 |
|
3674 self.splitOrientationAct = E5Action( |
|
3675 QCoreApplication.translate('ViewManager', 'Arrange horizontally'), |
|
3676 QCoreApplication.translate('ViewManager', 'Arrange &horizontally'), |
|
3677 0, 0, self, 'vm_view_arrange_horizontally', True) |
|
3678 self.splitOrientationAct.setStatusTip(QCoreApplication.translate( |
|
3679 'ViewManager', 'Arrange the splitted views horizontally')) |
|
3680 self.splitOrientationAct.setWhatsThis(QCoreApplication.translate( |
|
3681 'ViewManager', |
|
3682 """<b>Arrange horizontally</b>""" |
|
3683 """<p>Arrange the splitted views horizontally.</p>""" |
|
3684 )) |
|
3685 self.splitOrientationAct.setChecked(False) |
|
3686 self.splitOrientationAct.toggled[bool].connect(self.__splitOrientation) |
|
3687 self.viewActions.append(self.splitOrientationAct) |
|
3688 |
|
3689 self.splitRemoveAct = E5Action( |
|
3690 QCoreApplication.translate('ViewManager', 'Remove split'), |
|
3691 UI.PixmapCache.getIcon("remsplitVertical.png"), |
|
3692 QCoreApplication.translate('ViewManager', '&Remove split'), |
|
3693 0, 0, self, 'vm_view_remove_split') |
|
3694 self.splitRemoveAct.setStatusTip(QCoreApplication.translate( |
|
3695 'ViewManager', 'Remove the current split')) |
|
3696 self.splitRemoveAct.setWhatsThis(QCoreApplication.translate( |
|
3697 'ViewManager', |
|
3698 """<b>Remove split</b>""" |
|
3699 """<p>Remove the current split.</p>""" |
|
3700 )) |
|
3701 self.splitRemoveAct.triggered.connect(self.removeSplit) |
|
3702 self.viewActions.append(self.splitRemoveAct) |
|
3703 |
|
3704 self.nextSplitAct = E5Action( |
|
3705 QCoreApplication.translate('ViewManager', 'Next split'), |
|
3706 QCoreApplication.translate('ViewManager', '&Next split'), |
|
3707 QKeySequence(QCoreApplication.translate( |
|
3708 'ViewManager', "Ctrl+Alt+N", "View|Next split")), |
|
3709 0, |
|
3710 self, 'vm_next_split') |
|
3711 self.nextSplitAct.setStatusTip(QCoreApplication.translate( |
|
3712 'ViewManager', 'Move to the next split')) |
|
3713 self.nextSplitAct.setWhatsThis(QCoreApplication.translate( |
|
3714 'ViewManager', |
|
3715 """<b>Next split</b>""" |
|
3716 """<p>Move to the next split.</p>""" |
|
3717 )) |
|
3718 self.nextSplitAct.triggered.connect(self.nextSplit) |
|
3719 self.viewActions.append(self.nextSplitAct) |
|
3720 |
|
3721 self.prevSplitAct = E5Action( |
|
3722 QCoreApplication.translate('ViewManager', 'Previous split'), |
|
3723 QCoreApplication.translate('ViewManager', '&Previous split'), |
|
3724 QKeySequence(QCoreApplication.translate( |
|
3725 'ViewManager', "Ctrl+Alt+P", "View|Previous split")), |
|
3726 0, self, 'vm_previous_split') |
|
3727 self.prevSplitAct.setStatusTip(QCoreApplication.translate( |
|
3728 'ViewManager', 'Move to the previous split')) |
|
3729 self.prevSplitAct.setWhatsThis(QCoreApplication.translate( |
|
3730 'ViewManager', |
|
3731 """<b>Previous split</b>""" |
|
3732 """<p>Move to the previous split.</p>""" |
|
3733 )) |
|
3734 self.prevSplitAct.triggered.connect(self.prevSplit) |
|
3735 self.viewActions.append(self.prevSplitAct) |
|
3736 |
|
3737 self.previewAct = E5Action( |
|
3738 QCoreApplication.translate('ViewManager', 'Preview'), |
|
3739 UI.PixmapCache.getIcon("previewer.png"), |
|
3740 QCoreApplication.translate('ViewManager', 'Preview'), |
|
3741 0, 0, self, 'vm_preview', True) |
|
3742 self.previewAct.setStatusTip(QCoreApplication.translate( |
|
3743 'ViewManager', 'Preview the current file in the web browser')) |
|
3744 self.previewAct.setWhatsThis(QCoreApplication.translate( |
|
3745 'ViewManager', |
|
3746 """<b>Preview</b>""" |
|
3747 """<p>This opens the web browser with a preview of""" |
|
3748 """ the current file.</p>""" |
|
3749 )) |
|
3750 self.previewAct.setChecked(Preferences.getUI("ShowFilePreview")) |
|
3751 self.previewAct.toggled[bool].connect(self.__previewEditor) |
|
3752 self.viewActions.append(self.previewAct) |
|
3753 |
|
3754 self.astViewerAct = E5Action( |
|
3755 QCoreApplication.translate('ViewManager', 'Python AST Viewer'), |
|
3756 UI.PixmapCache.getIcon("astTree"), |
|
3757 QCoreApplication.translate('ViewManager', 'Python AST Viewer'), |
|
3758 0, 0, self, 'vm_python_ast_viewer', True) |
|
3759 self.astViewerAct.setStatusTip(QCoreApplication.translate( |
|
3760 'ViewManager', 'Show the AST for the current Python file')) |
|
3761 self.astViewerAct.setWhatsThis(QCoreApplication.translate( |
|
3762 'ViewManager', |
|
3763 """<b>Python AST Viewer</b>""" |
|
3764 """<p>This opens the a tree view of the AST of the current""" |
|
3765 """ Python source file.</p>""" |
|
3766 )) |
|
3767 self.astViewerAct.setChecked(False) |
|
3768 self.astViewerAct.toggled[bool].connect(self.__astViewer) |
|
3769 self.viewActions.append(self.astViewerAct) |
|
3770 |
|
3771 self.viewActGrp.setEnabled(False) |
|
3772 self.viewFoldActGrp.setEnabled(False) |
|
3773 self.unhighlightAct.setEnabled(False) |
|
3774 self.splitViewAct.setEnabled(False) |
|
3775 self.splitOrientationAct.setEnabled(False) |
|
3776 self.splitRemoveAct.setEnabled(False) |
|
3777 self.nextSplitAct.setEnabled(False) |
|
3778 self.prevSplitAct.setEnabled(False) |
|
3779 self.previewAct.setEnabled(True) |
|
3780 self.astViewerAct.setEnabled(False) |
|
3781 self.newDocumentViewAct.setEnabled(False) |
|
3782 self.newDocumentSplitViewAct.setEnabled(False) |
|
3783 |
|
3784 self.splitOrientationAct.setChecked( |
|
3785 Preferences.getUI("SplitOrientationVertical")) |
|
3786 |
|
3787 def initViewMenu(self): |
|
3788 """ |
|
3789 Public method to create the View menu. |
|
3790 |
|
3791 @return the generated menu |
|
3792 """ |
|
3793 menu = QMenu(QCoreApplication.translate('ViewManager', '&View'), |
|
3794 self.ui) |
|
3795 menu.setTearOffEnabled(True) |
|
3796 menu.addActions(self.viewActGrp.actions()) |
|
3797 menu.addSeparator() |
|
3798 menu.addActions(self.viewFoldActGrp.actions()) |
|
3799 menu.addSeparator() |
|
3800 menu.addAction(self.previewAct) |
|
3801 menu.addAction(self.astViewerAct) |
|
3802 menu.addSeparator() |
|
3803 menu.addAction(self.unhighlightAct) |
|
3804 menu.addSeparator() |
|
3805 menu.addAction(self.newDocumentViewAct) |
|
3806 if self.canSplit(): |
|
3807 menu.addAction(self.newDocumentSplitViewAct) |
|
3808 menu.addSeparator() |
|
3809 menu.addAction(self.splitViewAct) |
|
3810 menu.addAction(self.splitOrientationAct) |
|
3811 menu.addAction(self.splitRemoveAct) |
|
3812 menu.addAction(self.nextSplitAct) |
|
3813 menu.addAction(self.prevSplitAct) |
|
3814 |
|
3815 return menu |
|
3816 |
|
3817 def initViewToolbar(self, toolbarManager): |
|
3818 """ |
|
3819 Public method to create the View toolbar. |
|
3820 |
|
3821 @param toolbarManager reference to a toolbar manager object |
|
3822 (E5ToolBarManager) |
|
3823 @return the generated toolbar |
|
3824 """ |
|
3825 tb = QToolBar(QCoreApplication.translate('ViewManager', 'View'), |
|
3826 self.ui) |
|
3827 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
3828 tb.setObjectName("ViewToolbar") |
|
3829 tb.setToolTip(QCoreApplication.translate('ViewManager', 'View')) |
|
3830 |
|
3831 tb.addActions(self.viewActGrp.actions()) |
|
3832 tb.addSeparator() |
|
3833 tb.addAction(self.previewAct) |
|
3834 tb.addAction(self.astViewerAct) |
|
3835 tb.addSeparator() |
|
3836 tb.addAction(self.newDocumentViewAct) |
|
3837 if self.canSplit(): |
|
3838 tb.addAction(self.newDocumentSplitViewAct) |
|
3839 |
|
3840 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
3841 toolbarManager.addAction(self.unhighlightAct, tb.windowTitle()) |
|
3842 toolbarManager.addAction(self.splitViewAct, tb.windowTitle()) |
|
3843 toolbarManager.addAction(self.splitRemoveAct, tb.windowTitle()) |
|
3844 |
|
3845 return tb |
|
3846 |
|
3847 ################################################################## |
|
3848 ## Initialize the macro related actions and macro menu |
|
3849 ################################################################## |
|
3850 |
|
3851 def __initMacroActions(self): |
|
3852 """ |
|
3853 Private method defining the user interface actions for the macro |
|
3854 commands. |
|
3855 """ |
|
3856 self.macroActGrp = createActionGroup(self) |
|
3857 |
|
3858 self.macroStartRecAct = E5Action( |
|
3859 QCoreApplication.translate( |
|
3860 'ViewManager', 'Start Macro Recording'), |
|
3861 QCoreApplication.translate( |
|
3862 'ViewManager', 'S&tart Macro Recording'), |
|
3863 0, 0, self.macroActGrp, 'vm_macro_start_recording') |
|
3864 self.macroStartRecAct.setStatusTip(QCoreApplication.translate( |
|
3865 'ViewManager', 'Start Macro Recording')) |
|
3866 self.macroStartRecAct.setWhatsThis(QCoreApplication.translate( |
|
3867 'ViewManager', |
|
3868 """<b>Start Macro Recording</b>""" |
|
3869 """<p>Start recording editor commands into a new macro.</p>""" |
|
3870 )) |
|
3871 self.macroStartRecAct.triggered.connect(self.__macroStartRecording) |
|
3872 self.macroActions.append(self.macroStartRecAct) |
|
3873 |
|
3874 self.macroStopRecAct = E5Action( |
|
3875 QCoreApplication.translate('ViewManager', 'Stop Macro Recording'), |
|
3876 QCoreApplication.translate('ViewManager', 'Sto&p Macro Recording'), |
|
3877 0, 0, self.macroActGrp, 'vm_macro_stop_recording') |
|
3878 self.macroStopRecAct.setStatusTip(QCoreApplication.translate( |
|
3879 'ViewManager', 'Stop Macro Recording')) |
|
3880 self.macroStopRecAct.setWhatsThis(QCoreApplication.translate( |
|
3881 'ViewManager', |
|
3882 """<b>Stop Macro Recording</b>""" |
|
3883 """<p>Stop recording editor commands into a new macro.</p>""" |
|
3884 )) |
|
3885 self.macroStopRecAct.triggered.connect(self.__macroStopRecording) |
|
3886 self.macroActions.append(self.macroStopRecAct) |
|
3887 |
|
3888 self.macroRunAct = E5Action( |
|
3889 QCoreApplication.translate('ViewManager', 'Run Macro'), |
|
3890 QCoreApplication.translate('ViewManager', '&Run Macro'), |
|
3891 0, 0, self.macroActGrp, 'vm_macro_run') |
|
3892 self.macroRunAct.setStatusTip(QCoreApplication.translate( |
|
3893 'ViewManager', 'Run Macro')) |
|
3894 self.macroRunAct.setWhatsThis(QCoreApplication.translate( |
|
3895 'ViewManager', |
|
3896 """<b>Run Macro</b>""" |
|
3897 """<p>Run a previously recorded editor macro.</p>""" |
|
3898 )) |
|
3899 self.macroRunAct.triggered.connect(self.__macroRun) |
|
3900 self.macroActions.append(self.macroRunAct) |
|
3901 |
|
3902 self.macroDeleteAct = E5Action( |
|
3903 QCoreApplication.translate('ViewManager', 'Delete Macro'), |
|
3904 QCoreApplication.translate('ViewManager', '&Delete Macro'), |
|
3905 0, 0, self.macroActGrp, 'vm_macro_delete') |
|
3906 self.macroDeleteAct.setStatusTip(QCoreApplication.translate( |
|
3907 'ViewManager', 'Delete Macro')) |
|
3908 self.macroDeleteAct.setWhatsThis(QCoreApplication.translate( |
|
3909 'ViewManager', |
|
3910 """<b>Delete Macro</b>""" |
|
3911 """<p>Delete a previously recorded editor macro.</p>""" |
|
3912 )) |
|
3913 self.macroDeleteAct.triggered.connect(self.__macroDelete) |
|
3914 self.macroActions.append(self.macroDeleteAct) |
|
3915 |
|
3916 self.macroLoadAct = E5Action( |
|
3917 QCoreApplication.translate('ViewManager', 'Load Macro'), |
|
3918 QCoreApplication.translate('ViewManager', '&Load Macro'), |
|
3919 0, 0, self.macroActGrp, 'vm_macro_load') |
|
3920 self.macroLoadAct.setStatusTip(QCoreApplication.translate( |
|
3921 'ViewManager', 'Load Macro')) |
|
3922 self.macroLoadAct.setWhatsThis(QCoreApplication.translate( |
|
3923 'ViewManager', |
|
3924 """<b>Load Macro</b>""" |
|
3925 """<p>Load an editor macro from a file.</p>""" |
|
3926 )) |
|
3927 self.macroLoadAct.triggered.connect(self.__macroLoad) |
|
3928 self.macroActions.append(self.macroLoadAct) |
|
3929 |
|
3930 self.macroSaveAct = E5Action( |
|
3931 QCoreApplication.translate('ViewManager', 'Save Macro'), |
|
3932 QCoreApplication.translate('ViewManager', '&Save Macro'), |
|
3933 0, 0, self.macroActGrp, 'vm_macro_save') |
|
3934 self.macroSaveAct.setStatusTip(QCoreApplication.translate( |
|
3935 'ViewManager', 'Save Macro')) |
|
3936 self.macroSaveAct.setWhatsThis(QCoreApplication.translate( |
|
3937 'ViewManager', |
|
3938 """<b>Save Macro</b>""" |
|
3939 """<p>Save a previously recorded editor macro to a file.</p>""" |
|
3940 )) |
|
3941 self.macroSaveAct.triggered.connect(self.__macroSave) |
|
3942 self.macroActions.append(self.macroSaveAct) |
|
3943 |
|
3944 self.macroActGrp.setEnabled(False) |
|
3945 |
|
3946 def initMacroMenu(self): |
|
3947 """ |
|
3948 Public method to create the Macro menu. |
|
3949 |
|
3950 @return the generated menu |
|
3951 """ |
|
3952 menu = QMenu(QCoreApplication.translate('ViewManager', "&Macros"), |
|
3953 self.ui) |
|
3954 menu.setTearOffEnabled(True) |
|
3955 menu.addActions(self.macroActGrp.actions()) |
|
3956 |
|
3957 return menu |
|
3958 |
|
3959 ##################################################################### |
|
3960 ## Initialize the bookmark related actions, bookmark menu and toolbar |
|
3961 ##################################################################### |
|
3962 |
|
3963 def __initBookmarkActions(self): |
|
3964 """ |
|
3965 Private method defining the user interface actions for the bookmarks |
|
3966 commands. |
|
3967 """ |
|
3968 self.bookmarkActGrp = createActionGroup(self) |
|
3969 |
|
3970 self.bookmarkToggleAct = E5Action( |
|
3971 QCoreApplication.translate('ViewManager', 'Toggle Bookmark'), |
|
3972 UI.PixmapCache.getIcon("bookmarkToggle.png"), |
|
3973 QCoreApplication.translate('ViewManager', '&Toggle Bookmark'), |
|
3974 QKeySequence(QCoreApplication.translate( |
|
3975 'ViewManager', "Alt+Ctrl+T", "Bookmark|Toggle")), |
|
3976 0, |
|
3977 self.bookmarkActGrp, 'vm_bookmark_toggle') |
|
3978 self.bookmarkToggleAct.setStatusTip(QCoreApplication.translate( |
|
3979 'ViewManager', 'Toggle Bookmark')) |
|
3980 self.bookmarkToggleAct.setWhatsThis(QCoreApplication.translate( |
|
3981 'ViewManager', |
|
3982 """<b>Toggle Bookmark</b>""" |
|
3983 """<p>Toggle a bookmark at the current line of the current""" |
|
3984 """ editor.</p>""" |
|
3985 )) |
|
3986 self.bookmarkToggleAct.triggered.connect(self.__toggleBookmark) |
|
3987 self.bookmarkActions.append(self.bookmarkToggleAct) |
|
3988 |
|
3989 self.bookmarkNextAct = E5Action( |
|
3990 QCoreApplication.translate('ViewManager', 'Next Bookmark'), |
|
3991 UI.PixmapCache.getIcon("bookmarkNext.png"), |
|
3992 QCoreApplication.translate('ViewManager', '&Next Bookmark'), |
|
3993 QKeySequence(QCoreApplication.translate( |
|
3994 'ViewManager', "Ctrl+PgDown", "Bookmark|Next")), |
|
3995 0, |
|
3996 self.bookmarkActGrp, 'vm_bookmark_next') |
|
3997 self.bookmarkNextAct.setStatusTip(QCoreApplication.translate( |
|
3998 'ViewManager', 'Next Bookmark')) |
|
3999 self.bookmarkNextAct.setWhatsThis(QCoreApplication.translate( |
|
4000 'ViewManager', |
|
4001 """<b>Next Bookmark</b>""" |
|
4002 """<p>Go to next bookmark of the current editor.</p>""" |
|
4003 )) |
|
4004 self.bookmarkNextAct.triggered.connect(self.__nextBookmark) |
|
4005 self.bookmarkActions.append(self.bookmarkNextAct) |
|
4006 |
|
4007 self.bookmarkPreviousAct = E5Action( |
|
4008 QCoreApplication.translate('ViewManager', 'Previous Bookmark'), |
|
4009 UI.PixmapCache.getIcon("bookmarkPrevious.png"), |
|
4010 QCoreApplication.translate('ViewManager', '&Previous Bookmark'), |
|
4011 QKeySequence(QCoreApplication.translate( |
|
4012 'ViewManager', "Ctrl+PgUp", "Bookmark|Previous")), |
|
4013 0, |
|
4014 self.bookmarkActGrp, 'vm_bookmark_previous') |
|
4015 self.bookmarkPreviousAct.setStatusTip(QCoreApplication.translate( |
|
4016 'ViewManager', 'Previous Bookmark')) |
|
4017 self.bookmarkPreviousAct.setWhatsThis(QCoreApplication.translate( |
|
4018 'ViewManager', |
|
4019 """<b>Previous Bookmark</b>""" |
|
4020 """<p>Go to previous bookmark of the current editor.</p>""" |
|
4021 )) |
|
4022 self.bookmarkPreviousAct.triggered.connect(self.__previousBookmark) |
|
4023 self.bookmarkActions.append(self.bookmarkPreviousAct) |
|
4024 |
|
4025 self.bookmarkClearAct = E5Action( |
|
4026 QCoreApplication.translate('ViewManager', 'Clear Bookmarks'), |
|
4027 QCoreApplication.translate('ViewManager', '&Clear Bookmarks'), |
|
4028 QKeySequence(QCoreApplication.translate( |
|
4029 'ViewManager', "Alt+Ctrl+C", "Bookmark|Clear")), |
|
4030 0, |
|
4031 self.bookmarkActGrp, 'vm_bookmark_clear') |
|
4032 self.bookmarkClearAct.setStatusTip(QCoreApplication.translate( |
|
4033 'ViewManager', 'Clear Bookmarks')) |
|
4034 self.bookmarkClearAct.setWhatsThis(QCoreApplication.translate( |
|
4035 'ViewManager', |
|
4036 """<b>Clear Bookmarks</b>""" |
|
4037 """<p>Clear bookmarks of all editors.</p>""" |
|
4038 )) |
|
4039 self.bookmarkClearAct.triggered.connect(self.__clearAllBookmarks) |
|
4040 self.bookmarkActions.append(self.bookmarkClearAct) |
|
4041 |
|
4042 self.syntaxErrorGotoAct = E5Action( |
|
4043 QCoreApplication.translate('ViewManager', 'Goto Syntax Error'), |
|
4044 UI.PixmapCache.getIcon("syntaxErrorGoto.png"), |
|
4045 QCoreApplication.translate('ViewManager', '&Goto Syntax Error'), |
|
4046 0, 0, |
|
4047 self.bookmarkActGrp, 'vm_syntaxerror_goto') |
|
4048 self.syntaxErrorGotoAct.setStatusTip(QCoreApplication.translate( |
|
4049 'ViewManager', 'Goto Syntax Error')) |
|
4050 self.syntaxErrorGotoAct.setWhatsThis(QCoreApplication.translate( |
|
4051 'ViewManager', |
|
4052 """<b>Goto Syntax Error</b>""" |
|
4053 """<p>Go to next syntax error of the current editor.</p>""" |
|
4054 )) |
|
4055 self.syntaxErrorGotoAct.triggered.connect(self.__gotoSyntaxError) |
|
4056 self.bookmarkActions.append(self.syntaxErrorGotoAct) |
|
4057 |
|
4058 self.syntaxErrorClearAct = E5Action( |
|
4059 QCoreApplication.translate('ViewManager', 'Clear Syntax Errors'), |
|
4060 QCoreApplication.translate('ViewManager', 'Clear &Syntax Errors'), |
|
4061 0, 0, |
|
4062 self.bookmarkActGrp, 'vm_syntaxerror_clear') |
|
4063 self.syntaxErrorClearAct.setStatusTip(QCoreApplication.translate( |
|
4064 'ViewManager', 'Clear Syntax Errors')) |
|
4065 self.syntaxErrorClearAct.setWhatsThis(QCoreApplication.translate( |
|
4066 'ViewManager', |
|
4067 """<b>Clear Syntax Errors</b>""" |
|
4068 """<p>Clear syntax errors of all editors.</p>""" |
|
4069 )) |
|
4070 self.syntaxErrorClearAct.triggered.connect( |
|
4071 self.__clearAllSyntaxErrors) |
|
4072 self.bookmarkActions.append(self.syntaxErrorClearAct) |
|
4073 |
|
4074 self.warningsNextAct = E5Action( |
|
4075 QCoreApplication.translate('ViewManager', 'Next warning message'), |
|
4076 UI.PixmapCache.getIcon("warningNext.png"), |
|
4077 QCoreApplication.translate('ViewManager', '&Next warning message'), |
|
4078 0, 0, |
|
4079 self.bookmarkActGrp, 'vm_warning_next') |
|
4080 self.warningsNextAct.setStatusTip(QCoreApplication.translate( |
|
4081 'ViewManager', 'Next warning message')) |
|
4082 self.warningsNextAct.setWhatsThis(QCoreApplication.translate( |
|
4083 'ViewManager', |
|
4084 """<b>Next warning message</b>""" |
|
4085 """<p>Go to next line of the current editor""" |
|
4086 """ having a pyflakes warning.</p>""" |
|
4087 )) |
|
4088 self.warningsNextAct.triggered.connect(self.__nextWarning) |
|
4089 self.bookmarkActions.append(self.warningsNextAct) |
|
4090 |
|
4091 self.warningsPreviousAct = E5Action( |
|
4092 QCoreApplication.translate( |
|
4093 'ViewManager', 'Previous warning message'), |
|
4094 UI.PixmapCache.getIcon("warningPrev.png"), |
|
4095 QCoreApplication.translate( |
|
4096 'ViewManager', '&Previous warning message'), |
|
4097 0, 0, |
|
4098 self.bookmarkActGrp, 'vm_warning_previous') |
|
4099 self.warningsPreviousAct.setStatusTip(QCoreApplication.translate( |
|
4100 'ViewManager', 'Previous warning message')) |
|
4101 self.warningsPreviousAct.setWhatsThis(QCoreApplication.translate( |
|
4102 'ViewManager', |
|
4103 """<b>Previous warning message</b>""" |
|
4104 """<p>Go to previous line of the current editor""" |
|
4105 """ having a pyflakes warning.</p>""" |
|
4106 )) |
|
4107 self.warningsPreviousAct.triggered.connect(self.__previousWarning) |
|
4108 self.bookmarkActions.append(self.warningsPreviousAct) |
|
4109 |
|
4110 self.warningsClearAct = E5Action( |
|
4111 QCoreApplication.translate( |
|
4112 'ViewManager', 'Clear Warning Messages'), |
|
4113 QCoreApplication.translate( |
|
4114 'ViewManager', 'Clear &Warning Messages'), |
|
4115 0, 0, |
|
4116 self.bookmarkActGrp, 'vm_warnings_clear') |
|
4117 self.warningsClearAct.setStatusTip(QCoreApplication.translate( |
|
4118 'ViewManager', 'Clear Warning Messages')) |
|
4119 self.warningsClearAct.setWhatsThis(QCoreApplication.translate( |
|
4120 'ViewManager', |
|
4121 """<b>Clear Warning Messages</b>""" |
|
4122 """<p>Clear pyflakes warning messages of all editors.</p>""" |
|
4123 )) |
|
4124 self.warningsClearAct.triggered.connect(self.__clearAllWarnings) |
|
4125 self.bookmarkActions.append(self.warningsClearAct) |
|
4126 |
|
4127 self.notcoveredNextAct = E5Action( |
|
4128 QCoreApplication.translate('ViewManager', 'Next uncovered line'), |
|
4129 UI.PixmapCache.getIcon("notcoveredNext.png"), |
|
4130 QCoreApplication.translate('ViewManager', '&Next uncovered line'), |
|
4131 0, 0, |
|
4132 self.bookmarkActGrp, 'vm_uncovered_next') |
|
4133 self.notcoveredNextAct.setStatusTip(QCoreApplication.translate( |
|
4134 'ViewManager', 'Next uncovered line')) |
|
4135 self.notcoveredNextAct.setWhatsThis(QCoreApplication.translate( |
|
4136 'ViewManager', |
|
4137 """<b>Next uncovered line</b>""" |
|
4138 """<p>Go to next line of the current editor marked as not""" |
|
4139 """ covered.</p>""" |
|
4140 )) |
|
4141 self.notcoveredNextAct.triggered.connect(self.__nextUncovered) |
|
4142 self.bookmarkActions.append(self.notcoveredNextAct) |
|
4143 |
|
4144 self.notcoveredPreviousAct = E5Action( |
|
4145 QCoreApplication.translate( |
|
4146 'ViewManager', 'Previous uncovered line'), |
|
4147 UI.PixmapCache.getIcon("notcoveredPrev.png"), |
|
4148 QCoreApplication.translate( |
|
4149 'ViewManager', '&Previous uncovered line'), |
|
4150 0, 0, |
|
4151 self.bookmarkActGrp, 'vm_uncovered_previous') |
|
4152 self.notcoveredPreviousAct.setStatusTip(QCoreApplication.translate( |
|
4153 'ViewManager', 'Previous uncovered line')) |
|
4154 self.notcoveredPreviousAct.setWhatsThis(QCoreApplication.translate( |
|
4155 'ViewManager', |
|
4156 """<b>Previous uncovered line</b>""" |
|
4157 """<p>Go to previous line of the current editor marked""" |
|
4158 """ as not covered.</p>""" |
|
4159 )) |
|
4160 self.notcoveredPreviousAct.triggered.connect( |
|
4161 self.__previousUncovered) |
|
4162 self.bookmarkActions.append(self.notcoveredPreviousAct) |
|
4163 |
|
4164 self.taskNextAct = E5Action( |
|
4165 QCoreApplication.translate('ViewManager', 'Next Task'), |
|
4166 UI.PixmapCache.getIcon("taskNext.png"), |
|
4167 QCoreApplication.translate('ViewManager', '&Next Task'), |
|
4168 0, 0, |
|
4169 self.bookmarkActGrp, 'vm_task_next') |
|
4170 self.taskNextAct.setStatusTip(QCoreApplication.translate( |
|
4171 'ViewManager', 'Next Task')) |
|
4172 self.taskNextAct.setWhatsThis(QCoreApplication.translate( |
|
4173 'ViewManager', |
|
4174 """<b>Next Task</b>""" |
|
4175 """<p>Go to next line of the current editor having a task.</p>""" |
|
4176 )) |
|
4177 self.taskNextAct.triggered.connect(self.__nextTask) |
|
4178 self.bookmarkActions.append(self.taskNextAct) |
|
4179 |
|
4180 self.taskPreviousAct = E5Action( |
|
4181 QCoreApplication.translate('ViewManager', 'Previous Task'), |
|
4182 UI.PixmapCache.getIcon("taskPrev.png"), |
|
4183 QCoreApplication.translate( |
|
4184 'ViewManager', '&Previous Task'), |
|
4185 0, 0, |
|
4186 self.bookmarkActGrp, 'vm_task_previous') |
|
4187 self.taskPreviousAct.setStatusTip(QCoreApplication.translate( |
|
4188 'ViewManager', 'Previous Task')) |
|
4189 self.taskPreviousAct.setWhatsThis(QCoreApplication.translate( |
|
4190 'ViewManager', |
|
4191 """<b>Previous Task</b>""" |
|
4192 """<p>Go to previous line of the current editor having a""" |
|
4193 """ task.</p>""" |
|
4194 )) |
|
4195 self.taskPreviousAct.triggered.connect(self.__previousTask) |
|
4196 self.bookmarkActions.append(self.taskPreviousAct) |
|
4197 |
|
4198 self.changeNextAct = E5Action( |
|
4199 QCoreApplication.translate('ViewManager', 'Next Change'), |
|
4200 UI.PixmapCache.getIcon("changeNext.png"), |
|
4201 QCoreApplication.translate('ViewManager', '&Next Change'), |
|
4202 0, 0, |
|
4203 self.bookmarkActGrp, 'vm_change_next') |
|
4204 self.changeNextAct.setStatusTip(QCoreApplication.translate( |
|
4205 'ViewManager', 'Next Change')) |
|
4206 self.changeNextAct.setWhatsThis(QCoreApplication.translate( |
|
4207 'ViewManager', |
|
4208 """<b>Next Change</b>""" |
|
4209 """<p>Go to next line of the current editor having a change""" |
|
4210 """ marker.</p>""" |
|
4211 )) |
|
4212 self.changeNextAct.triggered.connect(self.__nextChange) |
|
4213 self.bookmarkActions.append(self.changeNextAct) |
|
4214 |
|
4215 self.changePreviousAct = E5Action( |
|
4216 QCoreApplication.translate('ViewManager', 'Previous Change'), |
|
4217 UI.PixmapCache.getIcon("changePrev.png"), |
|
4218 QCoreApplication.translate( |
|
4219 'ViewManager', '&Previous Change'), |
|
4220 0, 0, |
|
4221 self.bookmarkActGrp, 'vm_change_previous') |
|
4222 self.changePreviousAct.setStatusTip(QCoreApplication.translate( |
|
4223 'ViewManager', 'Previous Change')) |
|
4224 self.changePreviousAct.setWhatsThis(QCoreApplication.translate( |
|
4225 'ViewManager', |
|
4226 """<b>Previous Change</b>""" |
|
4227 """<p>Go to previous line of the current editor having""" |
|
4228 """ a change marker.</p>""" |
|
4229 )) |
|
4230 self.changePreviousAct.triggered.connect(self.__previousChange) |
|
4231 self.bookmarkActions.append(self.changePreviousAct) |
|
4232 |
|
4233 self.bookmarkActGrp.setEnabled(False) |
|
4234 |
|
4235 def initBookmarkMenu(self): |
|
4236 """ |
|
4237 Public method to create the Bookmark menu. |
|
4238 |
|
4239 @return the generated menu |
|
4240 """ |
|
4241 menu = QMenu(QCoreApplication.translate('ViewManager', '&Bookmarks'), |
|
4242 self.ui) |
|
4243 self.bookmarksMenu = QMenu( |
|
4244 QCoreApplication.translate('ViewManager', '&Bookmarks'), |
|
4245 menu) |
|
4246 menu.setTearOffEnabled(True) |
|
4247 |
|
4248 menu.addAction(self.bookmarkToggleAct) |
|
4249 menu.addAction(self.bookmarkNextAct) |
|
4250 menu.addAction(self.bookmarkPreviousAct) |
|
4251 menu.addAction(self.bookmarkClearAct) |
|
4252 menu.addSeparator() |
|
4253 self.menuBookmarksAct = menu.addMenu(self.bookmarksMenu) |
|
4254 menu.addSeparator() |
|
4255 menu.addAction(self.syntaxErrorGotoAct) |
|
4256 menu.addAction(self.syntaxErrorClearAct) |
|
4257 menu.addSeparator() |
|
4258 menu.addAction(self.warningsNextAct) |
|
4259 menu.addAction(self.warningsPreviousAct) |
|
4260 menu.addAction(self.warningsClearAct) |
|
4261 menu.addSeparator() |
|
4262 menu.addAction(self.notcoveredNextAct) |
|
4263 menu.addAction(self.notcoveredPreviousAct) |
|
4264 menu.addSeparator() |
|
4265 menu.addAction(self.taskNextAct) |
|
4266 menu.addAction(self.taskPreviousAct) |
|
4267 menu.addSeparator() |
|
4268 menu.addAction(self.changeNextAct) |
|
4269 menu.addAction(self.changePreviousAct) |
|
4270 |
|
4271 self.bookmarksMenu.aboutToShow.connect(self.__showBookmarksMenu) |
|
4272 self.bookmarksMenu.triggered.connect(self.__bookmarkSelected) |
|
4273 menu.aboutToShow.connect(self.__showBookmarkMenu) |
|
4274 |
|
4275 return menu |
|
4276 |
|
4277 def initBookmarkToolbar(self, toolbarManager): |
|
4278 """ |
|
4279 Public method to create the Bookmark toolbar. |
|
4280 |
|
4281 @param toolbarManager reference to a toolbar manager object |
|
4282 (E5ToolBarManager) |
|
4283 @return the generated toolbar |
|
4284 """ |
|
4285 tb = QToolBar(QCoreApplication.translate('ViewManager', 'Bookmarks'), |
|
4286 self.ui) |
|
4287 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
4288 tb.setObjectName("BookmarksToolbar") |
|
4289 tb.setToolTip(QCoreApplication.translate('ViewManager', 'Bookmarks')) |
|
4290 |
|
4291 tb.addAction(self.bookmarkToggleAct) |
|
4292 tb.addAction(self.bookmarkNextAct) |
|
4293 tb.addAction(self.bookmarkPreviousAct) |
|
4294 tb.addSeparator() |
|
4295 tb.addAction(self.syntaxErrorGotoAct) |
|
4296 tb.addSeparator() |
|
4297 tb.addAction(self.warningsNextAct) |
|
4298 tb.addAction(self.warningsPreviousAct) |
|
4299 tb.addSeparator() |
|
4300 tb.addAction(self.taskNextAct) |
|
4301 tb.addAction(self.taskPreviousAct) |
|
4302 tb.addSeparator() |
|
4303 tb.addAction(self.changeNextAct) |
|
4304 tb.addAction(self.changePreviousAct) |
|
4305 |
|
4306 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
4307 toolbarManager.addAction(self.notcoveredNextAct, tb.windowTitle()) |
|
4308 toolbarManager.addAction(self.notcoveredPreviousAct, tb.windowTitle()) |
|
4309 |
|
4310 return tb |
|
4311 |
|
4312 ################################################################## |
|
4313 ## Initialize the spell checking related actions |
|
4314 ################################################################## |
|
4315 |
|
4316 def __initSpellingActions(self): |
|
4317 """ |
|
4318 Private method to initialize the spell checking actions. |
|
4319 """ |
|
4320 self.spellingActGrp = createActionGroup(self) |
|
4321 |
|
4322 self.spellCheckAct = E5Action( |
|
4323 QCoreApplication.translate('ViewManager', 'Check spelling'), |
|
4324 UI.PixmapCache.getIcon("spellchecking.png"), |
|
4325 QCoreApplication.translate( |
|
4326 'ViewManager', 'Check &spelling...'), |
|
4327 QKeySequence(QCoreApplication.translate( |
|
4328 'ViewManager', "Shift+F7", "Spelling|Spell Check")), |
|
4329 0, |
|
4330 self.spellingActGrp, 'vm_spelling_spellcheck') |
|
4331 self.spellCheckAct.setStatusTip(QCoreApplication.translate( |
|
4332 'ViewManager', 'Perform spell check of current editor')) |
|
4333 self.spellCheckAct.setWhatsThis(QCoreApplication.translate( |
|
4334 'ViewManager', |
|
4335 """<b>Check spelling</b>""" |
|
4336 """<p>Perform a spell check of the current editor.</p>""" |
|
4337 )) |
|
4338 self.spellCheckAct.triggered.connect(self.__spellCheck) |
|
4339 self.spellingActions.append(self.spellCheckAct) |
|
4340 |
|
4341 self.autoSpellCheckAct = E5Action( |
|
4342 QCoreApplication.translate( |
|
4343 'ViewManager', 'Automatic spell checking'), |
|
4344 UI.PixmapCache.getIcon("autospellchecking.png"), |
|
4345 QCoreApplication.translate( |
|
4346 'ViewManager', '&Automatic spell checking'), |
|
4347 0, 0, |
|
4348 self.spellingActGrp, 'vm_spelling_autospellcheck', True) |
|
4349 self.autoSpellCheckAct.setStatusTip(QCoreApplication.translate( |
|
4350 'ViewManager', '(De-)Activate automatic spell checking')) |
|
4351 self.autoSpellCheckAct.setWhatsThis(QCoreApplication.translate( |
|
4352 'ViewManager', |
|
4353 """<b>Automatic spell checking</b>""" |
|
4354 """<p>Activate or deactivate the automatic spell checking""" |
|
4355 """ function of all editors.</p>""" |
|
4356 )) |
|
4357 self.autoSpellCheckAct.setChecked( |
|
4358 Preferences.getEditor("AutoSpellCheckingEnabled")) |
|
4359 self.autoSpellCheckAct.triggered.connect( |
|
4360 self.__setAutoSpellChecking) |
|
4361 self.spellingActions.append(self.autoSpellCheckAct) |
|
4362 |
|
4363 self.__enableSpellingActions() |
|
4364 |
|
4365 def __enableSpellingActions(self): |
|
4366 """ |
|
4367 Private method to set the enabled state of the spelling actions. |
|
4368 """ |
|
4369 from QScintilla.SpellChecker import SpellChecker |
|
4370 spellingAvailable = SpellChecker.isAvailable() |
|
4371 |
|
4372 self.spellCheckAct.setEnabled( |
|
4373 len(self.editors) != 0 and spellingAvailable) |
|
4374 self.autoSpellCheckAct.setEnabled(spellingAvailable) |
|
4375 |
|
4376 def addToExtrasMenu(self, menu): |
|
4377 """ |
|
4378 Public method to add some actions to the extras menu. |
|
4379 |
|
4380 @param menu reference to the menu to add actions to (QMenu) |
|
4381 """ |
|
4382 self.__editSpellingMenu = QMenu(QCoreApplication.translate( |
|
4383 'ViewManager', "Edit Dictionary")) |
|
4384 self.__editProjectPwlAct = self.__editSpellingMenu.addAction( |
|
4385 QCoreApplication.translate('ViewManager', "Project Word List"), |
|
4386 self.__editProjectPWL) |
|
4387 self.__editProjectPelAct = self.__editSpellingMenu.addAction( |
|
4388 QCoreApplication.translate( |
|
4389 'ViewManager', "Project Exception List"), |
|
4390 self.__editProjectPEL) |
|
4391 self.__editSpellingMenu.addSeparator() |
|
4392 self.__editUserPwlAct = self.__editSpellingMenu.addAction( |
|
4393 QCoreApplication.translate('ViewManager', "User Word List"), |
|
4394 self.__editUserPWL) |
|
4395 self.__editUserPelAct = self.__editSpellingMenu.addAction( |
|
4396 QCoreApplication.translate('ViewManager', "User Exception List"), |
|
4397 self.__editUserPEL) |
|
4398 self.__editSpellingMenu.aboutToShow.connect( |
|
4399 self.__showEditSpellingMenu) |
|
4400 |
|
4401 menu.addAction(self.spellCheckAct) |
|
4402 menu.addAction(self.autoSpellCheckAct) |
|
4403 menu.addMenu(self.__editSpellingMenu) |
|
4404 menu.addSeparator() |
|
4405 |
|
4406 def initSpellingToolbar(self, toolbarManager): |
|
4407 """ |
|
4408 Public method to create the Spelling toolbar. |
|
4409 |
|
4410 @param toolbarManager reference to a toolbar manager object |
|
4411 (E5ToolBarManager) |
|
4412 @return the generated toolbar |
|
4413 """ |
|
4414 tb = QToolBar(QCoreApplication.translate('ViewManager', 'Spelling'), |
|
4415 self.ui) |
|
4416 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
4417 tb.setObjectName("SpellingToolbar") |
|
4418 tb.setToolTip(QCoreApplication.translate('ViewManager', 'Spelling')) |
|
4419 |
|
4420 tb.addAction(self.spellCheckAct) |
|
4421 tb.addAction(self.autoSpellCheckAct) |
|
4422 |
|
4423 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
4424 |
|
4425 return tb |
|
4426 |
|
4427 ################################################################## |
|
4428 ## Methods and slots that deal with file and window handling |
|
4429 ################################################################## |
|
4430 |
|
4431 def __openFiles(self): |
|
4432 """ |
|
4433 Private slot to open some files. |
|
4434 """ |
|
4435 # set the cwd of the dialog based on the following search criteria: |
|
4436 # 1: Directory of currently active editor |
|
4437 # 2: Directory of currently active project |
|
4438 # 3: CWD |
|
4439 import QScintilla.Lexers |
|
4440 fileFilter = self._getOpenFileFilter() |
|
4441 progs = E5FileDialog.getOpenFileNamesAndFilter( |
|
4442 self.ui, |
|
4443 QCoreApplication.translate('ViewManager', "Open files"), |
|
4444 self._getOpenStartDir(), |
|
4445 QScintilla.Lexers.getOpenFileFiltersList(True, True), |
|
4446 fileFilter)[0] |
|
4447 for prog in progs: |
|
4448 self.openFiles(prog) |
|
4449 |
|
4450 def openFiles(self, prog): |
|
4451 """ |
|
4452 Public slot to open some files. |
|
4453 |
|
4454 @param prog name of file to be opened (string) |
|
4455 """ |
|
4456 prog = Utilities.normabspath(prog) |
|
4457 # Open up the new files. |
|
4458 self.openSourceFile(prog) |
|
4459 |
|
4460 def checkDirty(self, editor, autosave=False): |
|
4461 """ |
|
4462 Public method to check the dirty status and open a message window. |
|
4463 |
|
4464 @param editor editor window to check |
|
4465 @type Editor |
|
4466 @param autosave flag indicating that the file should be saved |
|
4467 automatically |
|
4468 @type bool |
|
4469 @return flag indicating successful reset of the dirty flag |
|
4470 @rtype bool |
|
4471 """ |
|
4472 if editor.isModified(): |
|
4473 fn = editor.getFileName() |
|
4474 # ignore the dirty status, if there is more than one open editor |
|
4475 # for the same file |
|
4476 if fn and self.getOpenEditorCount(fn) > 1: |
|
4477 return True |
|
4478 |
|
4479 if fn is None: |
|
4480 fn = editor.getNoName() |
|
4481 autosave = False |
|
4482 if autosave: |
|
4483 res = editor.saveFile() |
|
4484 else: |
|
4485 res = E5MessageBox.okToClearData( |
|
4486 self.ui, |
|
4487 QCoreApplication.translate('ViewManager', "File Modified"), |
|
4488 QCoreApplication.translate( |
|
4489 'ViewManager', |
|
4490 """<p>The file <b>{0}</b> has unsaved changes.</p>""") |
|
4491 .format(fn), |
|
4492 editor.saveFile) |
|
4493 if res: |
|
4494 self.setEditorName(editor, editor.getFileName()) |
|
4495 return res |
|
4496 |
|
4497 return True |
|
4498 |
|
4499 def checkAllDirty(self): |
|
4500 """ |
|
4501 Public method to check the dirty status of all editors. |
|
4502 |
|
4503 @return flag indicating successful reset of all dirty flags |
|
4504 @rtype bool |
|
4505 """ |
|
4506 for editor in self.editors: |
|
4507 if not self.checkDirty(editor): |
|
4508 return False |
|
4509 |
|
4510 return True |
|
4511 |
|
4512 def checkFileDirty(self, fn): |
|
4513 """ |
|
4514 Public method to check the dirty status of an editor given its file |
|
4515 name and open a message window. |
|
4516 |
|
4517 @param fn file name of editor to be checked |
|
4518 @type str |
|
4519 @return flag indicating successful reset of the dirty flag |
|
4520 @rtype bool |
|
4521 """ |
|
4522 for editor in self.editors: |
|
4523 if Utilities.samepath(fn, editor.getFileName()): |
|
4524 break |
|
4525 else: |
|
4526 return True |
|
4527 |
|
4528 res = self.checkDirty(editor) |
|
4529 return res |
|
4530 |
|
4531 def closeEditor(self, editor, ignoreDirty=False): |
|
4532 """ |
|
4533 Public method to close an editor window. |
|
4534 |
|
4535 @param editor editor window to be closed |
|
4536 @type Editor |
|
4537 @param ignoreDirty flag indicating to ignore the 'dirty' status |
|
4538 @type bool |
|
4539 @return flag indicating success |
|
4540 @rtype bool |
|
4541 """ |
|
4542 # save file if necessary |
|
4543 if not ignoreDirty and not self.checkDirty(editor): |
|
4544 return False |
|
4545 |
|
4546 # get the filename of the editor for later use |
|
4547 fn = editor.getFileName() |
|
4548 |
|
4549 # remove the window |
|
4550 editor.parent().shutdownTimer() |
|
4551 self._removeView(editor) |
|
4552 self.editors.remove(editor) |
|
4553 |
|
4554 # send a signal, if it was the last editor for this filename |
|
4555 if fn and self.getOpenEditor(fn) is None: |
|
4556 self.editorClosed.emit(fn) |
|
4557 self.editorClosedEd.emit(editor) |
|
4558 |
|
4559 # send a signal, if it was the very last editor |
|
4560 if not len(self.editors): |
|
4561 self.__lastEditorClosed() |
|
4562 self.lastEditorClosed.emit() |
|
4563 |
|
4564 editor.deleteLater() |
|
4565 |
|
4566 return True |
|
4567 |
|
4568 def closeCurrentWindow(self): |
|
4569 """ |
|
4570 Public method to close the current window. |
|
4571 |
|
4572 @return flag indicating success (boolean) |
|
4573 """ |
|
4574 aw = self.activeWindow() |
|
4575 if aw is None: |
|
4576 return False |
|
4577 |
|
4578 res = self.closeEditor(aw) |
|
4579 if res and aw == self.currentEditor: |
|
4580 self.currentEditor = None |
|
4581 |
|
4582 return res |
|
4583 |
|
4584 def closeAllWindows(self): |
|
4585 """ |
|
4586 Public method to close all editor windows via file menu. |
|
4587 """ |
|
4588 savedEditors = self.editors[:] |
|
4589 for editor in savedEditors: |
|
4590 self.closeEditor(editor) |
|
4591 |
|
4592 def closeWindow(self, fn, ignoreDirty=False): |
|
4593 """ |
|
4594 Public method to close an arbitrary source editor. |
|
4595 |
|
4596 @param fn file name of the editor to be closed |
|
4597 @type str |
|
4598 @param ignoreDirty flag indicating to ignore the 'dirty' status |
|
4599 @type bool |
|
4600 @return flag indicating success |
|
4601 @rtype bool |
|
4602 """ |
|
4603 for editor in self.editors: |
|
4604 if Utilities.samepath(fn, editor.getFileName()): |
|
4605 break |
|
4606 else: |
|
4607 return True |
|
4608 |
|
4609 res = self.closeEditor(editor, ignoreDirty=ignoreDirty) |
|
4610 if res and editor == self.currentEditor: |
|
4611 self.currentEditor = None |
|
4612 |
|
4613 return res |
|
4614 |
|
4615 def closeEditorWindow(self, editor): |
|
4616 """ |
|
4617 Public method to close an arbitrary source editor. |
|
4618 |
|
4619 @param editor editor to be closed |
|
4620 """ |
|
4621 if editor is None: |
|
4622 return |
|
4623 |
|
4624 res = self.closeEditor(editor) |
|
4625 if res and editor == self.currentEditor: |
|
4626 self.currentEditor = None |
|
4627 |
|
4628 def exit(self): |
|
4629 """ |
|
4630 Public method to handle the debugged program terminating. |
|
4631 """ |
|
4632 if self.currentEditor is not None: |
|
4633 self.currentEditor.highlight() |
|
4634 self.currentEditor = None |
|
4635 |
|
4636 for editor in self.editors: |
|
4637 editor.refreshCoverageAnnotations() |
|
4638 |
|
4639 self.__setSbFile() |
|
4640 |
|
4641 def openSourceFile(self, fn, lineno=-1, filetype="", |
|
4642 selStart=0, selEnd=0, pos=0, addNext=False, |
|
4643 indexes=None): |
|
4644 """ |
|
4645 Public slot to display a file in an editor. |
|
4646 |
|
4647 @param fn name of file to be opened |
|
4648 @type str |
|
4649 @param lineno line number to place the cursor at or list of line |
|
4650 numbers (cursor will be placed at the next line greater than |
|
4651 the current one) |
|
4652 @type int or list of int |
|
4653 @param filetype type of the source file |
|
4654 @type str |
|
4655 @param selStart start of an area to be selected |
|
4656 @type int |
|
4657 @param selEnd end of an area to be selected |
|
4658 @type int |
|
4659 @param pos position within the line to place the cursor at |
|
4660 @type int |
|
4661 @param addNext flag indicating to add the file next to the current |
|
4662 editor |
|
4663 @type bool |
|
4664 @param indexes of the editor, first the split view index, second the |
|
4665 index within the view |
|
4666 @type tuple of two int |
|
4667 @return reference to the opened editor |
|
4668 @rtype Editor |
|
4669 """ |
|
4670 try: |
|
4671 newWin, editor = self.getEditor(fn, filetype=filetype, |
|
4672 addNext=addNext, indexes=indexes) |
|
4673 except (IOError, UnicodeDecodeError): |
|
4674 return None |
|
4675 |
|
4676 if newWin: |
|
4677 self._modificationStatusChanged(editor.isModified(), editor) |
|
4678 self._checkActions(editor) |
|
4679 |
|
4680 cline, cindex = editor.getCursorPosition() |
|
4681 cline += 1 |
|
4682 if isinstance(lineno, list): |
|
4683 if len(lineno) > 1: |
|
4684 for line in lineno: |
|
4685 if line > cline: |
|
4686 break |
|
4687 else: |
|
4688 line = lineno[0] |
|
4689 elif len(lineno) == 1: |
|
4690 line = lineno[0] |
|
4691 else: |
|
4692 line = -1 |
|
4693 else: |
|
4694 line = lineno |
|
4695 |
|
4696 if line >= 0 and line != cline: |
|
4697 editor.ensureVisibleTop(line) |
|
4698 editor.gotoLine(line, pos) |
|
4699 |
|
4700 if selStart != selEnd: |
|
4701 editor.setSelection(line - 1, selStart, line - 1, selEnd) |
|
4702 |
|
4703 # insert filename into list of recently opened files |
|
4704 self.addToRecentList(fn) |
|
4705 |
|
4706 return editor |
|
4707 |
|
4708 def __connectEditor(self, editor): |
|
4709 """ |
|
4710 Private method to establish all editor connections. |
|
4711 |
|
4712 @param editor reference to the editor object to be connected |
|
4713 """ |
|
4714 editor.modificationStatusChanged.connect( |
|
4715 self._modificationStatusChanged) |
|
4716 editor.cursorChanged.connect( |
|
4717 lambda f, l, p: self.__cursorChanged(f, l, p, editor)) |
|
4718 editor.editorSaved.connect( |
|
4719 lambda fn: self.__editorSaved(fn, editor)) |
|
4720 editor.editorRenamed.connect( |
|
4721 lambda fn: self.__editorRenamed(fn, editor)) |
|
4722 editor.breakpointToggled.connect(self.__breakpointToggled) |
|
4723 editor.bookmarkToggled.connect(self.__bookmarkToggled) |
|
4724 editor.syntaxerrorToggled.connect(self._syntaxErrorToggled) |
|
4725 editor.coverageMarkersShown.connect(self.__coverageMarkersShown) |
|
4726 editor.autoCompletionAPIsAvailable.connect( |
|
4727 lambda a: self.__editorAutoCompletionAPIsAvailable(a, editor)) |
|
4728 editor.undoAvailable.connect(self.undoAct.setEnabled) |
|
4729 editor.redoAvailable.connect(self.redoAct.setEnabled) |
|
4730 editor.taskMarkersUpdated.connect(self.__taskMarkersUpdated) |
|
4731 editor.changeMarkersUpdated.connect(self.__changeMarkersUpdated) |
|
4732 editor.languageChanged.connect( |
|
4733 lambda: self.__editorConfigChanged(editor)) |
|
4734 editor.eolChanged.connect( |
|
4735 lambda: self.__editorConfigChanged(editor)) |
|
4736 editor.encodingChanged.connect( |
|
4737 lambda: self.__editorConfigChanged(editor)) |
|
4738 editor.selectionChanged.connect( |
|
4739 lambda: self.__searchWidget.selectionChanged(editor)) |
|
4740 editor.selectionChanged.connect( |
|
4741 lambda: self.__replaceWidget.selectionChanged(editor)) |
|
4742 editor.selectionChanged.connect( |
|
4743 lambda: self.__editorSelectionChanged(editor)) |
|
4744 editor.lastEditPositionAvailable.connect( |
|
4745 self.__lastEditPositionAvailable) |
|
4746 editor.zoomValueChanged.connect( |
|
4747 lambda v: self.zoomValueChanged(v, editor)) |
|
4748 editor.mouseDoubleClick.connect( |
|
4749 lambda pos, buttons: self.__editorDoubleClicked(editor, pos, |
|
4750 buttons)) |
|
4751 |
|
4752 editor.languageChanged.connect( |
|
4753 lambda: self.editorLanguageChanged.emit(editor)) |
|
4754 editor.textChanged.connect(lambda: self.editorTextChanged.emit(editor)) |
|
4755 |
|
4756 def newEditorView(self, fn, caller, filetype="", indexes=None): |
|
4757 """ |
|
4758 Public method to create a new editor displaying the given document. |
|
4759 |
|
4760 @param fn filename of this view |
|
4761 @type str |
|
4762 @param caller reference to the editor calling this method |
|
4763 @type Editor |
|
4764 @param filetype type of the source file |
|
4765 @type str |
|
4766 @param indexes of the editor, first the split view index, second the |
|
4767 index within the view |
|
4768 @type tuple of two int |
|
4769 @return reference to the new editor object |
|
4770 @rtype Editor |
|
4771 """ |
|
4772 editor, assembly = self.cloneEditor(caller, filetype, fn) |
|
4773 |
|
4774 self._addView(assembly, fn, caller.getNoName(), indexes=indexes) |
|
4775 self._modificationStatusChanged(editor.isModified(), editor) |
|
4776 self._checkActions(editor) |
|
4777 |
|
4778 return editor |
|
4779 |
|
4780 def cloneEditor(self, caller, filetype, fn): |
|
4781 """ |
|
4782 Public method to clone an editor displaying the given document. |
|
4783 |
|
4784 @param caller reference to the editor calling this method |
|
4785 @param filetype type of the source file (string) |
|
4786 @param fn filename of this view |
|
4787 @return reference to the new editor object (Editor.Editor) and the new |
|
4788 editor assembly object (EditorAssembly.EditorAssembly) |
|
4789 """ |
|
4790 from QScintilla.EditorAssembly import EditorAssembly |
|
4791 assembly = EditorAssembly(self.dbs, fn, self, filetype=filetype, |
|
4792 editor=caller, |
|
4793 tv=e5App().getObject("TaskViewer")) |
|
4794 editor = assembly.getEditor() |
|
4795 self.editors.append(editor) |
|
4796 self.__connectEditor(editor) |
|
4797 self.__editorOpened() |
|
4798 self.editorOpened.emit(fn) |
|
4799 self.editorOpenedEd.emit(editor) |
|
4800 |
|
4801 return editor, assembly |
|
4802 |
|
4803 def addToRecentList(self, fn): |
|
4804 """ |
|
4805 Public slot to add a filename to the list of recently opened files. |
|
4806 |
|
4807 @param fn name of the file to be added |
|
4808 """ |
|
4809 for recent in self.recent[:]: |
|
4810 if Utilities.samepath(fn, recent): |
|
4811 self.recent.remove(recent) |
|
4812 self.recent.insert(0, fn) |
|
4813 maxRecent = Preferences.getUI("RecentNumber") |
|
4814 if len(self.recent) > maxRecent: |
|
4815 self.recent = self.recent[:maxRecent] |
|
4816 self.__saveRecent() |
|
4817 |
|
4818 def showDebugSource(self, fn, line): |
|
4819 """ |
|
4820 Public method to open the given file and highlight the given line in |
|
4821 it. |
|
4822 |
|
4823 @param fn filename of editor to update (string) |
|
4824 @param line line number to highlight (int) |
|
4825 """ |
|
4826 if not fn.startswith('<'): |
|
4827 self.openSourceFile(fn, line) |
|
4828 self.setFileLine(fn, line) |
|
4829 |
|
4830 def setFileLine(self, fn, line, error=False, syntaxError=False): |
|
4831 """ |
|
4832 Public method to update the user interface when the current program |
|
4833 or line changes. |
|
4834 |
|
4835 @param fn filename of editor to update (string) |
|
4836 @param line line number to highlight (int) |
|
4837 @param error flag indicating an error highlight (boolean) |
|
4838 @param syntaxError flag indicating a syntax error |
|
4839 """ |
|
4840 try: |
|
4841 newWin, self.currentEditor = self.getEditor(fn) |
|
4842 except (IOError, UnicodeDecodeError): |
|
4843 return |
|
4844 |
|
4845 enc = self.currentEditor.getEncoding() |
|
4846 lang = self.currentEditor.getLanguage() |
|
4847 eol = self.currentEditor.getEolIndicator() |
|
4848 zoom = self.currentEditor.getZoom() |
|
4849 self.__setSbFile(fn, line, encoding=enc, language=lang, eol=eol, |
|
4850 zoom=zoom) |
|
4851 |
|
4852 # Change the highlighted line. |
|
4853 self.currentEditor.highlight(line, error, syntaxError) |
|
4854 |
|
4855 self.currentEditor.highlightVisible() |
|
4856 self._checkActions(self.currentEditor, False) |
|
4857 |
|
4858 def __setSbFile(self, fn=None, line=None, pos=None, |
|
4859 encoding=None, language=None, eol=None, |
|
4860 zoom=None): |
|
4861 """ |
|
4862 Private method to set the file info in the status bar. |
|
4863 |
|
4864 @param fn filename to display (string) |
|
4865 @param line line number to display (int) |
|
4866 @param pos character position to display (int) |
|
4867 @param encoding encoding name to display (string) |
|
4868 @param language language to display (string) |
|
4869 @param eol eol indicator to display (string) |
|
4870 @param zoom zoom value (integer) |
|
4871 """ |
|
4872 if not fn: |
|
4873 fn = '' |
|
4874 writ = ' ' |
|
4875 else: |
|
4876 if QFileInfo(fn).isWritable(): |
|
4877 writ = 'rw' |
|
4878 else: |
|
4879 writ = 'ro' |
|
4880 self.sbWritable.setText(writ) |
|
4881 |
|
4882 if line is None: |
|
4883 line = '' |
|
4884 self.sbLine.setText( |
|
4885 QCoreApplication.translate('ViewManager', 'Line: {0:5}') |
|
4886 .format(line)) |
|
4887 |
|
4888 if pos is None: |
|
4889 pos = '' |
|
4890 self.sbPos.setText( |
|
4891 QCoreApplication.translate('ViewManager', 'Pos: {0:5}') |
|
4892 .format(pos)) |
|
4893 |
|
4894 if encoding is None: |
|
4895 encoding = '' |
|
4896 self.sbEnc.setText(encoding) |
|
4897 |
|
4898 if language is None: |
|
4899 pixmap = QPixmap() |
|
4900 elif language == "": |
|
4901 pixmap = UI.PixmapCache.getPixmap("fileText.png") |
|
4902 else: |
|
4903 import QScintilla.Lexers |
|
4904 pixmap = QScintilla.Lexers.getLanguageIcon(language, True) |
|
4905 self.sbLang.setPixmap(pixmap) |
|
4906 if pixmap.isNull(): |
|
4907 self.sbLang.setText(language) |
|
4908 self.sbLang.setToolTip("") |
|
4909 else: |
|
4910 self.sbLang.setText("") |
|
4911 self.sbLang.setToolTip( |
|
4912 QCoreApplication.translate('ViewManager', 'Language: {0}') |
|
4913 .format(language)) |
|
4914 |
|
4915 if eol is None: |
|
4916 eol = '' |
|
4917 self.sbEol.setPixmap(self.__eolPixmap(eol)) |
|
4918 self.sbEol.setToolTip( |
|
4919 QCoreApplication.translate('ViewManager', 'EOL Mode: {0}') |
|
4920 .format(eol)) |
|
4921 |
|
4922 if zoom is None: |
|
4923 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
4924 aw = e5App().getObject("Shell") |
|
4925 else: |
|
4926 aw = self.activeWindow() |
|
4927 if aw: |
|
4928 self.sbZoom.setValue(aw.getZoom()) |
|
4929 else: |
|
4930 self.sbZoom.setValue(zoom) |
|
4931 |
|
4932 def __eolPixmap(self, eolIndicator): |
|
4933 """ |
|
4934 Private method to get an EOL pixmap for an EOL string. |
|
4935 |
|
4936 @param eolIndicator eol indicator string (string) |
|
4937 @return pixmap for the eol indicator (QPixmap) |
|
4938 """ |
|
4939 if eolIndicator == "LF": |
|
4940 pixmap = UI.PixmapCache.getPixmap("eolLinux.png") |
|
4941 elif eolIndicator == "CR": |
|
4942 pixmap = UI.PixmapCache.getPixmap("eolMac.png") |
|
4943 elif eolIndicator == "CRLF": |
|
4944 pixmap = UI.PixmapCache.getPixmap("eolWindows.png") |
|
4945 else: |
|
4946 pixmap = QPixmap() |
|
4947 return pixmap |
|
4948 |
|
4949 def __unhighlight(self): |
|
4950 """ |
|
4951 Private slot to switch of all highlights. |
|
4952 """ |
|
4953 self.unhighlight() |
|
4954 |
|
4955 def unhighlight(self, current=False): |
|
4956 """ |
|
4957 Public method to switch off all highlights or the highlight of |
|
4958 the current editor. |
|
4959 |
|
4960 @param current flag indicating only the current editor should be |
|
4961 unhighlighted (boolean) |
|
4962 """ |
|
4963 if current: |
|
4964 if self.currentEditor is not None: |
|
4965 self.currentEditor.highlight() |
|
4966 else: |
|
4967 for editor in self.editors: |
|
4968 editor.highlight() |
|
4969 |
|
4970 def getOpenFilenames(self): |
|
4971 """ |
|
4972 Public method returning a list of the filenames of all editors. |
|
4973 |
|
4974 @return list of all opened filenames (list of strings) |
|
4975 """ |
|
4976 filenames = [] |
|
4977 for editor in self.editors: |
|
4978 fn = editor.getFileName() |
|
4979 if fn is not None and fn not in filenames and os.path.exists(fn): |
|
4980 # only return names of existing files |
|
4981 filenames.append(fn) |
|
4982 |
|
4983 return filenames |
|
4984 |
|
4985 def getEditor(self, fn, filetype="", addNext=False, indexes=None): |
|
4986 """ |
|
4987 Public method to return the editor displaying the given file. |
|
4988 |
|
4989 If there is no editor with the given file, a new editor window is |
|
4990 created. |
|
4991 |
|
4992 @param fn filename to look for |
|
4993 @type str |
|
4994 @param filetype type of the source file |
|
4995 @type str |
|
4996 @param addNext flag indicating that if a new editor needs to be |
|
4997 created, it should be added next to the current editor |
|
4998 @type bool |
|
4999 @param indexes of the editor, first the split view index, second the |
|
5000 index within the view |
|
5001 @type tuple of two int |
|
5002 @return tuple of two values giving a flag indicating a new window |
|
5003 creation and a reference to the editor displaying this file |
|
5004 @rtype tuple of (bool, Editor) |
|
5005 """ |
|
5006 newWin = False |
|
5007 editor = self.activeWindow() |
|
5008 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
|
5009 for editor in self.editors: |
|
5010 if Utilities.samepath(fn, editor.getFileName()): |
|
5011 break |
|
5012 else: |
|
5013 from QScintilla.EditorAssembly import EditorAssembly |
|
5014 assembly = EditorAssembly(self.dbs, fn, self, |
|
5015 filetype=filetype, |
|
5016 tv=e5App().getObject("TaskViewer")) |
|
5017 editor = assembly.getEditor() |
|
5018 self.editors.append(editor) |
|
5019 self.__connectEditor(editor) |
|
5020 self.__editorOpened() |
|
5021 self.editorOpened.emit(fn) |
|
5022 self.editorOpenedEd.emit(editor) |
|
5023 newWin = True |
|
5024 |
|
5025 if newWin: |
|
5026 self._addView(assembly, fn, addNext=addNext, indexes=indexes) |
|
5027 else: |
|
5028 self._showView(editor.parent(), fn) |
|
5029 |
|
5030 return (newWin, editor) |
|
5031 |
|
5032 def getOpenEditors(self): |
|
5033 """ |
|
5034 Public method to get references to all open editors. |
|
5035 |
|
5036 @return list of references to all open editors (list of |
|
5037 QScintilla.editor) |
|
5038 """ |
|
5039 return self.editors |
|
5040 |
|
5041 def getOpenEditorsCount(self): |
|
5042 """ |
|
5043 Public method to get the number of open editors. |
|
5044 |
|
5045 @return number of open editors (integer) |
|
5046 """ |
|
5047 return len(self.editors) |
|
5048 |
|
5049 def getOpenEditor(self, fn): |
|
5050 """ |
|
5051 Public method to return the editor displaying the given file. |
|
5052 |
|
5053 @param fn filename to look for |
|
5054 @return a reference to the editor displaying this file or None, if |
|
5055 no editor was found |
|
5056 """ |
|
5057 for editor in self.editors: |
|
5058 if Utilities.samepath(fn, editor.getFileName()): |
|
5059 return editor |
|
5060 |
|
5061 return None |
|
5062 |
|
5063 def getOpenEditorCount(self, fn): |
|
5064 """ |
|
5065 Public method to return the count of editors displaying the given file. |
|
5066 |
|
5067 @param fn filename to look for |
|
5068 @return count of editors displaying this file (integer) |
|
5069 """ |
|
5070 count = 0 |
|
5071 for editor in self.editors: |
|
5072 if Utilities.samepath(fn, editor.getFileName()): |
|
5073 count += 1 |
|
5074 return count |
|
5075 |
|
5076 def getOpenEditorsForSession(self): |
|
5077 """ |
|
5078 Public method to get a lists of all open editors. |
|
5079 |
|
5080 The returned list contains one list per split view. If the view manager |
|
5081 cannot split the view, only one list of editors is returned. |
|
5082 |
|
5083 Note: This method should be implemented by subclasses. |
|
5084 |
|
5085 @return list of list of editor references |
|
5086 @rtype list of list of Editor |
|
5087 """ |
|
5088 return [self.editors] |
|
5089 |
|
5090 def getActiveName(self): |
|
5091 """ |
|
5092 Public method to retrieve the filename of the active window. |
|
5093 |
|
5094 @return filename of active window (string) |
|
5095 """ |
|
5096 aw = self.activeWindow() |
|
5097 if aw: |
|
5098 return aw.getFileName() |
|
5099 else: |
|
5100 return None |
|
5101 |
|
5102 def saveEditor(self, fn): |
|
5103 """ |
|
5104 Public method to save a named editor file. |
|
5105 |
|
5106 @param fn filename of editor to be saved (string) |
|
5107 @return flag indicating success (boolean) |
|
5108 """ |
|
5109 for editor in self.editors: |
|
5110 if Utilities.samepath(fn, editor.getFileName()): |
|
5111 break |
|
5112 else: |
|
5113 return True |
|
5114 |
|
5115 if not editor.isModified(): |
|
5116 return True |
|
5117 else: |
|
5118 ok = editor.saveFile() |
|
5119 return ok |
|
5120 |
|
5121 def saveEditorEd(self, ed): |
|
5122 """ |
|
5123 Public slot to save the contents of an editor. |
|
5124 |
|
5125 @param ed editor to be saved |
|
5126 @return flag indicating success (boolean) |
|
5127 """ |
|
5128 if ed: |
|
5129 if not ed.isModified(): |
|
5130 return True |
|
5131 else: |
|
5132 ok = ed.saveFile() |
|
5133 if ok: |
|
5134 self.setEditorName(ed, ed.getFileName()) |
|
5135 return ok |
|
5136 else: |
|
5137 return False |
|
5138 |
|
5139 def saveCurrentEditor(self): |
|
5140 """ |
|
5141 Public slot to save the contents of the current editor. |
|
5142 """ |
|
5143 aw = self.activeWindow() |
|
5144 self.saveEditorEd(aw) |
|
5145 |
|
5146 def saveAsEditorEd(self, ed): |
|
5147 """ |
|
5148 Public slot to save the contents of an editor to a new file. |
|
5149 |
|
5150 @param ed editor to be saved |
|
5151 """ |
|
5152 if ed: |
|
5153 ok = ed.saveFileAs() |
|
5154 if ok: |
|
5155 self.setEditorName(ed, ed.getFileName()) |
|
5156 |
|
5157 def saveAsCurrentEditor(self): |
|
5158 """ |
|
5159 Public slot to save the contents of the current editor to a new file. |
|
5160 """ |
|
5161 aw = self.activeWindow() |
|
5162 self.saveAsEditorEd(aw) |
|
5163 |
|
5164 def saveCopyEditorEd(self, ed): |
|
5165 """ |
|
5166 Public slot to save the contents of an editor to a new copy of |
|
5167 the file. |
|
5168 |
|
5169 @param ed editor to be saved |
|
5170 """ |
|
5171 if ed: |
|
5172 ed.saveFileCopy() |
|
5173 |
|
5174 def saveCopyCurrentEditor(self): |
|
5175 """ |
|
5176 Public slot to save the contents of the current editor to a new copy |
|
5177 of the file. |
|
5178 """ |
|
5179 aw = self.activeWindow() |
|
5180 self.saveCopyEditorEd(aw) |
|
5181 |
|
5182 def saveEditorsList(self, editors): |
|
5183 """ |
|
5184 Public slot to save a list of editors. |
|
5185 |
|
5186 @param editors list of editors to be saved |
|
5187 """ |
|
5188 for editor in editors: |
|
5189 ok = editor.saveFile() |
|
5190 if ok: |
|
5191 self.setEditorName(editor, editor.getFileName()) |
|
5192 |
|
5193 def saveAllEditors(self): |
|
5194 """ |
|
5195 Public slot to save the contents of all editors. |
|
5196 """ |
|
5197 for editor in self.editors: |
|
5198 ok = editor.saveFile() |
|
5199 if ok: |
|
5200 self.setEditorName(editor, editor.getFileName()) |
|
5201 |
|
5202 # restart autosave timer |
|
5203 if self.autosaveInterval > 0: |
|
5204 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
5205 |
|
5206 def __exportMenuTriggered(self, act): |
|
5207 """ |
|
5208 Private method to handle the selection of an export format. |
|
5209 |
|
5210 @param act reference to the action that was triggered (QAction) |
|
5211 """ |
|
5212 aw = self.activeWindow() |
|
5213 if aw: |
|
5214 exporterFormat = act.data() |
|
5215 aw.exportFile(exporterFormat) |
|
5216 |
|
5217 def newEditor(self): |
|
5218 """ |
|
5219 Public slot to generate a new empty editor. |
|
5220 """ |
|
5221 from QScintilla.EditorAssembly import EditorAssembly |
|
5222 assembly = EditorAssembly(self.dbs, "", self, |
|
5223 tv=e5App().getObject("TaskViewer")) |
|
5224 editor = assembly.getEditor() |
|
5225 self.editors.append(editor) |
|
5226 self.__connectEditor(editor) |
|
5227 self._addView(assembly, None) |
|
5228 self.__editorOpened() |
|
5229 self._checkActions(editor) |
|
5230 self.editorOpened.emit("") |
|
5231 self.editorOpenedEd.emit(editor) |
|
5232 |
|
5233 def printEditor(self, editor): |
|
5234 """ |
|
5235 Public slot to print an editor. |
|
5236 |
|
5237 @param editor editor to be printed |
|
5238 """ |
|
5239 if editor: |
|
5240 editor.printFile() |
|
5241 else: |
|
5242 return |
|
5243 |
|
5244 def printCurrentEditor(self): |
|
5245 """ |
|
5246 Public slot to print the contents of the current editor. |
|
5247 """ |
|
5248 aw = self.activeWindow() |
|
5249 self.printEditor(aw) |
|
5250 |
|
5251 def printPreviewCurrentEditor(self): |
|
5252 """ |
|
5253 Public slot to show a print preview of the current editor. |
|
5254 """ |
|
5255 aw = self.activeWindow() |
|
5256 if aw: |
|
5257 aw.printPreviewFile() |
|
5258 |
|
5259 def __showFileMenu(self): |
|
5260 """ |
|
5261 Private method to set up the file menu. |
|
5262 """ |
|
5263 self.menuRecentAct.setEnabled(len(self.recent) > 0) |
|
5264 |
|
5265 def __showRecentMenu(self): |
|
5266 """ |
|
5267 Private method to set up recent files menu. |
|
5268 """ |
|
5269 self.__loadRecent() |
|
5270 |
|
5271 self.recentMenu.clear() |
|
5272 |
|
5273 idx = 1 |
|
5274 for rs in self.recent: |
|
5275 if idx < 10: |
|
5276 formatStr = '&{0:d}. {1}' |
|
5277 else: |
|
5278 formatStr = '{0:d}. {1}' |
|
5279 act = self.recentMenu.addAction( |
|
5280 formatStr.format( |
|
5281 idx, |
|
5282 Utilities.compactPath(rs, self.ui.maxMenuFilePathLen))) |
|
5283 act.setData(rs) |
|
5284 act.setEnabled(QFileInfo(rs).exists()) |
|
5285 idx += 1 |
|
5286 |
|
5287 self.recentMenu.addSeparator() |
|
5288 self.recentMenu.addAction( |
|
5289 QCoreApplication.translate('ViewManager', '&Clear'), |
|
5290 self.clearRecent) |
|
5291 |
|
5292 def __openSourceFile(self, act): |
|
5293 """ |
|
5294 Private method to open a file from the list of recently opened files. |
|
5295 |
|
5296 @param act reference to the action that triggered (QAction) |
|
5297 """ |
|
5298 file = act.data() |
|
5299 if file: |
|
5300 self.openSourceFile(file) |
|
5301 |
|
5302 def clearRecent(self): |
|
5303 """ |
|
5304 Public method to clear the recent files menu. |
|
5305 """ |
|
5306 self.recent = [] |
|
5307 self.__saveRecent() |
|
5308 |
|
5309 def __showBookmarkedMenu(self): |
|
5310 """ |
|
5311 Private method to set up bookmarked files menu. |
|
5312 """ |
|
5313 self.bookmarkedMenu.clear() |
|
5314 |
|
5315 for rp in self.bookmarked: |
|
5316 act = self.bookmarkedMenu.addAction( |
|
5317 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)) |
|
5318 act.setData(rp) |
|
5319 act.setEnabled(QFileInfo(rp).exists()) |
|
5320 |
|
5321 if len(self.bookmarked): |
|
5322 self.bookmarkedMenu.addSeparator() |
|
5323 self.bookmarkedMenu.addAction( |
|
5324 QCoreApplication.translate('ViewManager', '&Add'), |
|
5325 self.__addBookmarked) |
|
5326 self.bookmarkedMenu.addAction( |
|
5327 QCoreApplication.translate('ViewManager', '&Edit...'), |
|
5328 self.__editBookmarked) |
|
5329 self.bookmarkedMenu.addAction( |
|
5330 QCoreApplication.translate('ViewManager', '&Clear'), |
|
5331 self.__clearBookmarked) |
|
5332 |
|
5333 def __addBookmarked(self): |
|
5334 """ |
|
5335 Private method to add the current file to the list of bookmarked files. |
|
5336 """ |
|
5337 an = self.getActiveName() |
|
5338 if an is not None and an not in self.bookmarked: |
|
5339 self.bookmarked.append(an) |
|
5340 |
|
5341 def __editBookmarked(self): |
|
5342 """ |
|
5343 Private method to edit the list of bookmarked files. |
|
5344 """ |
|
5345 from .BookmarkedFilesDialog import BookmarkedFilesDialog |
|
5346 dlg = BookmarkedFilesDialog(self.bookmarked, self.ui) |
|
5347 if dlg.exec_() == QDialog.Accepted: |
|
5348 self.bookmarked = dlg.getBookmarkedFiles() |
|
5349 |
|
5350 def __clearBookmarked(self): |
|
5351 """ |
|
5352 Private method to clear the bookmarked files menu. |
|
5353 """ |
|
5354 self.bookmarked = [] |
|
5355 |
|
5356 def projectOpened(self): |
|
5357 """ |
|
5358 Public slot to handle the projectOpened signal. |
|
5359 """ |
|
5360 for editor in self.editors: |
|
5361 editor.projectOpened() |
|
5362 |
|
5363 self.__editProjectPwlAct.setEnabled(True) |
|
5364 self.__editProjectPelAct.setEnabled(True) |
|
5365 |
|
5366 def projectClosed(self): |
|
5367 """ |
|
5368 Public slot to handle the projectClosed signal. |
|
5369 """ |
|
5370 for editor in self.editors: |
|
5371 editor.projectClosed() |
|
5372 |
|
5373 self.__editProjectPwlAct.setEnabled(False) |
|
5374 self.__editProjectPelAct.setEnabled(False) |
|
5375 |
|
5376 def projectFileRenamed(self, oldfn, newfn): |
|
5377 """ |
|
5378 Public slot to handle the projectFileRenamed signal. |
|
5379 |
|
5380 @param oldfn old filename of the file (string) |
|
5381 @param newfn new filename of the file (string) |
|
5382 """ |
|
5383 editor = self.getOpenEditor(oldfn) |
|
5384 if editor: |
|
5385 editor.fileRenamed(newfn) |
|
5386 |
|
5387 def projectLexerAssociationsChanged(self): |
|
5388 """ |
|
5389 Public slot to handle changes of the project lexer associations. |
|
5390 """ |
|
5391 for editor in self.editors: |
|
5392 editor.projectLexerAssociationsChanged() |
|
5393 |
|
5394 def enableEditorsCheckFocusIn(self, enabled): |
|
5395 """ |
|
5396 Public method to set a flag enabling the editors to perform focus in |
|
5397 checks. |
|
5398 |
|
5399 @param enabled flag indicating focus in checks should be performed |
|
5400 (boolean) |
|
5401 """ |
|
5402 self.editorsCheckFocusIn = enabled |
|
5403 |
|
5404 def editorsCheckFocusInEnabled(self): |
|
5405 """ |
|
5406 Public method returning the flag indicating editors should perform |
|
5407 focus in checks. |
|
5408 |
|
5409 @return flag indicating focus in checks should be performed (boolean) |
|
5410 """ |
|
5411 return self.editorsCheckFocusIn |
|
5412 |
|
5413 def __findFileName(self): |
|
5414 """ |
|
5415 Private method to handle the search for file action. |
|
5416 """ |
|
5417 self.ui.showFindFileByNameDialog() |
|
5418 |
|
5419 def appFocusChanged(self, old, now): |
|
5420 """ |
|
5421 Public method to handle the global change of focus. |
|
5422 |
|
5423 @param old reference to the widget loosing focus (QWidget) |
|
5424 @param now reference to the widget gaining focus (QWidget) |
|
5425 """ |
|
5426 from QScintilla.Shell import Shell |
|
5427 |
|
5428 if not isinstance(now, (Editor, Shell)): |
|
5429 self.editActGrp.setEnabled(False) |
|
5430 self.copyActGrp.setEnabled(False) |
|
5431 self.viewActGrp.setEnabled(False) |
|
5432 self.sbZoom.setEnabled(False) |
|
5433 else: |
|
5434 self.sbZoom.setEnabled(True) |
|
5435 self.sbZoom.setValue(now.getZoom()) |
|
5436 |
|
5437 if not isinstance(now, (Editor, Shell)) and \ |
|
5438 now is not self.quickFindtextCombo: |
|
5439 self.searchActGrp.setEnabled(False) |
|
5440 |
|
5441 if now is self.quickFindtextCombo: |
|
5442 self.searchActGrp.setEnabled(True) |
|
5443 |
|
5444 if not isinstance(now, (Editor, Shell)): |
|
5445 self.__lastFocusWidget = old |
|
5446 |
|
5447 ################################################################## |
|
5448 ## Below are the action methods for the edit menu |
|
5449 ################################################################## |
|
5450 |
|
5451 def __editUndo(self): |
|
5452 """ |
|
5453 Private method to handle the undo action. |
|
5454 """ |
|
5455 self.activeWindow().undo() |
|
5456 |
|
5457 def __editRedo(self): |
|
5458 """ |
|
5459 Private method to handle the redo action. |
|
5460 """ |
|
5461 self.activeWindow().redo() |
|
5462 |
|
5463 def __editRevert(self): |
|
5464 """ |
|
5465 Private method to handle the revert action. |
|
5466 """ |
|
5467 self.activeWindow().revertToUnmodified() |
|
5468 |
|
5469 def __editCut(self): |
|
5470 """ |
|
5471 Private method to handle the cut action. |
|
5472 """ |
|
5473 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
5474 e5App().getObject("Shell").cut() |
|
5475 else: |
|
5476 self.activeWindow().cut() |
|
5477 |
|
5478 def __editCopy(self): |
|
5479 """ |
|
5480 Private method to handle the copy action. |
|
5481 """ |
|
5482 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
5483 e5App().getObject("Shell").copy() |
|
5484 else: |
|
5485 self.activeWindow().copy() |
|
5486 |
|
5487 def __editPaste(self): |
|
5488 """ |
|
5489 Private method to handle the paste action. |
|
5490 """ |
|
5491 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
5492 e5App().getObject("Shell").paste() |
|
5493 else: |
|
5494 self.activeWindow().paste() |
|
5495 |
|
5496 def __editDelete(self): |
|
5497 """ |
|
5498 Private method to handle the delete action. |
|
5499 """ |
|
5500 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
5501 e5App().getObject("Shell").clear() |
|
5502 else: |
|
5503 self.activeWindow().clear() |
|
5504 |
|
5505 def __editJoin(self): |
|
5506 """ |
|
5507 Private method to handle the join action. |
|
5508 """ |
|
5509 self.activeWindow().joinLines() |
|
5510 |
|
5511 def __editIndent(self): |
|
5512 """ |
|
5513 Private method to handle the indent action. |
|
5514 """ |
|
5515 self.activeWindow().indentLineOrSelection() |
|
5516 |
|
5517 def __editUnindent(self): |
|
5518 """ |
|
5519 Private method to handle the unindent action. |
|
5520 """ |
|
5521 self.activeWindow().unindentLineOrSelection() |
|
5522 |
|
5523 def __editSmartIndent(self): |
|
5524 """ |
|
5525 Private method to handle the smart indent action. |
|
5526 """ |
|
5527 self.activeWindow().smartIndentLineOrSelection() |
|
5528 |
|
5529 def __editToggleComment(self): |
|
5530 """ |
|
5531 Private method to handle the toggle comment action. |
|
5532 """ |
|
5533 self.activeWindow().toggleCommentBlock() |
|
5534 |
|
5535 def __editComment(self): |
|
5536 """ |
|
5537 Private method to handle the comment action. |
|
5538 """ |
|
5539 self.activeWindow().commentLineOrSelection() |
|
5540 |
|
5541 def __editUncomment(self): |
|
5542 """ |
|
5543 Private method to handle the uncomment action. |
|
5544 """ |
|
5545 self.activeWindow().uncommentLineOrSelection() |
|
5546 |
|
5547 def __editStreamComment(self): |
|
5548 """ |
|
5549 Private method to handle the stream comment action. |
|
5550 """ |
|
5551 self.activeWindow().streamCommentLineOrSelection() |
|
5552 |
|
5553 def __editBoxComment(self): |
|
5554 """ |
|
5555 Private method to handle the box comment action. |
|
5556 """ |
|
5557 self.activeWindow().boxCommentLineOrSelection() |
|
5558 |
|
5559 def __editSelectBrace(self): |
|
5560 """ |
|
5561 Private method to handle the select to brace action. |
|
5562 """ |
|
5563 self.activeWindow().selectToMatchingBrace() |
|
5564 |
|
5565 def __editSelectAll(self): |
|
5566 """ |
|
5567 Private method to handle the select all action. |
|
5568 """ |
|
5569 self.activeWindow().selectAll(True) |
|
5570 |
|
5571 def __editDeselectAll(self): |
|
5572 """ |
|
5573 Private method to handle the select all action. |
|
5574 """ |
|
5575 self.activeWindow().selectAll(False) |
|
5576 |
|
5577 def __convertEOL(self): |
|
5578 """ |
|
5579 Private method to handle the convert line end characters action. |
|
5580 """ |
|
5581 aw = self.activeWindow() |
|
5582 aw.convertEols(aw.eolMode()) |
|
5583 |
|
5584 def __shortenEmptyLines(self): |
|
5585 """ |
|
5586 Private method to handle the shorten empty lines action. |
|
5587 """ |
|
5588 self.activeWindow().shortenEmptyLines() |
|
5589 |
|
5590 def __editAutoComplete(self): |
|
5591 """ |
|
5592 Private method to handle the autocomplete action. |
|
5593 """ |
|
5594 self.activeWindow().autoComplete() |
|
5595 |
|
5596 def __editAutoCompleteFromDoc(self): |
|
5597 """ |
|
5598 Private method to handle the autocomplete from document action. |
|
5599 """ |
|
5600 self.activeWindow().autoCompleteFromDocument() |
|
5601 |
|
5602 def __editAutoCompleteFromAPIs(self): |
|
5603 """ |
|
5604 Private method to handle the autocomplete from APIs action. |
|
5605 """ |
|
5606 self.activeWindow().autoCompleteFromAPIs() |
|
5607 |
|
5608 def __editAutoCompleteFromAll(self): |
|
5609 """ |
|
5610 Private method to handle the autocomplete from All action. |
|
5611 """ |
|
5612 self.activeWindow().autoCompleteFromAll() |
|
5613 |
|
5614 def __editorAutoCompletionAPIsAvailable(self, available, editor): |
|
5615 """ |
|
5616 Private method to handle the availability of API autocompletion signal. |
|
5617 |
|
5618 @param available flag indicating the availability of API |
|
5619 autocompletion |
|
5620 @type bool |
|
5621 @param editor reference to the editor |
|
5622 @type Editor |
|
5623 """ |
|
5624 self.autoCompleteAct.setEnabled( |
|
5625 editor.canProvideDynamicAutoCompletion()) |
|
5626 self.autoCompleteFromAPIsAct.setEnabled(available) |
|
5627 self.autoCompleteFromAllAct.setEnabled(available) |
|
5628 self.calltipsAct.setEnabled(editor.canProvideCallTipps()) |
|
5629 |
|
5630 def __editShowCallTips(self): |
|
5631 """ |
|
5632 Private method to handle the calltips action. |
|
5633 """ |
|
5634 self.activeWindow().callTip() |
|
5635 |
|
5636 def __editShowCodeInfo(self): |
|
5637 """ |
|
5638 Private method to handle the code info action. |
|
5639 """ |
|
5640 self.showEditorInfo(self.activeWindow()) |
|
5641 |
|
5642 ################################################################## |
|
5643 ## Below are the action and utility methods for the search menu |
|
5644 ################################################################## |
|
5645 |
|
5646 def textForFind(self, getCurrentWord=True): |
|
5647 """ |
|
5648 Public method to determine the selection or the current word for the |
|
5649 next find operation. |
|
5650 |
|
5651 @param getCurrentWord flag indicating to return the current word, if |
|
5652 no selected text was found (boolean) |
|
5653 @return selection or current word (string) |
|
5654 """ |
|
5655 aw = self.activeWindow() |
|
5656 if aw is None: |
|
5657 return "" |
|
5658 |
|
5659 return aw.getSearchText(not getCurrentWord) |
|
5660 |
|
5661 def getSRHistory(self, key): |
|
5662 """ |
|
5663 Public method to get the search or replace history list. |
|
5664 |
|
5665 @param key list to return (must be 'search' or 'replace') |
|
5666 @return the requested history list (list of strings) |
|
5667 """ |
|
5668 return self.srHistory[key] |
|
5669 |
|
5670 def __quickSearch(self): |
|
5671 """ |
|
5672 Private slot to handle the incremental quick search. |
|
5673 """ |
|
5674 # first we have to check if quick search is active |
|
5675 # and try to activate it if not |
|
5676 if self.__quickSearchToolbarVisibility is None: |
|
5677 self.__quickSearchToolbarVisibility = \ |
|
5678 self.__quickSearchToolbar.isVisible() |
|
5679 if not self.__quickSearchToolbar.isVisible(): |
|
5680 self.__quickSearchToolbar.show() |
|
5681 if not self.quickFindtextCombo.lineEdit().hasFocus(): |
|
5682 aw = self.activeWindow() |
|
5683 self.quickFindtextCombo.lastActive = aw |
|
5684 if aw: |
|
5685 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition() |
|
5686 else: |
|
5687 self.quickFindtextCombo.lastCursorPos = None |
|
5688 tff = self.textForFind(False) |
|
5689 if tff: |
|
5690 self.quickFindtextCombo.lineEdit().setText(tff) |
|
5691 self.quickFindtextCombo.lineEdit().setFocus() |
|
5692 self.quickFindtextCombo.lineEdit().selectAll() |
|
5693 self.__quickSearchSetEditColors(False) |
|
5694 else: |
|
5695 self.__quickSearchInEditor(True, False) |
|
5696 |
|
5697 def __quickSearchFocusIn(self): |
|
5698 """ |
|
5699 Private method to handle a focus in signal of the quicksearch lineedit. |
|
5700 """ |
|
5701 self.quickFindtextCombo.lastActive = self.activeWindow() |
|
5702 |
|
5703 def __quickSearchEnter(self): |
|
5704 """ |
|
5705 Private slot to handle the incremental quick search return pressed |
|
5706 (jump back to text). |
|
5707 """ |
|
5708 if self.quickFindtextCombo.lastActive: |
|
5709 self.quickFindtextCombo.lastActive.setFocus() |
|
5710 if self.__quickSearchToolbarVisibility is not None: |
|
5711 self.__quickSearchToolbar.setVisible( |
|
5712 self.__quickSearchToolbarVisibility) |
|
5713 self.__quickSearchToolbarVisibility = None |
|
5714 |
|
5715 def __quickSearchEscape(self): |
|
5716 """ |
|
5717 Private slot to handle the incremental quick search escape pressed |
|
5718 (jump back to text). |
|
5719 """ |
|
5720 if self.quickFindtextCombo.lastActive: |
|
5721 self.quickFindtextCombo.lastActive.setFocus() |
|
5722 aw = self.activeWindow() |
|
5723 if aw: |
|
5724 aw.hideFindIndicator() |
|
5725 if self.quickFindtextCombo.lastCursorPos: |
|
5726 aw.setCursorPosition( |
|
5727 self.quickFindtextCombo.lastCursorPos[0], |
|
5728 self.quickFindtextCombo.lastCursorPos[1]) |
|
5729 |
|
5730 if self.__quickSearchToolbarVisibility is not None: |
|
5731 self.__quickSearchToolbar.setVisible( |
|
5732 self.__quickSearchToolbarVisibility) |
|
5733 self.__quickSearchToolbarVisibility = None |
|
5734 |
|
5735 def __quickSearchText(self): |
|
5736 """ |
|
5737 Private slot to handle the textChanged signal of the quicksearch edit. |
|
5738 """ |
|
5739 self.__quickSearchInEditor(False, False) |
|
5740 |
|
5741 def __quickSearchPrev(self): |
|
5742 """ |
|
5743 Private slot to handle the quickFindPrev toolbutton action. |
|
5744 """ |
|
5745 # first we have to check if quick search is active |
|
5746 # and try to activate it if not |
|
5747 if self.__quickSearchToolbarVisibility is None: |
|
5748 self.__quickSearchToolbarVisibility = \ |
|
5749 self.__quickSearchToolbar.isVisible() |
|
5750 if not self.__quickSearchToolbar.isVisible(): |
|
5751 self.__quickSearchToolbar.show() |
|
5752 if not self.quickFindtextCombo.lineEdit().hasFocus(): |
|
5753 aw = self.activeWindow() |
|
5754 self.quickFindtextCombo.lastActive = aw |
|
5755 if aw: |
|
5756 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition() |
|
5757 else: |
|
5758 self.quickFindtextCombo.lastCursorPos = None |
|
5759 tff = self.textForFind(False) |
|
5760 if tff: |
|
5761 self.quickFindtextCombo.lineEdit().setText(tff) |
|
5762 self.quickFindtextCombo.lineEdit().setFocus() |
|
5763 self.quickFindtextCombo.lineEdit().selectAll() |
|
5764 self.__quickSearchSetEditColors(False) |
|
5765 else: |
|
5766 self.__quickSearchInEditor(True, True) |
|
5767 |
|
5768 def __quickSearchMarkOccurrences(self, txt): |
|
5769 """ |
|
5770 Private method to mark all occurrences of the search text. |
|
5771 |
|
5772 @param txt text to search for (string) |
|
5773 """ |
|
5774 aw = self.activeWindow() |
|
5775 |
|
5776 lineFrom = 0 |
|
5777 indexFrom = 0 |
|
5778 lineTo = -1 |
|
5779 indexTo = -1 |
|
5780 |
|
5781 aw.clearSearchIndicators() |
|
5782 ok = aw.findFirstTarget(txt, False, False, False, |
|
5783 lineFrom, indexFrom, lineTo, indexTo) |
|
5784 while ok: |
|
5785 tgtPos, tgtLen = aw.getFoundTarget() |
|
5786 aw.setSearchIndicator(tgtPos, tgtLen) |
|
5787 ok = aw.findNextTarget() |
|
5788 |
|
5789 def __quickSearchInEditor(self, again, back): |
|
5790 """ |
|
5791 Private slot to perform a quick search. |
|
5792 |
|
5793 @param again flag indicating a repeat of the last search (boolean) |
|
5794 @param back flag indicating a backwards search operation (boolean) |
|
5795 """ |
|
5796 aw = self.activeWindow() |
|
5797 if not aw: |
|
5798 return |
|
5799 |
|
5800 aw.hideFindIndicator() |
|
5801 |
|
5802 text = self.quickFindtextCombo.lineEdit().text() |
|
5803 if not text and again: |
|
5804 text = self.quickFindtextCombo.lastSearchText |
|
5805 if not text: |
|
5806 if Preferences.getEditor("QuickSearchMarkersEnabled"): |
|
5807 aw.clearSearchIndicators() |
|
5808 return |
|
5809 else: |
|
5810 self.quickFindtextCombo.lastSearchText = text |
|
5811 |
|
5812 if Preferences.getEditor("QuickSearchMarkersEnabled"): |
|
5813 self.__quickSearchMarkOccurrences(text) |
|
5814 |
|
5815 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection() |
|
5816 cline, cindex = aw.getCursorPosition() |
|
5817 if again: |
|
5818 if back: |
|
5819 if indexFrom != 0: |
|
5820 index = indexFrom - 1 |
|
5821 line = lineFrom |
|
5822 elif lineFrom == 0: |
|
5823 return |
|
5824 else: |
|
5825 line = lineFrom - 1 |
|
5826 index = aw.lineLength(line) |
|
5827 ok = aw.findFirst(text, False, False, False, True, False, |
|
5828 line, index) |
|
5829 else: |
|
5830 ok = aw.findFirst(text, False, False, False, True, not back, |
|
5831 cline, cindex) |
|
5832 else: |
|
5833 ok = aw.findFirst(text, False, False, False, True, not back, |
|
5834 lineFrom, indexFrom) |
|
5835 if ok: |
|
5836 sline, sindex, eline, eindex = aw.getSelection() |
|
5837 aw.showFindIndicator(sline, sindex, eline, eindex) |
|
5838 self.__quickSearchSetEditColors(not ok) |
|
5839 |
|
5840 def __quickSearchSetEditColors(self, error): |
|
5841 """ |
|
5842 Private method to set the quick search edit colors. |
|
5843 |
|
5844 @param error flag indicating an error (boolean) |
|
5845 """ |
|
5846 if error: |
|
5847 palette = self.quickFindtextCombo.lineEdit().palette() |
|
5848 palette.setColor(QPalette.Base, QColor("red")) |
|
5849 palette.setColor(QPalette.Text, QColor("white")) |
|
5850 self.quickFindtextCombo.lineEdit().setPalette(palette) |
|
5851 else: |
|
5852 palette = self.quickFindtextCombo.lineEdit().palette() |
|
5853 palette.setColor( |
|
5854 QPalette.Base, |
|
5855 self.quickFindtextCombo.palette().color(QPalette.Base)) |
|
5856 palette.setColor( |
|
5857 QPalette.Text, |
|
5858 self.quickFindtextCombo.palette().color(QPalette.Text)) |
|
5859 self.quickFindtextCombo.lineEdit().setPalette(palette) |
|
5860 |
|
5861 def __quickSearchExtend(self): |
|
5862 """ |
|
5863 Private method to handle the quicksearch extend action. |
|
5864 """ |
|
5865 aw = self.activeWindow() |
|
5866 if aw is None: |
|
5867 return |
|
5868 |
|
5869 txt = self.quickFindtextCombo.lineEdit().text() |
|
5870 if not txt: |
|
5871 return |
|
5872 |
|
5873 line, index = aw.getCursorPosition() |
|
5874 text = aw.text(line) |
|
5875 |
|
5876 reg = QRegExp(r'[^\w_]') |
|
5877 end = reg.indexIn(text, index) |
|
5878 if end > index: |
|
5879 ext = text[index:end] |
|
5880 txt += ext |
|
5881 self.quickFindtextCombo.lineEdit().setText(txt) |
|
5882 |
|
5883 def showSearchWidget(self): |
|
5884 """ |
|
5885 Public method to show the search widget. |
|
5886 """ |
|
5887 self.__replaceWidget.hide() |
|
5888 self.__searchWidget.show() |
|
5889 self.__searchWidget.show(self.textForFind()) |
|
5890 |
|
5891 def __searchNext(self): |
|
5892 """ |
|
5893 Private slot to handle the search next action. |
|
5894 """ |
|
5895 if self.__replaceWidget.isVisible(): |
|
5896 self.__replaceWidget.findNext() |
|
5897 else: |
|
5898 self.__searchWidget.findNext() |
|
5899 |
|
5900 def __searchPrev(self): |
|
5901 """ |
|
5902 Private slot to handle the search previous action. |
|
5903 """ |
|
5904 if self.__replaceWidget.isVisible(): |
|
5905 self.__replaceWidget.findPrev() |
|
5906 else: |
|
5907 self.__searchWidget.findPrev() |
|
5908 |
|
5909 def showReplaceWidget(self): |
|
5910 """ |
|
5911 Public method to show the replace widget. |
|
5912 """ |
|
5913 self.__searchWidget.hide() |
|
5914 self.__replaceWidget.show(self.textForFind()) |
|
5915 |
|
5916 def __findNextWord(self): |
|
5917 """ |
|
5918 Private slot to find the next occurrence of the current word of the |
|
5919 current editor. |
|
5920 """ |
|
5921 self.activeWindow().searchCurrentWordForward() |
|
5922 |
|
5923 def __findPrevWord(self): |
|
5924 """ |
|
5925 Private slot to find the previous occurrence of the current word of |
|
5926 the current editor. |
|
5927 """ |
|
5928 self.activeWindow().searchCurrentWordBackward() |
|
5929 |
|
5930 def __searchClearMarkers(self): |
|
5931 """ |
|
5932 Private method to clear the search markers of the active window. |
|
5933 """ |
|
5934 self.activeWindow().clearSearchIndicators() |
|
5935 |
|
5936 def __goto(self): |
|
5937 """ |
|
5938 Private method to handle the goto action. |
|
5939 """ |
|
5940 from QScintilla.GotoDialog import GotoDialog |
|
5941 |
|
5942 aw = self.activeWindow() |
|
5943 lines = aw.lines() |
|
5944 curLine = aw.getCursorPosition()[0] + 1 |
|
5945 dlg = GotoDialog(lines, curLine, self.ui, None, True) |
|
5946 if dlg.exec_() == QDialog.Accepted: |
|
5947 aw.gotoLine(dlg.getLinenumber(), expand=True) |
|
5948 |
|
5949 def __gotoBrace(self): |
|
5950 """ |
|
5951 Private method to handle the goto brace action. |
|
5952 """ |
|
5953 self.activeWindow().moveToMatchingBrace() |
|
5954 |
|
5955 def __gotoLastEditPosition(self): |
|
5956 """ |
|
5957 Private method to move the cursor to the last edit position. |
|
5958 """ |
|
5959 self.activeWindow().gotoLastEditPosition() |
|
5960 |
|
5961 def __lastEditPositionAvailable(self): |
|
5962 """ |
|
5963 Private slot to handle the lastEditPositionAvailable signal of an |
|
5964 editor. |
|
5965 """ |
|
5966 self.gotoLastEditAct.setEnabled(True) |
|
5967 |
|
5968 def __gotoNextMethodClass(self): |
|
5969 """ |
|
5970 Private slot to go to the next Python/Ruby method or class definition. |
|
5971 """ |
|
5972 self.activeWindow().gotoMethodClass(False) |
|
5973 |
|
5974 def __gotoPreviousMethodClass(self): |
|
5975 """ |
|
5976 Private slot to go to the previous Python/Ruby method or class |
|
5977 definition. |
|
5978 """ |
|
5979 self.activeWindow().gotoMethodClass(True) |
|
5980 |
|
5981 def __searchFiles(self): |
|
5982 """ |
|
5983 Private method to handle the search in files action. |
|
5984 """ |
|
5985 self.ui.showFindFilesDialog(self.textForFind()) |
|
5986 |
|
5987 def __replaceFiles(self): |
|
5988 """ |
|
5989 Private method to handle the replace in files action. |
|
5990 """ |
|
5991 self.ui.showReplaceFilesDialog(self.textForFind()) |
|
5992 |
|
5993 def __searchOpenFiles(self): |
|
5994 """ |
|
5995 Private method to handle the search in open files action. |
|
5996 """ |
|
5997 self.ui.showFindFilesDialog(self.textForFind(), openFiles=True) |
|
5998 |
|
5999 def __replaceOpenFiles(self): |
|
6000 """ |
|
6001 Private method to handle the replace in open files action. |
|
6002 """ |
|
6003 self.ui.showReplaceFilesDialog(self.textForFind(), openFiles=True) |
|
6004 |
|
6005 ################################################################## |
|
6006 ## Below are the action methods for the view menu |
|
6007 ################################################################## |
|
6008 |
|
6009 def __zoomIn(self): |
|
6010 """ |
|
6011 Private method to handle the zoom in action. |
|
6012 """ |
|
6013 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
6014 e5App().getObject("Shell").zoomIn() |
|
6015 else: |
|
6016 aw = self.activeWindow() |
|
6017 if aw: |
|
6018 aw.zoomIn() |
|
6019 self.sbZoom.setValue(aw.getZoom()) |
|
6020 |
|
6021 def __zoomOut(self): |
|
6022 """ |
|
6023 Private method to handle the zoom out action. |
|
6024 """ |
|
6025 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
6026 e5App().getObject("Shell").zoomOut() |
|
6027 else: |
|
6028 aw = self.activeWindow() |
|
6029 if aw: |
|
6030 aw.zoomOut() |
|
6031 self.sbZoom.setValue(aw.getZoom()) |
|
6032 |
|
6033 def __zoomReset(self): |
|
6034 """ |
|
6035 Private method to reset the zoom factor. |
|
6036 """ |
|
6037 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
6038 e5App().getObject("Shell").zoomTo(0) |
|
6039 else: |
|
6040 aw = self.activeWindow() |
|
6041 if aw: |
|
6042 aw.zoomTo(0) |
|
6043 self.sbZoom.setValue(aw.getZoom()) |
|
6044 |
|
6045 def __zoom(self): |
|
6046 """ |
|
6047 Private method to handle the zoom action. |
|
6048 """ |
|
6049 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
6050 aw = e5App().getObject("Shell") |
|
6051 else: |
|
6052 aw = self.activeWindow() |
|
6053 if aw: |
|
6054 from QScintilla.ZoomDialog import ZoomDialog |
|
6055 dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) |
|
6056 if dlg.exec_() == QDialog.Accepted: |
|
6057 value = dlg.getZoomSize() |
|
6058 self.__zoomTo(value) |
|
6059 |
|
6060 def __zoomTo(self, value): |
|
6061 """ |
|
6062 Private slot to zoom to a given value. |
|
6063 |
|
6064 @param value zoom value to be set (integer) |
|
6065 """ |
|
6066 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
6067 aw = e5App().getObject("Shell") |
|
6068 else: |
|
6069 aw = self.activeWindow() |
|
6070 if aw: |
|
6071 aw.zoomTo(value) |
|
6072 self.sbZoom.setValue(aw.getZoom()) |
|
6073 |
|
6074 def zoomValueChanged(self, value, zoomingWidget): |
|
6075 """ |
|
6076 Public slot to handle changes of the zoom value. |
|
6077 |
|
6078 @param value new zoom value |
|
6079 @type int |
|
6080 @param zoomingWidget reference to the widget triggering the slot |
|
6081 @type Editor or Shell |
|
6082 """ |
|
6083 if QApplication.focusWidget() == e5App().getObject("Shell"): |
|
6084 aw = e5App().getObject("Shell") |
|
6085 else: |
|
6086 aw = self.activeWindow() |
|
6087 if aw and aw == zoomingWidget: |
|
6088 self.sbZoom.setValue(value) |
|
6089 |
|
6090 def __clearAllFolds(self): |
|
6091 """ |
|
6092 Private method to handle the clear all folds action. |
|
6093 """ |
|
6094 aw = self.activeWindow() |
|
6095 if aw: |
|
6096 aw.clearFolds() |
|
6097 |
|
6098 def __toggleAll(self): |
|
6099 """ |
|
6100 Private method to handle the toggle all folds action. |
|
6101 """ |
|
6102 aw = self.activeWindow() |
|
6103 if aw: |
|
6104 aw.foldAll() |
|
6105 |
|
6106 def __toggleAllChildren(self): |
|
6107 """ |
|
6108 Private method to handle the toggle all folds (including children) |
|
6109 action. |
|
6110 """ |
|
6111 aw = self.activeWindow() |
|
6112 if aw: |
|
6113 aw.foldAll(True) |
|
6114 |
|
6115 def __toggleCurrent(self): |
|
6116 """ |
|
6117 Private method to handle the toggle current fold action. |
|
6118 """ |
|
6119 aw = self.activeWindow() |
|
6120 if aw: |
|
6121 aw.toggleCurrentFold() |
|
6122 |
|
6123 def __newDocumentView(self): |
|
6124 """ |
|
6125 Private method to open a new view of the current editor. |
|
6126 """ |
|
6127 aw = self.activeWindow() |
|
6128 if aw: |
|
6129 self.newEditorView(aw.getFileName(), aw, aw.getFileType()) |
|
6130 |
|
6131 def __newDocumentSplitView(self): |
|
6132 """ |
|
6133 Private method to open a new view of the current editor in a new split. |
|
6134 """ |
|
6135 aw = self.activeWindow() |
|
6136 if aw: |
|
6137 self.addSplit() |
|
6138 self.newEditorView(aw.getFileName(), aw, aw.getFileType()) |
|
6139 |
|
6140 def __splitView(self): |
|
6141 """ |
|
6142 Private method to handle the split view action. |
|
6143 """ |
|
6144 self.addSplit() |
|
6145 |
|
6146 def __splitOrientation(self, checked): |
|
6147 """ |
|
6148 Private method to handle the split orientation action. |
|
6149 |
|
6150 @param checked flag indicating the checked state of the action |
|
6151 (boolean). True means splitting horizontally. |
|
6152 """ |
|
6153 if checked: |
|
6154 self.setSplitOrientation(Qt.Horizontal) |
|
6155 self.splitViewAct.setIcon( |
|
6156 UI.PixmapCache.getIcon("splitHorizontal.png")) |
|
6157 self.splitRemoveAct.setIcon( |
|
6158 UI.PixmapCache.getIcon("remsplitHorizontal.png")) |
|
6159 self.newDocumentSplitViewAct.setIcon( |
|
6160 UI.PixmapCache.getIcon("splitHorizontal.png")) |
|
6161 else: |
|
6162 self.setSplitOrientation(Qt.Vertical) |
|
6163 self.splitViewAct.setIcon( |
|
6164 UI.PixmapCache.getIcon("splitVertical.png")) |
|
6165 self.splitRemoveAct.setIcon( |
|
6166 UI.PixmapCache.getIcon("remsplitVertical.png")) |
|
6167 self.newDocumentSplitViewAct.setIcon( |
|
6168 UI.PixmapCache.getIcon("splitVertical.png")) |
|
6169 Preferences.setUI("SplitOrientationVertical", checked) |
|
6170 |
|
6171 def __previewEditor(self, checked): |
|
6172 """ |
|
6173 Private slot to handle a change of the preview selection state. |
|
6174 |
|
6175 @param checked state of the action (boolean) |
|
6176 """ |
|
6177 Preferences.setUI("ShowFilePreview", checked) |
|
6178 self.previewStateChanged.emit(checked) |
|
6179 |
|
6180 def __astViewer(self, checked): |
|
6181 """ |
|
6182 Private slot to handle a change of the AST Viewer selection state. |
|
6183 |
|
6184 @param checked state of the action (boolean) |
|
6185 """ |
|
6186 self.astViewerStateChanged.emit(checked) |
|
6187 |
|
6188 ################################################################## |
|
6189 ## Below are the action methods for the macro menu |
|
6190 ################################################################## |
|
6191 |
|
6192 def __macroStartRecording(self): |
|
6193 """ |
|
6194 Private method to handle the start macro recording action. |
|
6195 """ |
|
6196 self.activeWindow().macroRecordingStart() |
|
6197 |
|
6198 def __macroStopRecording(self): |
|
6199 """ |
|
6200 Private method to handle the stop macro recording action. |
|
6201 """ |
|
6202 self.activeWindow().macroRecordingStop() |
|
6203 |
|
6204 def __macroRun(self): |
|
6205 """ |
|
6206 Private method to handle the run macro action. |
|
6207 """ |
|
6208 self.activeWindow().macroRun() |
|
6209 |
|
6210 def __macroDelete(self): |
|
6211 """ |
|
6212 Private method to handle the delete macro action. |
|
6213 """ |
|
6214 self.activeWindow().macroDelete() |
|
6215 |
|
6216 def __macroLoad(self): |
|
6217 """ |
|
6218 Private method to handle the load macro action. |
|
6219 """ |
|
6220 self.activeWindow().macroLoad() |
|
6221 |
|
6222 def __macroSave(self): |
|
6223 """ |
|
6224 Private method to handle the save macro action. |
|
6225 """ |
|
6226 self.activeWindow().macroSave() |
|
6227 |
|
6228 ################################################################## |
|
6229 ## Below are the action methods for the bookmarks menu |
|
6230 ################################################################## |
|
6231 |
|
6232 def __toggleBookmark(self): |
|
6233 """ |
|
6234 Private method to handle the toggle bookmark action. |
|
6235 """ |
|
6236 self.activeWindow().menuToggleBookmark() |
|
6237 |
|
6238 def __nextBookmark(self): |
|
6239 """ |
|
6240 Private method to handle the next bookmark action. |
|
6241 """ |
|
6242 self.activeWindow().nextBookmark() |
|
6243 |
|
6244 def __previousBookmark(self): |
|
6245 """ |
|
6246 Private method to handle the previous bookmark action. |
|
6247 """ |
|
6248 self.activeWindow().previousBookmark() |
|
6249 |
|
6250 def __clearAllBookmarks(self): |
|
6251 """ |
|
6252 Private method to handle the clear all bookmarks action. |
|
6253 """ |
|
6254 for editor in self.editors: |
|
6255 editor.clearBookmarks() |
|
6256 |
|
6257 self.bookmarkNextAct.setEnabled(False) |
|
6258 self.bookmarkPreviousAct.setEnabled(False) |
|
6259 self.bookmarkClearAct.setEnabled(False) |
|
6260 |
|
6261 def __showBookmarkMenu(self): |
|
6262 """ |
|
6263 Private method to set up the bookmark menu. |
|
6264 """ |
|
6265 bookmarksFound = 0 |
|
6266 filenames = self.getOpenFilenames() |
|
6267 for filename in filenames: |
|
6268 editor = self.getOpenEditor(filename) |
|
6269 bookmarksFound = len(editor.getBookmarks()) > 0 |
|
6270 if bookmarksFound: |
|
6271 self.menuBookmarksAct.setEnabled(True) |
|
6272 return |
|
6273 self.menuBookmarksAct.setEnabled(False) |
|
6274 |
|
6275 def __showBookmarksMenu(self): |
|
6276 """ |
|
6277 Private method to handle the show bookmarks menu signal. |
|
6278 """ |
|
6279 self.bookmarksMenu.clear() |
|
6280 |
|
6281 filenames = self.getOpenFilenames() |
|
6282 for filename in sorted(filenames): |
|
6283 editor = self.getOpenEditor(filename) |
|
6284 for bookmark in editor.getBookmarks(): |
|
6285 bmSuffix = " : {0:d}".format(bookmark) |
|
6286 act = self.bookmarksMenu.addAction( |
|
6287 "{0}{1}".format( |
|
6288 Utilities.compactPath( |
|
6289 filename, |
|
6290 self.ui.maxMenuFilePathLen - len(bmSuffix)), |
|
6291 bmSuffix)) |
|
6292 act.setData([filename, bookmark]) |
|
6293 |
|
6294 def __bookmarkSelected(self, act): |
|
6295 """ |
|
6296 Private method to handle the bookmark selected signal. |
|
6297 |
|
6298 @param act reference to the action that triggered (QAction) |
|
6299 """ |
|
6300 bmList = act.data() |
|
6301 filename = bmList[0] |
|
6302 line = bmList[1] |
|
6303 self.openSourceFile(filename, line) |
|
6304 |
|
6305 def __bookmarkToggled(self, editor): |
|
6306 """ |
|
6307 Private slot to handle the bookmarkToggled signal. |
|
6308 |
|
6309 It checks some bookmark actions and reemits the signal. |
|
6310 |
|
6311 @param editor editor that sent the signal |
|
6312 """ |
|
6313 if editor.hasBookmarks(): |
|
6314 self.bookmarkNextAct.setEnabled(True) |
|
6315 self.bookmarkPreviousAct.setEnabled(True) |
|
6316 self.bookmarkClearAct.setEnabled(True) |
|
6317 else: |
|
6318 self.bookmarkNextAct.setEnabled(False) |
|
6319 self.bookmarkPreviousAct.setEnabled(False) |
|
6320 self.bookmarkClearAct.setEnabled(False) |
|
6321 self.bookmarkToggled.emit(editor) |
|
6322 |
|
6323 def __gotoSyntaxError(self): |
|
6324 """ |
|
6325 Private method to handle the goto syntax error action. |
|
6326 """ |
|
6327 self.activeWindow().gotoSyntaxError() |
|
6328 |
|
6329 def __clearAllSyntaxErrors(self): |
|
6330 """ |
|
6331 Private method to handle the clear all syntax errors action. |
|
6332 """ |
|
6333 for editor in self.editors: |
|
6334 editor.clearSyntaxError() |
|
6335 |
|
6336 def _syntaxErrorToggled(self, editor): |
|
6337 """ |
|
6338 Protected slot to handle the syntaxerrorToggled signal. |
|
6339 |
|
6340 It checks some syntax error actions and reemits the signal. |
|
6341 |
|
6342 @param editor editor that sent the signal |
|
6343 """ |
|
6344 if editor.hasSyntaxErrors(): |
|
6345 self.syntaxErrorGotoAct.setEnabled(True) |
|
6346 self.syntaxErrorClearAct.setEnabled(True) |
|
6347 else: |
|
6348 self.syntaxErrorGotoAct.setEnabled(False) |
|
6349 self.syntaxErrorClearAct.setEnabled(False) |
|
6350 if editor.hasWarnings(): |
|
6351 self.warningsNextAct.setEnabled(True) |
|
6352 self.warningsPreviousAct.setEnabled(True) |
|
6353 self.warningsClearAct.setEnabled(True) |
|
6354 else: |
|
6355 self.warningsNextAct.setEnabled(False) |
|
6356 self.warningsPreviousAct.setEnabled(False) |
|
6357 self.warningsClearAct.setEnabled(False) |
|
6358 self.syntaxerrorToggled.emit(editor) |
|
6359 |
|
6360 def __nextWarning(self): |
|
6361 """ |
|
6362 Private method to handle the next warning action. |
|
6363 """ |
|
6364 self.activeWindow().nextWarning() |
|
6365 |
|
6366 def __previousWarning(self): |
|
6367 """ |
|
6368 Private method to handle the previous warning action. |
|
6369 """ |
|
6370 self.activeWindow().previousWarning() |
|
6371 |
|
6372 def __clearAllWarnings(self): |
|
6373 """ |
|
6374 Private method to handle the clear all warnings action. |
|
6375 """ |
|
6376 for editor in self.editors: |
|
6377 editor.clearWarnings() |
|
6378 |
|
6379 def __nextUncovered(self): |
|
6380 """ |
|
6381 Private method to handle the next uncovered action. |
|
6382 """ |
|
6383 self.activeWindow().nextUncovered() |
|
6384 |
|
6385 def __previousUncovered(self): |
|
6386 """ |
|
6387 Private method to handle the previous uncovered action. |
|
6388 """ |
|
6389 self.activeWindow().previousUncovered() |
|
6390 |
|
6391 def __coverageMarkersShown(self, shown): |
|
6392 """ |
|
6393 Private slot to handle the coverageMarkersShown signal. |
|
6394 |
|
6395 @param shown flag indicating whether the markers were shown or cleared |
|
6396 """ |
|
6397 if shown: |
|
6398 self.notcoveredNextAct.setEnabled(True) |
|
6399 self.notcoveredPreviousAct.setEnabled(True) |
|
6400 else: |
|
6401 self.notcoveredNextAct.setEnabled(False) |
|
6402 self.notcoveredPreviousAct.setEnabled(False) |
|
6403 |
|
6404 def __taskMarkersUpdated(self, editor): |
|
6405 """ |
|
6406 Private slot to handle the taskMarkersUpdated signal. |
|
6407 |
|
6408 @param editor editor that sent the signal |
|
6409 """ |
|
6410 if editor.hasTaskMarkers(): |
|
6411 self.taskNextAct.setEnabled(True) |
|
6412 self.taskPreviousAct.setEnabled(True) |
|
6413 else: |
|
6414 self.taskNextAct.setEnabled(False) |
|
6415 self.taskPreviousAct.setEnabled(False) |
|
6416 |
|
6417 def __nextTask(self): |
|
6418 """ |
|
6419 Private method to handle the next task action. |
|
6420 """ |
|
6421 self.activeWindow().nextTask() |
|
6422 |
|
6423 def __previousTask(self): |
|
6424 """ |
|
6425 Private method to handle the previous task action. |
|
6426 """ |
|
6427 self.activeWindow().previousTask() |
|
6428 |
|
6429 def __changeMarkersUpdated(self, editor): |
|
6430 """ |
|
6431 Private slot to handle the changeMarkersUpdated signal. |
|
6432 |
|
6433 @param editor editor that sent the signal |
|
6434 """ |
|
6435 if editor.hasChangeMarkers(): |
|
6436 self.changeNextAct.setEnabled(True) |
|
6437 self.changePreviousAct.setEnabled(True) |
|
6438 else: |
|
6439 self.changeNextAct.setEnabled(False) |
|
6440 self.changePreviousAct.setEnabled(False) |
|
6441 |
|
6442 def __nextChange(self): |
|
6443 """ |
|
6444 Private method to handle the next change action. |
|
6445 """ |
|
6446 self.activeWindow().nextChange() |
|
6447 |
|
6448 def __previousChange(self): |
|
6449 """ |
|
6450 Private method to handle the previous change action. |
|
6451 """ |
|
6452 self.activeWindow().previousChange() |
|
6453 |
|
6454 ################################################################## |
|
6455 ## Below are the action methods for the spell checking functions |
|
6456 ################################################################## |
|
6457 |
|
6458 def __showEditSpellingMenu(self): |
|
6459 """ |
|
6460 Private method to set up the edit dictionaries menu. |
|
6461 """ |
|
6462 proj = e5App().getObject("Project") |
|
6463 projetOpen = proj.isOpen() |
|
6464 pwl = e5App().getObject("Project").getProjectDictionaries()[0] |
|
6465 self.__editProjectPwlAct.setEnabled(projetOpen and bool(pwl)) |
|
6466 pel = e5App().getObject("Project").getProjectDictionaries()[1] |
|
6467 self.__editProjectPelAct.setEnabled(projetOpen and bool(pel)) |
|
6468 |
|
6469 from QScintilla.SpellChecker import SpellChecker |
|
6470 pwl = SpellChecker.getUserDictionaryPath() |
|
6471 self.__editUserPwlAct.setEnabled(bool(pwl)) |
|
6472 pel = SpellChecker.getUserDictionaryPath(True) |
|
6473 self.__editUserPelAct.setEnabled(bool(pel)) |
|
6474 |
|
6475 def __setAutoSpellChecking(self): |
|
6476 """ |
|
6477 Private slot to set the automatic spell checking of all editors. |
|
6478 """ |
|
6479 enabled = self.autoSpellCheckAct.isChecked() |
|
6480 Preferences.setEditor("AutoSpellCheckingEnabled", enabled) |
|
6481 for editor in self.editors: |
|
6482 editor.setAutoSpellChecking() |
|
6483 |
|
6484 def __spellCheck(self): |
|
6485 """ |
|
6486 Private slot to perform a spell check of the current editor. |
|
6487 """ |
|
6488 aw = self.activeWindow() |
|
6489 if aw: |
|
6490 aw.checkSpelling() |
|
6491 |
|
6492 def __editProjectPWL(self): |
|
6493 """ |
|
6494 Private slot to edit the project word list. |
|
6495 """ |
|
6496 pwl = e5App().getObject("Project").getProjectDictionaries()[0] |
|
6497 self.__editSpellingDictionary(pwl) |
|
6498 |
|
6499 def __editProjectPEL(self): |
|
6500 """ |
|
6501 Private slot to edit the project exception list. |
|
6502 """ |
|
6503 pel = e5App().getObject("Project").getProjectDictionaries()[1] |
|
6504 self.__editSpellingDictionary(pel) |
|
6505 |
|
6506 def __editUserPWL(self): |
|
6507 """ |
|
6508 Private slot to edit the user word list. |
|
6509 """ |
|
6510 from QScintilla.SpellChecker import SpellChecker |
|
6511 pwl = SpellChecker.getUserDictionaryPath() |
|
6512 self.__editSpellingDictionary(pwl) |
|
6513 |
|
6514 def __editUserPEL(self): |
|
6515 """ |
|
6516 Private slot to edit the user exception list. |
|
6517 """ |
|
6518 from QScintilla.SpellChecker import SpellChecker |
|
6519 pel = SpellChecker.getUserDictionaryPath(True) |
|
6520 self.__editSpellingDictionary(pel) |
|
6521 |
|
6522 def __editSpellingDictionary(self, dictionaryFile): |
|
6523 """ |
|
6524 Private slot to edit the given spelling dictionary. |
|
6525 |
|
6526 @param dictionaryFile file name of the dictionary to edit (string) |
|
6527 """ |
|
6528 if os.path.exists(dictionaryFile): |
|
6529 try: |
|
6530 f = open(dictionaryFile, "r", encoding="utf-8") |
|
6531 data = f.read() |
|
6532 f.close() |
|
6533 except (IOError, OSError) as err: |
|
6534 E5MessageBox.critical( |
|
6535 self.ui, |
|
6536 QCoreApplication.translate( |
|
6537 'ViewManager', "Edit Spelling Dictionary"), |
|
6538 QCoreApplication.translate( |
|
6539 'ViewManager', |
|
6540 """<p>The spelling dictionary file <b>{0}</b> could""" |
|
6541 """ not be read.</p><p>Reason: {1}</p>""").format( |
|
6542 dictionaryFile, str(err))) |
|
6543 return |
|
6544 |
|
6545 fileInfo = dictionaryFile if len(dictionaryFile) < 40 \ |
|
6546 else "...{0}".format(dictionaryFile[-40:]) |
|
6547 from QScintilla.SpellingDictionaryEditDialog import \ |
|
6548 SpellingDictionaryEditDialog |
|
6549 dlg = SpellingDictionaryEditDialog( |
|
6550 data, |
|
6551 QCoreApplication.translate('ViewManager', "Editing {0}") |
|
6552 .format(fileInfo), |
|
6553 self.ui) |
|
6554 if dlg.exec_() == QDialog.Accepted: |
|
6555 data = dlg.getData() |
|
6556 try: |
|
6557 f = open(dictionaryFile, "w", encoding="utf-8") |
|
6558 f.write(data) |
|
6559 f.close() |
|
6560 except (IOError, OSError) as err: |
|
6561 E5MessageBox.critical( |
|
6562 self.ui, |
|
6563 QCoreApplication.translate( |
|
6564 'ViewManager', "Edit Spelling Dictionary"), |
|
6565 QCoreApplication.translate( |
|
6566 'ViewManager', |
|
6567 """<p>The spelling dictionary file <b>{0}</b>""" |
|
6568 """ could not be written.</p>""" |
|
6569 """<p>Reason: {1}</p>""").format( |
|
6570 dictionaryFile, str(err))) |
|
6571 return |
|
6572 |
|
6573 if self.ui.notificationsEnabled(): |
|
6574 self.ui.showNotification( |
|
6575 UI.PixmapCache.getPixmap("spellchecking48.png"), |
|
6576 QCoreApplication.translate( |
|
6577 'ViewManager', "Edit Spelling Dictionary"), |
|
6578 QCoreApplication.translate( |
|
6579 'ViewManager', |
|
6580 "The spelling dictionary was saved successfully.")) |
|
6581 |
|
6582 ################################################################## |
|
6583 ## Below are general utility methods |
|
6584 ################################################################## |
|
6585 |
|
6586 def handleResetUI(self): |
|
6587 """ |
|
6588 Public slot to handle the resetUI signal. |
|
6589 """ |
|
6590 editor = self.activeWindow() |
|
6591 if editor is None: |
|
6592 self.__setSbFile() |
|
6593 else: |
|
6594 line, pos = editor.getCursorPosition() |
|
6595 enc = editor.getEncoding() |
|
6596 lang = editor.getLanguage() |
|
6597 eol = editor.getEolIndicator() |
|
6598 zoom = editor.getZoom() |
|
6599 self.__setSbFile(editor.getFileName(), line + 1, pos, enc, lang, |
|
6600 eol, zoom) |
|
6601 |
|
6602 def closeViewManager(self): |
|
6603 """ |
|
6604 Public method to shutdown the viewmanager. |
|
6605 |
|
6606 If it cannot close all editor windows, it aborts the shutdown process. |
|
6607 |
|
6608 @return flag indicating success (boolean) |
|
6609 """ |
|
6610 try: |
|
6611 e5App().focusChanged.disconnect(self.appFocusChanged) |
|
6612 except TypeError: |
|
6613 pass |
|
6614 |
|
6615 self.closeAllWindows() |
|
6616 self.currentEditor = None |
|
6617 |
|
6618 # save the list of recently opened projects |
|
6619 self.__saveRecent() |
|
6620 |
|
6621 # save the list of recently opened projects |
|
6622 Preferences.Prefs.settings.setValue( |
|
6623 'Bookmarked/Sources', self.bookmarked) |
|
6624 |
|
6625 if len(self.editors): |
|
6626 res = False |
|
6627 else: |
|
6628 res = True |
|
6629 |
|
6630 if not res: |
|
6631 e5App().focusChanged.connect(self.appFocusChanged) |
|
6632 |
|
6633 return res |
|
6634 |
|
6635 def __lastEditorClosed(self): |
|
6636 """ |
|
6637 Private slot to handle the lastEditorClosed signal. |
|
6638 """ |
|
6639 self.closeActGrp.setEnabled(False) |
|
6640 self.saveActGrp.setEnabled(False) |
|
6641 self.exportersMenuAct.setEnabled(False) |
|
6642 self.printAct.setEnabled(False) |
|
6643 if self.printPreviewAct: |
|
6644 self.printPreviewAct.setEnabled(False) |
|
6645 self.editActGrp.setEnabled(False) |
|
6646 self.searchActGrp.setEnabled(False) |
|
6647 self.quickFindtextCombo.setEnabled(False) |
|
6648 self.viewActGrp.setEnabled(False) |
|
6649 self.viewFoldActGrp.setEnabled(False) |
|
6650 self.unhighlightAct.setEnabled(False) |
|
6651 self.newDocumentViewAct.setEnabled(False) |
|
6652 self.newDocumentSplitViewAct.setEnabled(False) |
|
6653 self.splitViewAct.setEnabled(False) |
|
6654 self.splitOrientationAct.setEnabled(False) |
|
6655 self.previewAct.setEnabled(True) |
|
6656 self.astViewerAct.setEnabled(False) |
|
6657 self.macroActGrp.setEnabled(False) |
|
6658 self.bookmarkActGrp.setEnabled(False) |
|
6659 self.__enableSpellingActions() |
|
6660 self.__setSbFile(zoom=0) |
|
6661 |
|
6662 # remove all split views, if this is supported |
|
6663 if self.canSplit(): |
|
6664 while self.removeSplit(): |
|
6665 pass |
|
6666 |
|
6667 # stop the autosave timer |
|
6668 if self.autosaveTimer.isActive(): |
|
6669 self.autosaveTimer.stop() |
|
6670 |
|
6671 # hide search and replace widgets |
|
6672 self.__searchWidget.hide() |
|
6673 self.__replaceWidget.hide() |
|
6674 |
|
6675 # hide the AST Viewer via its action |
|
6676 self.astViewerAct.setChecked(False) |
|
6677 |
|
6678 def __editorOpened(self): |
|
6679 """ |
|
6680 Private slot to handle the editorOpened signal. |
|
6681 """ |
|
6682 self.closeActGrp.setEnabled(True) |
|
6683 self.saveActGrp.setEnabled(True) |
|
6684 self.exportersMenuAct.setEnabled(True) |
|
6685 self.printAct.setEnabled(True) |
|
6686 if self.printPreviewAct: |
|
6687 self.printPreviewAct.setEnabled(True) |
|
6688 self.editActGrp.setEnabled(True) |
|
6689 self.searchActGrp.setEnabled(True) |
|
6690 self.quickFindtextCombo.setEnabled(True) |
|
6691 self.viewActGrp.setEnabled(True) |
|
6692 self.viewFoldActGrp.setEnabled(True) |
|
6693 self.unhighlightAct.setEnabled(True) |
|
6694 self.newDocumentViewAct.setEnabled(True) |
|
6695 if self.canSplit(): |
|
6696 self.newDocumentSplitViewAct.setEnabled(True) |
|
6697 self.splitViewAct.setEnabled(True) |
|
6698 self.splitOrientationAct.setEnabled(True) |
|
6699 self.macroActGrp.setEnabled(True) |
|
6700 self.bookmarkActGrp.setEnabled(True) |
|
6701 self.__enableSpellingActions() |
|
6702 self.astViewerAct.setEnabled(True) |
|
6703 |
|
6704 # activate the autosave timer |
|
6705 if not self.autosaveTimer.isActive() and \ |
|
6706 self.autosaveInterval > 0: |
|
6707 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
6708 |
|
6709 def __autosave(self): |
|
6710 """ |
|
6711 Private slot to save the contents of all editors automatically. |
|
6712 |
|
6713 Only named editors will be saved by the autosave timer. |
|
6714 """ |
|
6715 for editor in self.editors: |
|
6716 if editor.shouldAutosave(): |
|
6717 ok = editor.saveFile() |
|
6718 if ok: |
|
6719 self.setEditorName(editor, editor.getFileName()) |
|
6720 |
|
6721 # restart autosave timer |
|
6722 if self.autosaveInterval > 0: |
|
6723 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
6724 |
|
6725 def _checkActions(self, editor, setSb=True): |
|
6726 """ |
|
6727 Protected slot to check some actions for their enable/disable status |
|
6728 and set the statusbar info. |
|
6729 |
|
6730 @param editor editor window |
|
6731 @param setSb flag indicating an update of the status bar is wanted |
|
6732 (boolean) |
|
6733 """ |
|
6734 if editor is not None: |
|
6735 self.saveAct.setEnabled(editor.isModified()) |
|
6736 self.revertAct.setEnabled(editor.isModified()) |
|
6737 |
|
6738 self.undoAct.setEnabled(editor.isUndoAvailable()) |
|
6739 self.redoAct.setEnabled(editor.isRedoAvailable()) |
|
6740 self.gotoLastEditAct.setEnabled( |
|
6741 editor.isLastEditPositionAvailable()) |
|
6742 |
|
6743 lex = editor.getLexer() |
|
6744 if lex is not None: |
|
6745 self.commentAct.setEnabled(lex.canBlockComment()) |
|
6746 self.uncommentAct.setEnabled(lex.canBlockComment()) |
|
6747 self.streamCommentAct.setEnabled(lex.canStreamComment()) |
|
6748 self.boxCommentAct.setEnabled(lex.canBoxComment()) |
|
6749 else: |
|
6750 self.commentAct.setEnabled(False) |
|
6751 self.uncommentAct.setEnabled(False) |
|
6752 self.streamCommentAct.setEnabled(False) |
|
6753 self.boxCommentAct.setEnabled(False) |
|
6754 |
|
6755 if editor.hasBookmarks(): |
|
6756 self.bookmarkNextAct.setEnabled(True) |
|
6757 self.bookmarkPreviousAct.setEnabled(True) |
|
6758 self.bookmarkClearAct.setEnabled(True) |
|
6759 else: |
|
6760 self.bookmarkNextAct.setEnabled(False) |
|
6761 self.bookmarkPreviousAct.setEnabled(False) |
|
6762 self.bookmarkClearAct.setEnabled(False) |
|
6763 |
|
6764 if editor.hasSyntaxErrors(): |
|
6765 self.syntaxErrorGotoAct.setEnabled(True) |
|
6766 self.syntaxErrorClearAct.setEnabled(True) |
|
6767 else: |
|
6768 self.syntaxErrorGotoAct.setEnabled(False) |
|
6769 self.syntaxErrorClearAct.setEnabled(False) |
|
6770 |
|
6771 if editor.hasWarnings(): |
|
6772 self.warningsNextAct.setEnabled(True) |
|
6773 self.warningsPreviousAct.setEnabled(True) |
|
6774 self.warningsClearAct.setEnabled(True) |
|
6775 else: |
|
6776 self.warningsNextAct.setEnabled(False) |
|
6777 self.warningsPreviousAct.setEnabled(False) |
|
6778 self.warningsClearAct.setEnabled(False) |
|
6779 |
|
6780 if editor.hasCoverageMarkers(): |
|
6781 self.notcoveredNextAct.setEnabled(True) |
|
6782 self.notcoveredPreviousAct.setEnabled(True) |
|
6783 else: |
|
6784 self.notcoveredNextAct.setEnabled(False) |
|
6785 self.notcoveredPreviousAct.setEnabled(False) |
|
6786 |
|
6787 if editor.hasTaskMarkers(): |
|
6788 self.taskNextAct.setEnabled(True) |
|
6789 self.taskPreviousAct.setEnabled(True) |
|
6790 else: |
|
6791 self.taskNextAct.setEnabled(False) |
|
6792 self.taskPreviousAct.setEnabled(False) |
|
6793 |
|
6794 if editor.hasChangeMarkers(): |
|
6795 self.changeNextAct.setEnabled(True) |
|
6796 self.changePreviousAct.setEnabled(True) |
|
6797 else: |
|
6798 self.changeNextAct.setEnabled(False) |
|
6799 self.changePreviousAct.setEnabled(False) |
|
6800 |
|
6801 if editor.canAutoCompleteFromAPIs(): |
|
6802 self.autoCompleteFromAPIsAct.setEnabled(True) |
|
6803 self.autoCompleteFromAllAct.setEnabled(True) |
|
6804 else: |
|
6805 self.autoCompleteFromAPIsAct.setEnabled(False) |
|
6806 self.autoCompleteFromAllAct.setEnabled(False) |
|
6807 self.autoCompleteAct.setEnabled( |
|
6808 editor.canProvideDynamicAutoCompletion()) |
|
6809 self.calltipsAct.setEnabled(editor.canProvideCallTipps()) |
|
6810 self.codeInfoAct.setEnabled(self.__isEditorInfoSupportedEd(editor)) |
|
6811 |
|
6812 if editor.isPyFile() or editor.isRubyFile(): |
|
6813 self.gotoPreviousDefAct.setEnabled(True) |
|
6814 self.gotoNextDefAct.setEnabled(True) |
|
6815 else: |
|
6816 self.gotoPreviousDefAct.setEnabled(False) |
|
6817 self.gotoNextDefAct.setEnabled(False) |
|
6818 |
|
6819 self.sortAct.setEnabled(editor.selectionIsRectangle()) |
|
6820 enable = editor.hasSelection() |
|
6821 self.editUpperCaseAct.setEnabled(enable) |
|
6822 self.editLowerCaseAct.setEnabled(enable) |
|
6823 |
|
6824 if setSb: |
|
6825 line, pos = editor.getCursorPosition() |
|
6826 enc = editor.getEncoding() |
|
6827 lang = editor.getLanguage() |
|
6828 eol = editor.getEolIndicator() |
|
6829 zoom = editor.getZoom() |
|
6830 self.__setSbFile( |
|
6831 editor.getFileName(), line + 1, pos, enc, lang, eol, zoom) |
|
6832 |
|
6833 self.checkActions.emit(editor) |
|
6834 |
|
6835 saveAllEnable = False |
|
6836 for editor in self.editors: |
|
6837 if editor.isModified(): |
|
6838 saveAllEnable = True |
|
6839 self.saveAllAct.setEnabled(saveAllEnable) |
|
6840 |
|
6841 def preferencesChanged(self): |
|
6842 """ |
|
6843 Public slot to handle the preferencesChanged signal. |
|
6844 |
|
6845 This method performs the following actions |
|
6846 <ul> |
|
6847 <li>reread the colours for the syntax highlighting</li> |
|
6848 <li>reloads the already created API objetcs</li> |
|
6849 <li>starts or stops the autosave timer</li> |
|
6850 <li><b>Note</b>: changes in viewmanager type are activated |
|
6851 on an application restart.</li> |
|
6852 </ul> |
|
6853 """ |
|
6854 # reload the APIs |
|
6855 self.apisManager.reloadAPIs() |
|
6856 |
|
6857 # reload editor settings |
|
6858 for editor in self.editors: |
|
6859 zoom = editor.getZoom() |
|
6860 editor.readSettings() |
|
6861 editor.zoomTo(zoom) |
|
6862 |
|
6863 # reload the autosave timer setting |
|
6864 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
|
6865 if len(self.editors): |
|
6866 if self.autosaveTimer.isActive() and \ |
|
6867 self.autosaveInterval == 0: |
|
6868 self.autosaveTimer.stop() |
|
6869 elif not self.autosaveTimer.isActive() and \ |
|
6870 self.autosaveInterval > 0: |
|
6871 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
6872 |
|
6873 self.__enableSpellingActions() |
|
6874 |
|
6875 def __editorSaved(self, fn, editor): |
|
6876 """ |
|
6877 Private slot to handle the editorSaved signal. |
|
6878 |
|
6879 It simply re-emits the signal. |
|
6880 |
|
6881 @param fn filename of the saved editor |
|
6882 @type str |
|
6883 @param editor reference to the editor |
|
6884 @type Editor |
|
6885 """ |
|
6886 self.editorSaved.emit(fn) |
|
6887 self.editorSavedEd.emit(editor) |
|
6888 |
|
6889 def __editorRenamed(self, fn, editor): |
|
6890 """ |
|
6891 Private slot to handle the editorRenamed signal. |
|
6892 |
|
6893 It simply re-emits the signal. |
|
6894 |
|
6895 @param fn filename of the renamed editor |
|
6896 @type str |
|
6897 @param editor reference to the editor |
|
6898 @type Editor |
|
6899 """ |
|
6900 self.editorRenamed.emit(fn) |
|
6901 self.editorRenamedEd.emit(editor) |
|
6902 |
|
6903 def __cursorChanged(self, fn, line, pos, editor): |
|
6904 """ |
|
6905 Private slot to handle the cursorChanged signal. |
|
6906 |
|
6907 It emits the signal cursorChanged with parameter editor. |
|
6908 |
|
6909 @param fn filename |
|
6910 @type str |
|
6911 @param line line number of the cursor |
|
6912 @type int |
|
6913 @param pos position in line of the cursor |
|
6914 @type int |
|
6915 @param editor reference to the editor |
|
6916 @type Editor |
|
6917 """ |
|
6918 enc = editor.getEncoding() |
|
6919 lang = editor.getLanguage() |
|
6920 eol = editor.getEolIndicator() |
|
6921 self.__setSbFile(fn, line, pos, enc, lang, eol) |
|
6922 self.cursorChanged.emit(editor) |
|
6923 |
|
6924 def __editorDoubleClicked(self, editor, pos, buttons): |
|
6925 """ |
|
6926 Private slot handling mouse double clicks of an editor. |
|
6927 |
|
6928 Note: This method is simply a multiplexer to re-emit the signal |
|
6929 with the editor prepended. |
|
6930 |
|
6931 @param editor reference to the editor, that emitted the signal |
|
6932 @type Editor |
|
6933 @param pos position of the double click |
|
6934 @type QPoint |
|
6935 @param buttons mouse buttons that were double clicked |
|
6936 @type Qt.MouseButtons |
|
6937 """ |
|
6938 self.editorDoubleClickedEd.emit(editor, pos, buttons) |
|
6939 |
|
6940 def __breakpointToggled(self, editor): |
|
6941 """ |
|
6942 Private slot to handle the breakpointToggled signal. |
|
6943 |
|
6944 It simply reemits the signal. |
|
6945 |
|
6946 @param editor editor that sent the signal |
|
6947 """ |
|
6948 self.breakpointToggled.emit(editor) |
|
6949 |
|
6950 def getActions(self, actionSetType): |
|
6951 """ |
|
6952 Public method to get a list of all actions. |
|
6953 |
|
6954 @param actionSetType string denoting the action set to get. |
|
6955 It must be one of "edit", "file", "search", "view", "window", |
|
6956 "macro", "bookmark" or "spelling". |
|
6957 @return list of all actions (list of E5Action) |
|
6958 """ |
|
6959 try: |
|
6960 return self.__actions[actionSetType][:] |
|
6961 except KeyError: |
|
6962 return [] |
|
6963 |
|
6964 def __editorCommand(self, cmd): |
|
6965 """ |
|
6966 Private method to send an editor command to the active window. |
|
6967 |
|
6968 @param cmd the scintilla command to be sent |
|
6969 """ |
|
6970 focusWidget = QApplication.focusWidget() |
|
6971 if focusWidget == e5App().getObject("Shell"): |
|
6972 e5App().getObject("Shell").editorCommand(cmd) |
|
6973 elif focusWidget == self.quickFindtextCombo: |
|
6974 self.quickFindtextCombo._editor.editorCommand(cmd) |
|
6975 else: |
|
6976 aw = self.activeWindow() |
|
6977 if aw: |
|
6978 aw.editorCommand(cmd) |
|
6979 |
|
6980 def __newLineBelow(self): |
|
6981 """ |
|
6982 Private method to insert a new line below the current one even if |
|
6983 cursor is not at the end of the line. |
|
6984 """ |
|
6985 focusWidget = QApplication.focusWidget() |
|
6986 if focusWidget == e5App().getObject("Shell") or \ |
|
6987 focusWidget == self.quickFindtextCombo: |
|
6988 return |
|
6989 else: |
|
6990 aw = self.activeWindow() |
|
6991 if aw: |
|
6992 aw.newLineBelow() |
|
6993 |
|
6994 def __editorConfigChanged(self, editor): |
|
6995 """ |
|
6996 Private slot to handle changes of an editor's configuration. |
|
6997 |
|
6998 @param editor reference to the editor |
|
6999 @type Editor |
|
7000 """ |
|
7001 fn = editor.getFileName() |
|
7002 line, pos = editor.getCursorPosition() |
|
7003 enc = editor.getEncoding() |
|
7004 lang = editor.getLanguage() |
|
7005 eol = editor.getEolIndicator() |
|
7006 zoom = editor.getZoom() |
|
7007 self.__setSbFile( |
|
7008 fn, line + 1, pos, encoding=enc, language=lang, eol=eol, zoom=zoom) |
|
7009 self._checkActions(editor, False) |
|
7010 |
|
7011 def __editorSelectionChanged(self, editor): |
|
7012 """ |
|
7013 Private slot to handle changes of the current editors selection. |
|
7014 |
|
7015 @param editor reference to the editor |
|
7016 @type Editor |
|
7017 """ |
|
7018 self.sortAct.setEnabled(editor.selectionIsRectangle()) |
|
7019 enable = editor.hasSelection() |
|
7020 self.editUpperCaseAct.setEnabled(enable) |
|
7021 self.editLowerCaseAct.setEnabled(enable) |
|
7022 |
|
7023 def __editSortSelectedLines(self): |
|
7024 """ |
|
7025 Private slot to sort the selected lines. |
|
7026 """ |
|
7027 editor = self.activeWindow() |
|
7028 if editor: |
|
7029 editor.sortLines() |
|
7030 |
|
7031 def showEditorInfo(self, editor): |
|
7032 """ |
|
7033 Public method to show some information for a given editor. |
|
7034 |
|
7035 @param editor editor to show information text for |
|
7036 @type Editor |
|
7037 """ |
|
7038 documentationViewer = self.ui.documentationViewer() |
|
7039 if documentationViewer: |
|
7040 documentationViewer.showInfo(editor) |
|
7041 |
|
7042 def isEditorInfoSupported(self, language): |
|
7043 """ |
|
7044 Public method to check, if a language is supported by the |
|
7045 documentation viewer. |
|
7046 |
|
7047 @param language editor programming language to check |
|
7048 @type str |
|
7049 @return flag indicating the support status |
|
7050 @rtype bool |
|
7051 """ |
|
7052 documentationViewer = self.ui.documentationViewer() |
|
7053 if documentationViewer: |
|
7054 return documentationViewer.isSupportedLanguage(language) |
|
7055 else: |
|
7056 return False |
|
7057 |
|
7058 def __isEditorInfoSupportedEd(self, editor): |
|
7059 """ |
|
7060 Private method to check, if an editor is supported by the |
|
7061 documentation viewer. |
|
7062 |
|
7063 @param editor reference to the editor to check for |
|
7064 @type Editor |
|
7065 @return flag indicating the support status |
|
7066 @rtype bool |
|
7067 """ |
|
7068 language = editor.getLanguage() |
|
7069 return self.isEditorInfoSupported(language) |
|
7070 |
|
7071 ################################################################## |
|
7072 ## Below are protected utility methods |
|
7073 ################################################################## |
|
7074 |
|
7075 def _getOpenStartDir(self): |
|
7076 """ |
|
7077 Protected method to return the starting directory for a file open |
|
7078 dialog. |
|
7079 |
|
7080 The appropriate starting directory is calculated |
|
7081 using the following search order, until a match is found:<br /> |
|
7082 1: Directory of currently active editor<br /> |
|
7083 2: Directory of currently active Project<br /> |
|
7084 3: CWD |
|
7085 |
|
7086 @return name of directory to start (string) |
|
7087 """ |
|
7088 # if we have an active source, return its path |
|
7089 if self.activeWindow() is not None and \ |
|
7090 self.activeWindow().getFileName(): |
|
7091 return os.path.dirname(self.activeWindow().getFileName()) |
|
7092 |
|
7093 # check, if there is an active project and return its path |
|
7094 elif e5App().getObject("Project").isOpen(): |
|
7095 return e5App().getObject("Project").ppath |
|
7096 |
|
7097 else: |
|
7098 return Preferences.getMultiProject("Workspace") or \ |
|
7099 Utilities.getHomeDir() |
|
7100 |
|
7101 def _getOpenFileFilter(self): |
|
7102 """ |
|
7103 Protected method to return the active filename filter for a file open |
|
7104 dialog. |
|
7105 |
|
7106 The appropriate filename filter is determined by file extension of |
|
7107 the currently active editor. |
|
7108 |
|
7109 @return name of the filename filter (string) or None |
|
7110 """ |
|
7111 if self.activeWindow() is not None and \ |
|
7112 self.activeWindow().getFileName(): |
|
7113 ext = os.path.splitext(self.activeWindow().getFileName())[1] |
|
7114 rx = QRegExp(r".*\*\.{0}[ )].*".format(ext[1:])) |
|
7115 import QScintilla.Lexers |
|
7116 filters = QScintilla.Lexers.getOpenFileFiltersList() |
|
7117 index = -1 |
|
7118 for i in range(len(filters)): |
|
7119 if rx.exactMatch(filters[i]): |
|
7120 index = i |
|
7121 break |
|
7122 if index == -1: |
|
7123 return Preferences.getEditor("DefaultOpenFilter") |
|
7124 else: |
|
7125 return filters[index] |
|
7126 else: |
|
7127 return Preferences.getEditor("DefaultOpenFilter") |
|
7128 |
|
7129 ################################################################## |
|
7130 ## Below are API handling methods |
|
7131 ################################################################## |
|
7132 |
|
7133 def getAPIsManager(self): |
|
7134 """ |
|
7135 Public method to get a reference to the APIs manager. |
|
7136 |
|
7137 @return the APIs manager object (eric6.QScintilla.APIsManager) |
|
7138 """ |
|
7139 return self.apisManager |
|
7140 |
|
7141 ####################################################################### |
|
7142 ## Cooperation related methods |
|
7143 ####################################################################### |
|
7144 |
|
7145 def setCooperationClient(self, client): |
|
7146 """ |
|
7147 Public method to set a reference to the cooperation client. |
|
7148 |
|
7149 @param client reference to the cooperation client (CooperationClient) |
|
7150 """ |
|
7151 self.__cooperationClient = client |
|
7152 |
|
7153 def isConnected(self): |
|
7154 """ |
|
7155 Public method to check the connection status of the IDE. |
|
7156 |
|
7157 @return flag indicating the connection status (boolean) |
|
7158 """ |
|
7159 return self.__cooperationClient.hasConnections() |
|
7160 |
|
7161 def send(self, fileName, message): |
|
7162 """ |
|
7163 Public method to send an editor command to remote editors. |
|
7164 |
|
7165 @param fileName file name of the editor (string) |
|
7166 @param message command message to be sent (string) |
|
7167 """ |
|
7168 project = e5App().getObject("Project") |
|
7169 if project.isProjectFile(fileName): |
|
7170 self.__cooperationClient.sendEditorCommand( |
|
7171 project.getHash(), |
|
7172 project.getRelativeUniversalPath(fileName), |
|
7173 message |
|
7174 ) |
|
7175 |
|
7176 def receive(self, projectHash, fileName, command): |
|
7177 """ |
|
7178 Public slot to handle received editor commands. |
|
7179 |
|
7180 @param projectHash hash of the project (string) |
|
7181 @param fileName project relative file name of the editor (string) |
|
7182 @param command command string (string) |
|
7183 """ |
|
7184 project = e5App().getObject("Project") |
|
7185 if projectHash == project.getHash(): |
|
7186 fn = project.getAbsoluteUniversalPath(fileName) |
|
7187 editor = self.getOpenEditor(fn) |
|
7188 if editor: |
|
7189 editor.receive(command) |
|
7190 |
|
7191 def shareConnected(self, connected): |
|
7192 """ |
|
7193 Public slot to handle a change of the connected state. |
|
7194 |
|
7195 @param connected flag indicating the connected state (boolean) |
|
7196 """ |
|
7197 for editor in self.getOpenEditors(): |
|
7198 editor.shareConnected(connected) |
|
7199 |
|
7200 def shareEditor(self, share): |
|
7201 """ |
|
7202 Public slot to set the shared status of the current editor. |
|
7203 |
|
7204 @param share flag indicating the share status (boolean) |
|
7205 """ |
|
7206 aw = self.activeWindow() |
|
7207 if aw is not None: |
|
7208 fn = aw.getFileName() |
|
7209 if fn and e5App().getObject("Project").isProjectFile(fn): |
|
7210 aw.shareEditor(share) |
|
7211 |
|
7212 def startSharedEdit(self): |
|
7213 """ |
|
7214 Public slot to start a shared edit session for the current editor. |
|
7215 """ |
|
7216 aw = self.activeWindow() |
|
7217 if aw is not None: |
|
7218 fn = aw.getFileName() |
|
7219 if fn and e5App().getObject("Project").isProjectFile(fn): |
|
7220 aw.startSharedEdit() |
|
7221 |
|
7222 def sendSharedEdit(self): |
|
7223 """ |
|
7224 Public slot to end a shared edit session for the current editor and |
|
7225 send the changes. |
|
7226 """ |
|
7227 aw = self.activeWindow() |
|
7228 if aw is not None: |
|
7229 fn = aw.getFileName() |
|
7230 if fn and e5App().getObject("Project").isProjectFile(fn): |
|
7231 aw.sendSharedEdit() |
|
7232 |
|
7233 def cancelSharedEdit(self): |
|
7234 """ |
|
7235 Public slot to cancel a shared edit session for the current editor. |
|
7236 """ |
|
7237 aw = self.activeWindow() |
|
7238 if aw is not None: |
|
7239 fn = aw.getFileName() |
|
7240 if fn and e5App().getObject("Project").isProjectFile(fn): |
|
7241 aw.cancelSharedEdit() |
|
7242 |
|
7243 ####################################################################### |
|
7244 ## Symbols viewer related methods |
|
7245 ####################################################################### |
|
7246 |
|
7247 def insertSymbol(self, txt): |
|
7248 """ |
|
7249 Public slot to insert a symbol text into the active window. |
|
7250 |
|
7251 @param txt text to be inserted (string) |
|
7252 """ |
|
7253 if self.__lastFocusWidget == e5App().getObject("Shell"): |
|
7254 e5App().getObject("Shell").insert(txt) |
|
7255 else: |
|
7256 aw = self.activeWindow() |
|
7257 if aw is not None: |
|
7258 curline, curindex = aw.getCursorPosition() |
|
7259 aw.insert(txt) |
|
7260 aw.setCursorPosition(curline, curindex + len(txt)) |
|
7261 |
|
7262 ####################################################################### |
|
7263 ## Numbers viewer related methods |
|
7264 ####################################################################### |
|
7265 |
|
7266 def insertNumber(self, txt): |
|
7267 """ |
|
7268 Public slot to insert a number text into the active window. |
|
7269 |
|
7270 @param txt text to be inserted (string) |
|
7271 """ |
|
7272 if self.__lastFocusWidget == e5App().getObject("Shell"): |
|
7273 aw = e5App().getObject("Shell") |
|
7274 if aw.hasSelectedText(): |
|
7275 aw.removeSelectedText() |
|
7276 aw.insert(txt) |
|
7277 else: |
|
7278 aw = self.activeWindow() |
|
7279 if aw is not None: |
|
7280 if aw.hasSelectedText(): |
|
7281 aw.removeSelectedText() |
|
7282 curline, curindex = aw.getCursorPosition() |
|
7283 aw.insert(txt) |
|
7284 aw.setCursorPosition(curline, curindex + len(txt)) |
|
7285 |
|
7286 def getNumber(self): |
|
7287 """ |
|
7288 Public method to get a number from the active window. |
|
7289 |
|
7290 @return selected text of the active window (string) |
|
7291 """ |
|
7292 txt = "" |
|
7293 if self.__lastFocusWidget == e5App().getObject("Shell"): |
|
7294 aw = e5App().getObject("Shell") |
|
7295 if aw.hasSelectedText(): |
|
7296 txt = aw.selectedText() |
|
7297 else: |
|
7298 aw = self.activeWindow() |
|
7299 if aw is not None: |
|
7300 if aw.hasSelectedText(): |
|
7301 txt = aw.selectedText() |
|
7302 return txt |