eric6/ViewManager/ViewManager.py

changeset 6942
2602857055c5
parent 6932
8a3df4c6ac9a
child 6989
8b8cadf8d7e9
child 7007
0ba99702920c
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
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 &current 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,