|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2002 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the viewmanager base class. |
|
8 """ |
|
9 |
|
10 import os |
|
11 |
|
12 from PyQt4.QtCore import * |
|
13 from PyQt4.QtGui import * |
|
14 from PyQt4.Qsci import QsciScintilla |
|
15 |
|
16 from E4Gui.E4Application import e4App |
|
17 |
|
18 from Globals import recentNameFiles |
|
19 |
|
20 import Preferences |
|
21 |
|
22 from BookmarkedFilesDialog import BookmarkedFilesDialog |
|
23 |
|
24 from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION |
|
25 from QScintilla.Editor import Editor |
|
26 from QScintilla.GotoDialog import GotoDialog |
|
27 from QScintilla.SearchReplaceWidget import SearchReplaceWidget |
|
28 from QScintilla.ZoomDialog import ZoomDialog |
|
29 from QScintilla.APIsManager import APIsManager |
|
30 from QScintilla.SpellChecker import SpellChecker |
|
31 import QScintilla.Lexers |
|
32 import QScintilla.Exporters |
|
33 |
|
34 import Utilities |
|
35 |
|
36 import UI.PixmapCache |
|
37 import UI.Config |
|
38 |
|
39 from E4Gui.E4Action import E4Action, createActionGroup |
|
40 |
|
41 class QuickSearchLineEdit(QLineEdit): |
|
42 """ |
|
43 Class implementing a line edit that reacts to newline and cancel commands. |
|
44 |
|
45 @signal escPressed() emitted after the cancel command was activated |
|
46 @signal returnPressed() emitted after a newline command was activated |
|
47 @signal gotFocus() emitted when the focus is changed to this widget |
|
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.emit(SIGNAL("returnPressed()")) |
|
64 elif cmd == QsciScintilla.SCI_CANCEL: |
|
65 self.emit(SIGNAL("escPressed()")) |
|
66 |
|
67 def keyPressEvent(self, evt): |
|
68 """ |
|
69 Re-implemented 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.emit(SIGNAL("escPressed()")) |
|
75 else: |
|
76 QLineEdit.keyPressEvent(self, evt) # pass it on |
|
77 |
|
78 def focusInEvent(self, evt): |
|
79 """ |
|
80 Re-implemented to record the current editor widget. |
|
81 |
|
82 @param evt focus event (QFocusEvent) |
|
83 """ |
|
84 self.emit(SIGNAL("gotFocus()")) |
|
85 QLineEdit.focusInEvent(self, evt) # pass it on |
|
86 |
|
87 class ViewManager(QObject): |
|
88 """ |
|
89 Base class inherited by all specific viewmanager classes. |
|
90 |
|
91 It defines the interface to be implemented by specific |
|
92 viewmanager classes and all common methods. |
|
93 |
|
94 @signal lastEditorClosed emitted after the last editor window was closed |
|
95 @signal editorOpened(string) emitted after an editor window was opened |
|
96 @signal editorOpenedEd(editor) emitted after an editor window was opened |
|
97 @signal editorClosed(string) emitted just before an editor window gets closed |
|
98 @signal editorClosedEd(editor) emitted just before an editor window gets closed |
|
99 @signal editorSaved(string) emitted after an editor window was saved |
|
100 @signal checkActions(editor) emitted when some actions should be checked |
|
101 for their status |
|
102 @signal cursorChanged(editor) emitted after the cursor position of the active |
|
103 window has changed |
|
104 @signal breakpointToggled(editor) emitted when a breakpoint is toggled. |
|
105 @signal bookmarkToggled(editor) emitted when a bookmark is toggled. |
|
106 """ |
|
107 def __init__(self): |
|
108 """ |
|
109 Constructor |
|
110 |
|
111 @param ui reference to the main user interface |
|
112 @param dbs reference to the debug server object |
|
113 """ |
|
114 QObject.__init__(self) |
|
115 |
|
116 # initialize the instance variables |
|
117 self.editors = [] |
|
118 self.currentEditor = None |
|
119 self.untitledCount = 0 |
|
120 self.srHistory = { |
|
121 "search" : [], |
|
122 "replace" : [] |
|
123 } |
|
124 self.editorsCheckFocusIn = True |
|
125 |
|
126 self.recent = [] |
|
127 self.__loadRecent() |
|
128 |
|
129 self.bookmarked = [] |
|
130 bs = Preferences.Prefs.settings.value("Bookmarked/Sources") |
|
131 if bs.isValid(): |
|
132 self.bookmarked = bs.toStringList() |
|
133 |
|
134 # initialize the autosave timer |
|
135 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
|
136 self.autosaveTimer = QTimer(self) |
|
137 self.autosaveTimer.setObjectName("AutosaveTimer") |
|
138 self.autosaveTimer.setSingleShot(True) |
|
139 self.connect(self.autosaveTimer, SIGNAL('timeout()'), self.__autosave) |
|
140 |
|
141 # initialize the APIs manager |
|
142 self.apisManager = APIsManager(parent = self) |
|
143 |
|
144 def setReferences(self, ui, dbs): |
|
145 """ |
|
146 Public method to set some references needed later on. |
|
147 |
|
148 @param ui reference to the main user interface |
|
149 @param dbs reference to the debug server object |
|
150 """ |
|
151 self.ui = ui |
|
152 self.dbs = dbs |
|
153 |
|
154 self.searchDlg = SearchReplaceWidget(False, self, ui) |
|
155 self.replaceDlg = SearchReplaceWidget(True, self, ui) |
|
156 |
|
157 self.connect(self, SIGNAL("checkActions"), |
|
158 self.searchDlg.updateSelectionCheckBox) |
|
159 self.connect(self, SIGNAL("checkActions"), |
|
160 self.replaceDlg.updateSelectionCheckBox) |
|
161 |
|
162 def __loadRecent(self): |
|
163 """ |
|
164 Private method to load the recently opened filenames. |
|
165 """ |
|
166 self.recent = [] |
|
167 Preferences.Prefs.rsettings.sync() |
|
168 rs = Preferences.Prefs.rsettings.value(recentNameFiles) |
|
169 if rs.isValid(): |
|
170 for f in rs.toStringList(): |
|
171 if QFileInfo(f).exists(): |
|
172 self.recent.append(f) |
|
173 |
|
174 def __saveRecent(self): |
|
175 """ |
|
176 Private method to save the list of recently opened filenames. |
|
177 """ |
|
178 Preferences.Prefs.rsettings.setValue(recentNameFiles, QVariant(self.recent)) |
|
179 Preferences.Prefs.rsettings.sync() |
|
180 |
|
181 def getMostRecent(self): |
|
182 """ |
|
183 Public method to get the most recently opened file. |
|
184 |
|
185 @return path of the most recently opened file (string) |
|
186 """ |
|
187 if len(self.recent): |
|
188 return self.recent[0] |
|
189 else: |
|
190 return None |
|
191 |
|
192 def setSbInfo(self, sbFile, sbLine, sbPos, sbWritable, sbEncoding, sbLanguage, sbEol): |
|
193 """ |
|
194 Public method to transfer statusbar info from the user interface to viewmanager. |
|
195 |
|
196 @param sbFile reference to the file part of the statusbar (E4SqueezeLabelPath) |
|
197 @param sbLine reference to the line number part of the statusbar (QLabel) |
|
198 @param sbPos reference to the character position part of the statusbar (QLabel) |
|
199 @param sbWritable reference to the writability indicator part of |
|
200 the statusbar (QLabel) |
|
201 @param sbEncoding reference to the encoding indicator part of the |
|
202 statusbar (QLabel) |
|
203 @param sbLanguage reference to the language indicator part of the |
|
204 statusbar (QLabel) |
|
205 @param sbEol reference to the eol indicator part of the statusbar (QLabel) |
|
206 """ |
|
207 self.sbFile = sbFile |
|
208 self.sbLine = sbLine |
|
209 self.sbPos = sbPos |
|
210 self.sbWritable = sbWritable |
|
211 self.sbEnc = sbEncoding |
|
212 self.sbLang = sbLanguage |
|
213 self.sbEol = sbEol |
|
214 self.__setSbFile() |
|
215 |
|
216 ############################################################################ |
|
217 ## methods below need to be implemented by a subclass |
|
218 ############################################################################ |
|
219 |
|
220 def canCascade(self): |
|
221 """ |
|
222 Public method to signal if cascading of managed windows is available. |
|
223 |
|
224 @return flag indicating cascading of windows is available |
|
225 @exception RuntimeError Not implemented |
|
226 """ |
|
227 raise RuntimeError('Not implemented') |
|
228 |
|
229 def canTile(self): |
|
230 """ |
|
231 Public method to signal if tiling of managed windows is available. |
|
232 |
|
233 @return flag indicating tiling of windows is available |
|
234 @exception RuntimeError Not implemented |
|
235 """ |
|
236 raise RuntimeError('Not implemented') |
|
237 |
|
238 def tile(self): |
|
239 """ |
|
240 Public method to tile the managed windows. |
|
241 |
|
242 @exception RuntimeError Not implemented |
|
243 """ |
|
244 raise RuntimeError('Not implemented') |
|
245 |
|
246 def cascade(self): |
|
247 """ |
|
248 Public method to cascade the managed windows. |
|
249 |
|
250 @exception RuntimeError Not implemented |
|
251 """ |
|
252 raise RuntimeError('Not implemented') |
|
253 |
|
254 def activeWindow(self): |
|
255 """ |
|
256 Public method to return the active (i.e. current) window. |
|
257 |
|
258 @return reference to the active editor |
|
259 @exception RuntimeError Not implemented |
|
260 """ |
|
261 raise RuntimeError('Not implemented') |
|
262 |
|
263 def _removeAllViews(self): |
|
264 """ |
|
265 Protected method to remove all views (i.e. windows) |
|
266 |
|
267 @exception RuntimeError Not implemented |
|
268 """ |
|
269 raise RuntimeError('Not implemented') |
|
270 |
|
271 def _removeView(self, win): |
|
272 """ |
|
273 Protected method to remove a view (i.e. window) |
|
274 |
|
275 @param win editor window to be removed |
|
276 @exception RuntimeError Not implemented |
|
277 """ |
|
278 raise RuntimeError('Not implemented') |
|
279 |
|
280 def _addView(self, win, fn=None, noName=""): |
|
281 """ |
|
282 Protected method to add a view (i.e. window) |
|
283 |
|
284 @param win editor window to be added |
|
285 @param fn filename of this editor |
|
286 @param noName name to be used for an unnamed editor (string) |
|
287 @exception RuntimeError Not implemented |
|
288 """ |
|
289 raise RuntimeError('Not implemented') |
|
290 |
|
291 def _showView(self, win, fn=None): |
|
292 """ |
|
293 Protected method to show a view (i.e. window) |
|
294 |
|
295 @param win editor window to be shown |
|
296 @param fn filename of this editor |
|
297 @exception RuntimeError Not implemented |
|
298 """ |
|
299 raise RuntimeError('Not implemented') |
|
300 |
|
301 def showWindowMenu(self, windowMenu): |
|
302 """ |
|
303 Public method to set up the viewmanager part of the Window menu. |
|
304 |
|
305 @param windowMenu reference to the window menu |
|
306 @exception RuntimeError Not implemented |
|
307 """ |
|
308 raise RuntimeError('Not implemented') |
|
309 |
|
310 def _initWindowActions(self): |
|
311 """ |
|
312 Protected method to define the user interface actions for window handling. |
|
313 |
|
314 @exception RuntimeError Not implemented |
|
315 """ |
|
316 raise RuntimeError('Not implemented') |
|
317 |
|
318 def setEditorName(self, editor, newName): |
|
319 """ |
|
320 Public method to change the displayed name of the editor. |
|
321 |
|
322 @param editor editor window to be changed |
|
323 @param newName new name to be shown (string) |
|
324 @exception RuntimeError Not implemented |
|
325 """ |
|
326 raise RuntimeError('Not implemented') |
|
327 |
|
328 def _modificationStatusChanged(self, m, editor): |
|
329 """ |
|
330 Protected slot to handle the modificationStatusChanged signal. |
|
331 |
|
332 @param m flag indicating the modification status (boolean) |
|
333 @param editor editor window changed |
|
334 @exception RuntimeError Not implemented |
|
335 """ |
|
336 raise RuntimeError('Not implemented') |
|
337 |
|
338 ##################################################################### |
|
339 ## methods above need to be implemented by a subclass |
|
340 ##################################################################### |
|
341 |
|
342 def canSplit(self): |
|
343 """ |
|
344 Public method to signal if splitting of the view is available. |
|
345 |
|
346 @return flag indicating splitting of the view is available. |
|
347 """ |
|
348 return False |
|
349 |
|
350 def addSplit(self): |
|
351 """ |
|
352 Public method used to split the current view. |
|
353 """ |
|
354 pass |
|
355 |
|
356 def removeSplit(self): |
|
357 """ |
|
358 Public method used to remove the current split view. |
|
359 |
|
360 @return Flag indicating successful deletion |
|
361 """ |
|
362 return False |
|
363 |
|
364 def setSplitOrientation(self, orientation): |
|
365 """ |
|
366 Public method used to set the orientation of the split view. |
|
367 |
|
368 @param orientation orientation of the split |
|
369 (Qt.Horizontal or Qt.Vertical) |
|
370 """ |
|
371 pass |
|
372 |
|
373 def nextSplit(self): |
|
374 """ |
|
375 Public slot used to move to the next split. |
|
376 """ |
|
377 pass |
|
378 |
|
379 def prevSplit(self): |
|
380 """ |
|
381 Public slot used to move to the previous split. |
|
382 """ |
|
383 pass |
|
384 |
|
385 def eventFilter(self, object, event): |
|
386 """ |
|
387 Public method called to filter an event. |
|
388 |
|
389 @param object object, that generated the event (QObject) |
|
390 @param event the event, that was generated by object (QEvent) |
|
391 @return flag indicating if event was filtered out |
|
392 """ |
|
393 return False |
|
394 |
|
395 ##################################################################### |
|
396 ## methods above need to be implemented by a subclass, that supports |
|
397 ## splitting of the viewmanager area. |
|
398 ##################################################################### |
|
399 |
|
400 def initActions(self): |
|
401 """ |
|
402 Public method defining the user interface actions. |
|
403 """ |
|
404 # list containing all edit actions |
|
405 self.editActions = [] |
|
406 |
|
407 # list containing all file actions |
|
408 self.fileActions = [] |
|
409 |
|
410 # list containing all search actions |
|
411 self.searchActions = [] |
|
412 |
|
413 # list containing all view actions |
|
414 self.viewActions = [] |
|
415 |
|
416 # list containing all window actions |
|
417 self.windowActions = [] |
|
418 |
|
419 # list containing all macro actions |
|
420 self.macroActions = [] |
|
421 |
|
422 # list containing all bookmark actions |
|
423 self.bookmarkActions = [] |
|
424 |
|
425 # list containing all spell checking actions |
|
426 self.spellingActions = [] |
|
427 |
|
428 self._initWindowActions() |
|
429 self.__initFileActions() |
|
430 self.__initEditActions() |
|
431 self.__initSearchActions() |
|
432 self.__initViewActions() |
|
433 self.__initMacroActions() |
|
434 self.__initBookmarkActions() |
|
435 self.__initSpellingActions() |
|
436 |
|
437 ################################################################## |
|
438 ## Initialize the file related actions, file menu and toolbar |
|
439 ################################################################## |
|
440 |
|
441 def __initFileActions(self): |
|
442 """ |
|
443 Private method defining the user interface actions for file handling. |
|
444 """ |
|
445 self.newAct = E4Action(QApplication.translate('ViewManager', 'New'), |
|
446 UI.PixmapCache.getIcon("new.png"), |
|
447 QApplication.translate('ViewManager', '&New'), |
|
448 QKeySequence(QApplication.translate('ViewManager', "Ctrl+N", "File|New")), |
|
449 0, self, 'vm_file_new') |
|
450 self.newAct.setStatusTip(\ |
|
451 QApplication.translate('ViewManager', 'Open an empty editor window')) |
|
452 self.newAct.setWhatsThis(QApplication.translate('ViewManager', |
|
453 """<b>New</b>""" |
|
454 """<p>An empty editor window will be created.</p>""" |
|
455 )) |
|
456 self.connect(self.newAct, SIGNAL('triggered()'), self.newEditor) |
|
457 self.fileActions.append(self.newAct) |
|
458 |
|
459 self.openAct = E4Action(QApplication.translate('ViewManager', 'Open'), |
|
460 UI.PixmapCache.getIcon("open.png"), |
|
461 QApplication.translate('ViewManager', '&Open...'), |
|
462 QKeySequence(\ |
|
463 QApplication.translate('ViewManager', "Ctrl+O", "File|Open")), |
|
464 0, self, 'vm_file_open') |
|
465 self.openAct.setStatusTip(QApplication.translate('ViewManager', 'Open a file')) |
|
466 self.openAct.setWhatsThis(QApplication.translate('ViewManager', |
|
467 """<b>Open a file</b>""" |
|
468 """<p>You will be asked for the name of a file to be opened""" |
|
469 """ in an editor window.</p>""" |
|
470 )) |
|
471 self.connect(self.openAct, SIGNAL('triggered()'), self.openFiles) |
|
472 self.fileActions.append(self.openAct) |
|
473 |
|
474 self.closeActGrp = createActionGroup(self) |
|
475 |
|
476 self.closeAct = E4Action(QApplication.translate('ViewManager', 'Close'), |
|
477 UI.PixmapCache.getIcon("close.png"), |
|
478 QApplication.translate('ViewManager', '&Close'), |
|
479 QKeySequence(\ |
|
480 QApplication.translate('ViewManager', "Ctrl+W", "File|Close")), |
|
481 0, self.closeActGrp, 'vm_file_close') |
|
482 self.closeAct.setStatusTip(\ |
|
483 QApplication.translate('ViewManager', 'Close the current window')) |
|
484 self.closeAct.setWhatsThis(QApplication.translate('ViewManager', |
|
485 """<b>Close Window</b>""" |
|
486 """<p>Close the current window.</p>""" |
|
487 )) |
|
488 self.connect(self.closeAct, SIGNAL('triggered()'), self.closeCurrentWindow) |
|
489 self.fileActions.append(self.closeAct) |
|
490 |
|
491 self.closeAllAct = E4Action(QApplication.translate('ViewManager', 'Close All'), |
|
492 QApplication.translate('ViewManager', 'Clos&e All'), |
|
493 0, 0, self.closeActGrp, 'vm_file_close_all') |
|
494 self.closeAllAct.setStatusTip(\ |
|
495 QApplication.translate('ViewManager', 'Close all editor windows')) |
|
496 self.closeAllAct.setWhatsThis(QApplication.translate('ViewManager', |
|
497 """<b>Close All Windows</b>""" |
|
498 """<p>Close all editor windows.</p>""" |
|
499 )) |
|
500 self.connect(self.closeAllAct, SIGNAL('triggered()'), self.closeAllWindows) |
|
501 self.fileActions.append(self.closeAllAct) |
|
502 |
|
503 self.closeActGrp.setEnabled(False) |
|
504 |
|
505 self.saveActGrp = createActionGroup(self) |
|
506 |
|
507 self.saveAct = E4Action(QApplication.translate('ViewManager', 'Save'), |
|
508 UI.PixmapCache.getIcon("fileSave.png"), |
|
509 QApplication.translate('ViewManager', '&Save'), |
|
510 QKeySequence(\ |
|
511 QApplication.translate('ViewManager', "Ctrl+S", "File|Save")), |
|
512 0, self.saveActGrp, 'vm_file_save') |
|
513 self.saveAct.setStatusTip(\ |
|
514 QApplication.translate('ViewManager', 'Save the current file')) |
|
515 self.saveAct.setWhatsThis(QApplication.translate('ViewManager', |
|
516 """<b>Save File</b>""" |
|
517 """<p>Save the contents of current editor window.</p>""" |
|
518 )) |
|
519 self.connect(self.saveAct, SIGNAL('triggered()'), self.saveCurrentEditor) |
|
520 self.fileActions.append(self.saveAct) |
|
521 |
|
522 self.saveAsAct = E4Action(QApplication.translate('ViewManager', 'Save as'), |
|
523 UI.PixmapCache.getIcon("fileSaveAs.png"), |
|
524 QApplication.translate('ViewManager', 'Save &as...'), |
|
525 QKeySequence(QApplication.translate('ViewManager', |
|
526 "Shift+Ctrl+S", "File|Save As")), |
|
527 0, self.saveActGrp, 'vm_file_save_as') |
|
528 self.saveAsAct.setStatusTip(QApplication.translate('ViewManager', |
|
529 'Save the current file to a new one')) |
|
530 self.saveAsAct.setWhatsThis(QApplication.translate('ViewManager', |
|
531 """<b>Save File as</b>""" |
|
532 """<p>Save the contents of current editor window to a new file.""" |
|
533 """ The file can be entered in a file selection dialog.</p>""" |
|
534 )) |
|
535 self.connect(self.saveAsAct, SIGNAL('triggered()'), self.saveAsCurrentEditor) |
|
536 self.fileActions.append(self.saveAsAct) |
|
537 |
|
538 self.saveAllAct = E4Action(QApplication.translate('ViewManager', 'Save all'), |
|
539 UI.PixmapCache.getIcon("fileSaveAll.png"), |
|
540 QApplication.translate('ViewManager', 'Save a&ll...'), |
|
541 0, 0, self.saveActGrp, 'vm_file_save_all') |
|
542 self.saveAllAct.setStatusTip(QApplication.translate('ViewManager', |
|
543 'Save all files')) |
|
544 self.saveAllAct.setWhatsThis(QApplication.translate('ViewManager', |
|
545 """<b>Save All Files</b>""" |
|
546 """<p>Save the contents of all editor windows.</p>""" |
|
547 )) |
|
548 self.connect(self.saveAllAct, SIGNAL('triggered()'), self.saveAllEditors) |
|
549 self.fileActions.append(self.saveAllAct) |
|
550 |
|
551 self.saveActGrp.setEnabled(False) |
|
552 |
|
553 self.saveToProjectAct = E4Action(QApplication.translate('ViewManager', |
|
554 'Save to Project'), |
|
555 UI.PixmapCache.getIcon("fileSaveProject.png"), |
|
556 QApplication.translate('ViewManager', 'Save to Pro&ject'), |
|
557 0, 0,self, 'vm_file_save_to_project') |
|
558 self.saveToProjectAct.setStatusTip(QApplication.translate('ViewManager', |
|
559 'Save the current file to the current project')) |
|
560 self.saveToProjectAct.setWhatsThis(QApplication.translate('ViewManager', |
|
561 """<b>Save to Project</b>""" |
|
562 """<p>Save the contents of the current editor window to the""" |
|
563 """ current project. After the file has been saved, it is""" |
|
564 """ automatically added to the current project.</p>""" |
|
565 )) |
|
566 self.connect(self.saveToProjectAct, SIGNAL('triggered()'), |
|
567 self.saveCurrentEditorToProject) |
|
568 self.saveToProjectAct.setEnabled(False) |
|
569 self.fileActions.append(self.saveToProjectAct) |
|
570 |
|
571 self.printAct = E4Action(QApplication.translate('ViewManager', 'Print'), |
|
572 UI.PixmapCache.getIcon("print.png"), |
|
573 QApplication.translate('ViewManager', '&Print'), |
|
574 QKeySequence(QApplication.translate('ViewManager', |
|
575 "Ctrl+P", "File|Print")), |
|
576 0, self, 'vm_file_print') |
|
577 self.printAct.setStatusTip(QApplication.translate('ViewManager', |
|
578 'Print the current file')) |
|
579 self.printAct.setWhatsThis(QApplication.translate('ViewManager', |
|
580 """<b>Print File</b>""" |
|
581 """<p>Print the contents of current editor window.</p>""" |
|
582 )) |
|
583 self.connect(self.printAct, SIGNAL('triggered()'), self.printCurrentEditor) |
|
584 self.printAct.setEnabled(False) |
|
585 self.fileActions.append(self.printAct) |
|
586 |
|
587 self.printPreviewAct = \ |
|
588 E4Action(QApplication.translate('ViewManager', 'Print Preview'), |
|
589 UI.PixmapCache.getIcon("printPreview.png"), |
|
590 QApplication.translate('ViewManager', 'Print Preview'), |
|
591 0, 0, self, 'vm_file_print_preview') |
|
592 self.printPreviewAct.setStatusTip(QApplication.translate('ViewManager', |
|
593 'Print preview of the current file')) |
|
594 self.printPreviewAct.setWhatsThis(QApplication.translate('ViewManager', |
|
595 """<b>Print Preview</b>""" |
|
596 """<p>Print preview of the current editor window.</p>""" |
|
597 )) |
|
598 self.connect(self.printPreviewAct, SIGNAL('triggered()'), |
|
599 self.printPreviewCurrentEditor) |
|
600 self.printPreviewAct.setEnabled(False) |
|
601 self.fileActions.append(self.printPreviewAct) |
|
602 |
|
603 self.findFileNameAct = E4Action(QApplication.translate('ViewManager', |
|
604 'Search File'), |
|
605 QApplication.translate('ViewManager', 'Search &File...'), |
|
606 QKeySequence(QApplication.translate('ViewManager', |
|
607 "Alt+Ctrl+F", "File|Search File")), |
|
608 0, self, 'vm_file_search_file') |
|
609 self.findFileNameAct.setStatusTip(QApplication.translate('ViewManager', |
|
610 'Search for a file')) |
|
611 self.findFileNameAct.setWhatsThis(QApplication.translate('ViewManager', |
|
612 """<b>Search File</b>""" |
|
613 """<p>Search for a file.</p>""" |
|
614 )) |
|
615 self.connect(self.findFileNameAct, SIGNAL('triggered()'), self.__findFileName) |
|
616 self.fileActions.append(self.findFileNameAct) |
|
617 |
|
618 def initFileMenu(self): |
|
619 """ |
|
620 Public method to create the File menu. |
|
621 |
|
622 @return the generated menu |
|
623 """ |
|
624 menu = QMenu(QApplication.translate('ViewManager', '&File'), self.ui) |
|
625 self.recentMenu = QMenu(QApplication.translate('ViewManager', |
|
626 'Open &Recent Files'), menu) |
|
627 self.bookmarkedMenu = QMenu(QApplication.translate('ViewManager', |
|
628 'Open &Bookmarked Files'), menu) |
|
629 self.exportersMenu = self.__initContextMenuExporters() |
|
630 menu.setTearOffEnabled(True) |
|
631 |
|
632 menu.addAction(self.newAct) |
|
633 menu.addAction(self.openAct) |
|
634 self.menuRecentAct = menu.addMenu(self.recentMenu) |
|
635 menu.addMenu(self.bookmarkedMenu) |
|
636 menu.addSeparator() |
|
637 menu.addAction(self.closeAct) |
|
638 menu.addAction(self.closeAllAct) |
|
639 menu.addSeparator() |
|
640 menu.addAction(self.findFileNameAct) |
|
641 menu.addSeparator() |
|
642 menu.addAction(self.saveAct) |
|
643 menu.addAction(self.saveAsAct) |
|
644 menu.addAction(self.saveAllAct) |
|
645 menu.addAction(self.saveToProjectAct) |
|
646 self.exportersMenuAct = menu.addMenu(self.exportersMenu) |
|
647 menu.addSeparator() |
|
648 menu.addAction(self.printPreviewAct) |
|
649 menu.addAction(self.printAct) |
|
650 |
|
651 self.connect(self.recentMenu, SIGNAL('aboutToShow()'), |
|
652 self.__showRecentMenu) |
|
653 self.connect(self.recentMenu, SIGNAL('triggered(QAction *)'), |
|
654 self.__openSourceFile) |
|
655 self.connect(self.bookmarkedMenu, SIGNAL('aboutToShow()'), |
|
656 self.__showBookmarkedMenu) |
|
657 self.connect(self.bookmarkedMenu, SIGNAL('triggered(QAction *)'), |
|
658 self.__openSourceFile) |
|
659 self.connect(menu, SIGNAL('aboutToShow()'), self.__showFileMenu) |
|
660 |
|
661 self.exportersMenuAct.setEnabled(False) |
|
662 |
|
663 return menu |
|
664 |
|
665 def initFileToolbar(self, toolbarManager): |
|
666 """ |
|
667 Public method to create the File toolbar. |
|
668 |
|
669 @param toolbarManager reference to a toolbar manager object (E4ToolBarManager) |
|
670 @return the generated toolbar |
|
671 """ |
|
672 tb = QToolBar(QApplication.translate('ViewManager', 'File'), self.ui) |
|
673 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
674 tb.setObjectName("FileToolbar") |
|
675 tb.setToolTip(QApplication.translate('ViewManager', 'File')) |
|
676 |
|
677 tb.addAction(self.newAct) |
|
678 tb.addAction(self.openAct) |
|
679 tb.addAction(self.closeAct) |
|
680 tb.addSeparator() |
|
681 tb.addAction(self.saveAct) |
|
682 tb.addAction(self.saveAsAct) |
|
683 tb.addAction(self.saveAllAct) |
|
684 tb.addAction(self.saveToProjectAct) |
|
685 tb.addSeparator() |
|
686 tb.addAction(self.printPreviewAct) |
|
687 tb.addAction(self.printAct) |
|
688 |
|
689 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
690 |
|
691 return tb |
|
692 |
|
693 def __initContextMenuExporters(self): |
|
694 """ |
|
695 Private method used to setup the Exporters sub menu. |
|
696 """ |
|
697 menu = QMenu(QApplication.translate('ViewManager', "Export as")) |
|
698 |
|
699 supportedExporters = QScintilla.Exporters.getSupportedFormats() |
|
700 exporters = supportedExporters.keys() |
|
701 exporters.sort() |
|
702 for exporter in exporters: |
|
703 act = menu.addAction(supportedExporters[exporter]) |
|
704 act.setData(QVariant(exporter)) |
|
705 |
|
706 self.connect(menu, SIGNAL('triggered(QAction *)'), self.__exportMenuTriggered) |
|
707 |
|
708 return menu |
|
709 |
|
710 ################################################################## |
|
711 ## Initialize the edit related actions, edit menu and toolbar |
|
712 ################################################################## |
|
713 |
|
714 def __initEditActions(self): |
|
715 """ |
|
716 Private method defining the user interface actions for the edit commands. |
|
717 """ |
|
718 self.editActGrp = createActionGroup(self) |
|
719 |
|
720 self.undoAct = E4Action(QApplication.translate('ViewManager', 'Undo'), |
|
721 UI.PixmapCache.getIcon("editUndo.png"), |
|
722 QApplication.translate('ViewManager', '&Undo'), |
|
723 QKeySequence(QApplication.translate('ViewManager', |
|
724 "Ctrl+Z", "Edit|Undo")), |
|
725 QKeySequence(QApplication.translate('ViewManager', |
|
726 "Alt+Backspace", "Edit|Undo")), |
|
727 self.editActGrp, 'vm_edit_undo') |
|
728 self.undoAct.setStatusTip(QApplication.translate('ViewManager', |
|
729 'Undo the last change')) |
|
730 self.undoAct.setWhatsThis(QApplication.translate('ViewManager', |
|
731 """<b>Undo</b>""" |
|
732 """<p>Undo the last change done in the current editor.</p>""" |
|
733 )) |
|
734 self.connect(self.undoAct, SIGNAL('triggered()'), self.__editUndo) |
|
735 self.editActions.append(self.undoAct) |
|
736 |
|
737 self.redoAct = E4Action(QApplication.translate('ViewManager', 'Redo'), |
|
738 UI.PixmapCache.getIcon("editRedo.png"), |
|
739 QApplication.translate('ViewManager', '&Redo'), |
|
740 QKeySequence(QApplication.translate('ViewManager', |
|
741 "Ctrl+Shift+Z", "Edit|Redo")), |
|
742 0, self.editActGrp, 'vm_edit_redo') |
|
743 self.redoAct.setStatusTip(QApplication.translate('ViewManager', |
|
744 'Redo the last change')) |
|
745 self.redoAct.setWhatsThis(QApplication.translate('ViewManager', |
|
746 """<b>Redo</b>""" |
|
747 """<p>Redo the last change done in the current editor.</p>""" |
|
748 )) |
|
749 self.connect(self.redoAct, SIGNAL('triggered()'), self.__editRedo) |
|
750 self.editActions.append(self.redoAct) |
|
751 |
|
752 self.revertAct = E4Action(QApplication.translate('ViewManager', |
|
753 'Revert to last saved state'), |
|
754 QApplication.translate('ViewManager', 'Re&vert to last saved state'), |
|
755 QKeySequence(QApplication.translate('ViewManager', |
|
756 "Ctrl+Y", "Edit|Revert")), |
|
757 0, |
|
758 self.editActGrp, 'vm_edit_revert') |
|
759 self.revertAct.setStatusTip(QApplication.translate('ViewManager', |
|
760 'Revert to last saved state')) |
|
761 self.revertAct.setWhatsThis(QApplication.translate('ViewManager', |
|
762 """<b>Revert to last saved state</b>""" |
|
763 """<p>Undo all changes up to the last saved state""" |
|
764 """ of the current editor.</p>""" |
|
765 )) |
|
766 self.connect(self.revertAct, SIGNAL('triggered()'), self.__editRevert) |
|
767 self.editActions.append(self.revertAct) |
|
768 |
|
769 self.copyActGrp = createActionGroup(self.editActGrp) |
|
770 |
|
771 self.cutAct = E4Action(QApplication.translate('ViewManager', 'Cut'), |
|
772 UI.PixmapCache.getIcon("editCut.png"), |
|
773 QApplication.translate('ViewManager', 'Cu&t'), |
|
774 QKeySequence(QApplication.translate('ViewManager', "Ctrl+X", "Edit|Cut")), |
|
775 QKeySequence(QApplication.translate('ViewManager', |
|
776 "Shift+Del", "Edit|Cut")), |
|
777 self.copyActGrp, 'vm_edit_cut') |
|
778 self.cutAct.setStatusTip(QApplication.translate('ViewManager', |
|
779 'Cut the selection')) |
|
780 self.cutAct.setWhatsThis(QApplication.translate('ViewManager', |
|
781 """<b>Cut</b>""" |
|
782 """<p>Cut the selected text of the current editor to the clipboard.</p>""" |
|
783 )) |
|
784 self.connect(self.cutAct, SIGNAL('triggered()'), self.__editCut) |
|
785 self.editActions.append(self.cutAct) |
|
786 |
|
787 self.copyAct = E4Action(QApplication.translate('ViewManager', 'Copy'), |
|
788 UI.PixmapCache.getIcon("editCopy.png"), |
|
789 QApplication.translate('ViewManager', '&Copy'), |
|
790 QKeySequence(QApplication.translate('ViewManager', |
|
791 "Ctrl+C", "Edit|Copy")), |
|
792 QKeySequence(QApplication.translate('ViewManager', |
|
793 "Ctrl+Ins", "Edit|Copy")), |
|
794 self.copyActGrp, 'vm_edit_copy') |
|
795 self.copyAct.setStatusTip(QApplication.translate('ViewManager', |
|
796 'Copy the selection')) |
|
797 self.copyAct.setWhatsThis(QApplication.translate('ViewManager', |
|
798 """<b>Copy</b>""" |
|
799 """<p>Copy the selected text of the current editor to the clipboard.</p>""" |
|
800 )) |
|
801 self.connect(self.copyAct, SIGNAL('triggered()'), self.__editCopy) |
|
802 self.editActions.append(self.copyAct) |
|
803 |
|
804 self.pasteAct = E4Action(QApplication.translate('ViewManager', 'Paste'), |
|
805 UI.PixmapCache.getIcon("editPaste.png"), |
|
806 QApplication.translate('ViewManager', '&Paste'), |
|
807 QKeySequence(QApplication.translate('ViewManager', |
|
808 "Ctrl+V", "Edit|Paste")), |
|
809 QKeySequence(QApplication.translate('ViewManager', |
|
810 "Shift+Ins", "Edit|Paste")), |
|
811 self.copyActGrp, 'vm_edit_paste') |
|
812 self.pasteAct.setStatusTip(QApplication.translate('ViewManager', |
|
813 'Paste the last cut/copied text')) |
|
814 self.pasteAct.setWhatsThis(QApplication.translate('ViewManager', |
|
815 """<b>Paste</b>""" |
|
816 """<p>Paste the last cut/copied text from the clipboard to""" |
|
817 """ the current editor.</p>""" |
|
818 )) |
|
819 self.connect(self.pasteAct, SIGNAL('triggered()'), self.__editPaste) |
|
820 self.editActions.append(self.pasteAct) |
|
821 |
|
822 self.deleteAct = E4Action(QApplication.translate('ViewManager', 'Clear'), |
|
823 UI.PixmapCache.getIcon("editDelete.png"), |
|
824 QApplication.translate('ViewManager', 'Cl&ear'), |
|
825 QKeySequence(QApplication.translate('ViewManager', |
|
826 "Alt+Shift+C", "Edit|Clear")), |
|
827 0, |
|
828 self.copyActGrp, 'vm_edit_clear') |
|
829 self.deleteAct.setStatusTip(QApplication.translate('ViewManager', |
|
830 'Clear all text')) |
|
831 self.deleteAct.setWhatsThis(QApplication.translate('ViewManager', |
|
832 """<b>Clear</b>""" |
|
833 """<p>Delete all text of the current editor.</p>""" |
|
834 )) |
|
835 self.connect(self.deleteAct, SIGNAL('triggered()'), self.__editDelete) |
|
836 self.editActions.append(self.deleteAct) |
|
837 |
|
838 self.indentAct = E4Action(QApplication.translate('ViewManager', 'Indent'), |
|
839 UI.PixmapCache.getIcon("editIndent.png"), |
|
840 QApplication.translate('ViewManager', '&Indent'), |
|
841 QKeySequence(QApplication.translate('ViewManager', |
|
842 "Ctrl+I", "Edit|Indent")), |
|
843 0, |
|
844 self.editActGrp, 'vm_edit_indent') |
|
845 self.indentAct.setStatusTip(QApplication.translate('ViewManager', 'Indent line')) |
|
846 self.indentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
847 """<b>Indent</b>""" |
|
848 """<p>Indents the current line or the lines of the""" |
|
849 """ selection by one level.</p>""" |
|
850 )) |
|
851 self.connect(self.indentAct, SIGNAL('triggered()'), self.__editIndent) |
|
852 self.editActions.append(self.indentAct) |
|
853 |
|
854 self.unindentAct = E4Action(QApplication.translate('ViewManager', 'Unindent'), |
|
855 UI.PixmapCache.getIcon("editUnindent.png"), |
|
856 QApplication.translate('ViewManager', 'U&nindent'), |
|
857 QKeySequence(QApplication.translate('ViewManager', |
|
858 "Ctrl+Shift+I", "Edit|Unindent")), |
|
859 0, |
|
860 self.editActGrp, 'vm_edit_unindent') |
|
861 self.unindentAct.setStatusTip(QApplication.translate('ViewManager', |
|
862 'Unindent line')) |
|
863 self.unindentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
864 """<b>Unindent</b>""" |
|
865 """<p>Unindents the current line or the lines of the""" |
|
866 """ selection by one level.</p>""" |
|
867 )) |
|
868 self.connect(self.unindentAct, SIGNAL('triggered()'), self.__editUnindent) |
|
869 self.editActions.append(self.unindentAct) |
|
870 |
|
871 self.smartIndentAct = E4Action(QApplication.translate('ViewManager', |
|
872 'Smart indent'), |
|
873 UI.PixmapCache.getIcon("editSmartIndent.png"), |
|
874 QApplication.translate('ViewManager', 'Smart indent'), |
|
875 QKeySequence(QApplication.translate('ViewManager', |
|
876 "Ctrl+Alt+I", "Edit|Smart indent")), |
|
877 0, |
|
878 self.editActGrp, 'vm_edit_smart_indent') |
|
879 self.smartIndentAct.setStatusTip(QApplication.translate('ViewManager', |
|
880 'Smart indent Line or Selection')) |
|
881 self.smartIndentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
882 """<b>Smart indent</b>""" |
|
883 """<p>Indents the current line or the lines of the""" |
|
884 """ current selection smartly.</p>""" |
|
885 )) |
|
886 self.connect(self.smartIndentAct, SIGNAL('triggered()'), self.__editSmartIndent) |
|
887 self.editActions.append(self.smartIndentAct) |
|
888 |
|
889 self.commentAct = E4Action(QApplication.translate('ViewManager', 'Comment'), |
|
890 UI.PixmapCache.getIcon("editComment.png"), |
|
891 QApplication.translate('ViewManager', 'C&omment'), |
|
892 QKeySequence(QApplication.translate('ViewManager', |
|
893 "Ctrl+M", "Edit|Comment")), |
|
894 0, |
|
895 self.editActGrp, 'vm_edit_comment') |
|
896 self.commentAct.setStatusTip(QApplication.translate('ViewManager', |
|
897 'Comment Line or Selection')) |
|
898 self.commentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
899 """<b>Comment</b>""" |
|
900 """<p>Comments the current line or the lines of the""" |
|
901 """ current selection.</p>""" |
|
902 )) |
|
903 self.connect(self.commentAct, SIGNAL('triggered()'), self.__editComment) |
|
904 self.editActions.append(self.commentAct) |
|
905 |
|
906 self.uncommentAct = E4Action(QApplication.translate('ViewManager', 'Uncomment'), |
|
907 UI.PixmapCache.getIcon("editUncomment.png"), |
|
908 QApplication.translate('ViewManager', 'Unco&mment'), |
|
909 QKeySequence(QApplication.translate('ViewManager', |
|
910 "Alt+Ctrl+M", "Edit|Uncomment")), |
|
911 0, |
|
912 self.editActGrp, 'vm_edit_uncomment') |
|
913 self.uncommentAct.setStatusTip(QApplication.translate('ViewManager', |
|
914 'Uncomment Line or Selection')) |
|
915 self.uncommentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
916 """<b>Uncomment</b>""" |
|
917 """<p>Uncomments the current line or the lines of the""" |
|
918 """ current selection.</p>""" |
|
919 )) |
|
920 self.connect(self.uncommentAct, SIGNAL('triggered()'), self.__editUncomment) |
|
921 self.editActions.append(self.uncommentAct) |
|
922 |
|
923 self.streamCommentAct = E4Action(QApplication.translate('ViewManager', |
|
924 'Stream Comment'), |
|
925 QApplication.translate('ViewManager', 'Stream Comment'), |
|
926 0, 0, self.editActGrp, 'vm_edit_stream_comment') |
|
927 self.streamCommentAct.setStatusTip(QApplication.translate('ViewManager', |
|
928 'Stream Comment Line or Selection')) |
|
929 self.streamCommentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
930 """<b>Stream Comment</b>""" |
|
931 """<p>Stream comments the current line or the current selection.</p>""" |
|
932 )) |
|
933 self.connect(self.streamCommentAct, SIGNAL('triggered()'), |
|
934 self.__editStreamComment) |
|
935 self.editActions.append(self.streamCommentAct) |
|
936 |
|
937 self.boxCommentAct = E4Action(QApplication.translate('ViewManager', |
|
938 'Box Comment'), |
|
939 QApplication.translate('ViewManager', 'Box Comment'), |
|
940 0, 0, self.editActGrp, 'vm_edit_box_comment') |
|
941 self.boxCommentAct.setStatusTip(QApplication.translate('ViewManager', |
|
942 'Box Comment Line or Selection')) |
|
943 self.boxCommentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
944 """<b>Box Comment</b>""" |
|
945 """<p>Box comments the current line or the lines of the""" |
|
946 """ current selection.</p>""" |
|
947 )) |
|
948 self.connect(self.boxCommentAct, SIGNAL('triggered()'), self.__editBoxComment) |
|
949 self.editActions.append(self.boxCommentAct) |
|
950 |
|
951 self.selectBraceAct = E4Action(QApplication.translate('ViewManager', |
|
952 'Select to brace'), |
|
953 QApplication.translate('ViewManager', 'Select to &brace'), |
|
954 QKeySequence(QApplication.translate('ViewManager', |
|
955 "Ctrl+E", "Edit|Select to brace")), |
|
956 0, |
|
957 self.editActGrp, 'vm_edit_select_to_brace') |
|
958 self.selectBraceAct.setStatusTip(QApplication.translate('ViewManager', |
|
959 'Select text to the matching brace')) |
|
960 self.selectBraceAct.setWhatsThis(QApplication.translate('ViewManager', |
|
961 """<b>Select to brace</b>""" |
|
962 """<p>Select text of the current editor to the matching brace.</p>""" |
|
963 )) |
|
964 self.connect(self.selectBraceAct, SIGNAL('triggered()'), self.__editSelectBrace) |
|
965 self.editActions.append(self.selectBraceAct) |
|
966 |
|
967 self.selectAllAct = E4Action(QApplication.translate('ViewManager', 'Select all'), |
|
968 QApplication.translate('ViewManager', '&Select all'), |
|
969 QKeySequence(QApplication.translate('ViewManager', |
|
970 "Ctrl+A", "Edit|Select all")), |
|
971 0, |
|
972 self.editActGrp, 'vm_edit_select_all') |
|
973 self.selectAllAct.setStatusTip(QApplication.translate('ViewManager', |
|
974 'Select all text')) |
|
975 self.selectAllAct.setWhatsThis(QApplication.translate('ViewManager', |
|
976 """<b>Select All</b>""" |
|
977 """<p>Select all text of the current editor.</p>""" |
|
978 )) |
|
979 self.connect(self.selectAllAct, SIGNAL('triggered()'), self.__editSelectAll) |
|
980 self.editActions.append(self.selectAllAct) |
|
981 |
|
982 self.deselectAllAct = E4Action(QApplication.translate('ViewManager', |
|
983 'Deselect all'), |
|
984 QApplication.translate('ViewManager', '&Deselect all'), |
|
985 QKeySequence(QApplication.translate('ViewManager', |
|
986 "Alt+Ctrl+A", "Edit|Deselect all")), |
|
987 0, |
|
988 self.editActGrp, 'vm_edit_deselect_all') |
|
989 self.deselectAllAct.setStatusTip(QApplication.translate('ViewManager', |
|
990 'Deselect all text')) |
|
991 self.deselectAllAct.setWhatsThis(QApplication.translate('ViewManager', |
|
992 """<b>Deselect All</b>""" |
|
993 """<p>Deselect all text of the current editor.</p>""" |
|
994 )) |
|
995 self.connect(self.deselectAllAct, SIGNAL('triggered()'), self.__editDeselectAll) |
|
996 self.editActions.append(self.deselectAllAct) |
|
997 |
|
998 self.convertEOLAct = E4Action(QApplication.translate('ViewManager', |
|
999 'Convert Line End Characters'), |
|
1000 QApplication.translate('ViewManager', 'Convert &Line End Characters'), |
|
1001 0, 0, self.editActGrp, 'vm_edit_convert_eol') |
|
1002 self.convertEOLAct.setStatusTip(QApplication.translate('ViewManager', |
|
1003 'Convert Line End Characters')) |
|
1004 self.convertEOLAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1005 """<b>Convert Line End Characters</b>""" |
|
1006 """<p>Convert the line end characters to the currently set type.</p>""" |
|
1007 )) |
|
1008 self.connect(self.convertEOLAct, SIGNAL('triggered()'), self.__convertEOL) |
|
1009 self.editActions.append(self.convertEOLAct) |
|
1010 |
|
1011 self.shortenEmptyAct = E4Action(QApplication.translate('ViewManager', |
|
1012 'Shorten empty lines'), |
|
1013 QApplication.translate('ViewManager', 'Shorten empty lines'), |
|
1014 0, 0, self.editActGrp, 'vm_edit_shorten_empty_lines') |
|
1015 self.shortenEmptyAct.setStatusTip(QApplication.translate('ViewManager', |
|
1016 'Shorten empty lines')) |
|
1017 self.shortenEmptyAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1018 """<b>Shorten empty lines</b>""" |
|
1019 """<p>Shorten lines consisting solely of whitespace characters.</p>""" |
|
1020 )) |
|
1021 self.connect(self.shortenEmptyAct, SIGNAL('triggered()'), |
|
1022 self.__shortenEmptyLines) |
|
1023 self.editActions.append(self.shortenEmptyAct) |
|
1024 |
|
1025 self.autoCompleteAct = E4Action(QApplication.translate('ViewManager', |
|
1026 'Autocomplete'), |
|
1027 QApplication.translate('ViewManager', '&Autocomplete'), |
|
1028 QKeySequence(QApplication.translate('ViewManager', |
|
1029 "Ctrl+Space", "Edit|Autocomplete")), |
|
1030 0, |
|
1031 self.editActGrp, 'vm_edit_autocomplete') |
|
1032 self.autoCompleteAct.setStatusTip(QApplication.translate('ViewManager', |
|
1033 'Autocomplete current word')) |
|
1034 self.autoCompleteAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1035 """<b>Autocomplete</b>""" |
|
1036 """<p>Performs an autocompletion of the word containing the cursor.</p>""" |
|
1037 )) |
|
1038 self.connect(self.autoCompleteAct, SIGNAL('triggered()'), self.__editAutoComplete) |
|
1039 self.editActions.append(self.autoCompleteAct) |
|
1040 |
|
1041 self.autoCompleteFromDocAct = E4Action(QApplication.translate('ViewManager', |
|
1042 'Autocomplete from Document'), |
|
1043 QApplication.translate('ViewManager', 'Autocomplete from Document'), |
|
1044 QKeySequence(QApplication.translate('ViewManager', "Ctrl+Shift+Space", |
|
1045 "Edit|Autocomplete from Document")), |
|
1046 0, self.editActGrp, 'vm_edit_autocomplete_from_document') |
|
1047 self.autoCompleteFromDocAct.setStatusTip(QApplication.translate('ViewManager', |
|
1048 'Autocomplete current word from Document')) |
|
1049 self.autoCompleteFromDocAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1050 """<b>Autocomplete from Document</b>""" |
|
1051 """<p>Performs an autocompletion from document of the word""" |
|
1052 """ containing the cursor.</p>""" |
|
1053 )) |
|
1054 self.connect(self.autoCompleteFromDocAct, SIGNAL('triggered()'), |
|
1055 self.__editAutoCompleteFromDoc) |
|
1056 self.editActions.append(self.autoCompleteFromDocAct) |
|
1057 |
|
1058 self.autoCompleteFromAPIsAct = E4Action(QApplication.translate('ViewManager', |
|
1059 'Autocomplete from APIs'), |
|
1060 QApplication.translate('ViewManager', 'Autocomplete from APIs'), |
|
1061 QKeySequence(QApplication.translate('ViewManager', "Ctrl+Alt+Space", |
|
1062 "Edit|Autocomplete from APIs")), |
|
1063 0, self.editActGrp, 'vm_edit_autocomplete_from_api') |
|
1064 self.autoCompleteFromAPIsAct.setStatusTip(QApplication.translate('ViewManager', |
|
1065 'Autocomplete current word from APIs')) |
|
1066 self.autoCompleteFromAPIsAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1067 """<b>Autocomplete from APIs</b>""" |
|
1068 """<p>Performs an autocompletion from APIs of the word containing""" |
|
1069 """ the cursor.</p>""" |
|
1070 )) |
|
1071 self.connect(self.autoCompleteFromAPIsAct, SIGNAL('triggered()'), |
|
1072 self.__editAutoCompleteFromAPIs) |
|
1073 self.editActions.append(self.autoCompleteFromAPIsAct) |
|
1074 |
|
1075 self.autoCompleteFromAllAct = E4Action(\ |
|
1076 QApplication.translate('ViewManager', |
|
1077 'Autocomplete from Document and APIs'), |
|
1078 QApplication.translate('ViewManager', |
|
1079 'Autocomplete from Document and APIs'), |
|
1080 QKeySequence(QApplication.translate('ViewManager', "Alt+Shift+Space", |
|
1081 "Edit|Autocomplete from Document and APIs")), |
|
1082 0, self.editActGrp, 'vm_edit_autocomplete_from_all') |
|
1083 self.autoCompleteFromAllAct.setStatusTip(QApplication.translate('ViewManager', |
|
1084 'Autocomplete current word from Document and APIs')) |
|
1085 self.autoCompleteFromAllAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1086 """<b>Autocomplete from Document and APIs</b>""" |
|
1087 """<p>Performs an autocompletion from document and APIs""" |
|
1088 """ of the word containing the cursor.</p>""" |
|
1089 )) |
|
1090 self.connect(self.autoCompleteFromAllAct, SIGNAL('triggered()'), |
|
1091 self.__editAutoCompleteFromAll) |
|
1092 self.editActions.append(self.autoCompleteFromAllAct) |
|
1093 |
|
1094 self.calltipsAct = E4Action(QApplication.translate('ViewManager', |
|
1095 'Calltip'), |
|
1096 QApplication.translate('ViewManager', '&Calltip'), |
|
1097 QKeySequence(QApplication.translate('ViewManager', |
|
1098 "Alt+Space", "Edit|Calltip")), |
|
1099 0, |
|
1100 self.editActGrp, 'vm_edit_calltip') |
|
1101 self.calltipsAct.setStatusTip(QApplication.translate('ViewManager', |
|
1102 'Show Calltips')) |
|
1103 self.calltipsAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1104 """<b>Calltip</b>""" |
|
1105 """<p>Show calltips based on the characters immediately to the""" |
|
1106 """ left of the cursor.</p>""" |
|
1107 )) |
|
1108 self.connect(self.calltipsAct, SIGNAL('triggered()'), self.__editShowCallTips) |
|
1109 self.editActions.append(self.calltipsAct) |
|
1110 |
|
1111 self.editActGrp.setEnabled(False) |
|
1112 self.copyActGrp.setEnabled(False) |
|
1113 |
|
1114 #################################################################### |
|
1115 ## Below follow the actions for qscintilla standard commands. |
|
1116 #################################################################### |
|
1117 |
|
1118 self.esm = QSignalMapper(self) |
|
1119 self.connect(self.esm, SIGNAL('mapped(int)'), self.__editorCommand) |
|
1120 |
|
1121 self.editorActGrp = createActionGroup(self.editActGrp) |
|
1122 |
|
1123 act = E4Action(QApplication.translate('ViewManager', 'Move left one character'), |
|
1124 QApplication.translate('ViewManager', 'Move left one character'), |
|
1125 QKeySequence(QApplication.translate('ViewManager', 'Left')), 0, |
|
1126 self.editorActGrp, 'vm_edit_move_left_char') |
|
1127 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) |
|
1128 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1129 self.editActions.append(act) |
|
1130 |
|
1131 act = E4Action(QApplication.translate('ViewManager', 'Move right one character'), |
|
1132 QApplication.translate('ViewManager', 'Move right one character'), |
|
1133 QKeySequence(QApplication.translate('ViewManager', 'Right')), 0, |
|
1134 self.editorActGrp, 'vm_edit_move_right_char') |
|
1135 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) |
|
1136 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1137 self.editActions.append(act) |
|
1138 |
|
1139 act = E4Action(QApplication.translate('ViewManager', 'Move up one line'), |
|
1140 QApplication.translate('ViewManager', 'Move up one line'), |
|
1141 QKeySequence(QApplication.translate('ViewManager', 'Up')), 0, |
|
1142 self.editorActGrp, 'vm_edit_move_up_line') |
|
1143 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) |
|
1144 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1145 self.editActions.append(act) |
|
1146 |
|
1147 act = E4Action(QApplication.translate('ViewManager', 'Move down one line'), |
|
1148 QApplication.translate('ViewManager', 'Move down one line'), |
|
1149 QKeySequence(QApplication.translate('ViewManager', 'Down')), 0, |
|
1150 self.editorActGrp, 'vm_edit_move_down_line') |
|
1151 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) |
|
1152 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1153 self.editActions.append(act) |
|
1154 |
|
1155 act = E4Action(QApplication.translate('ViewManager', 'Move left one word part'), |
|
1156 QApplication.translate('ViewManager', 'Move left one word part'), |
|
1157 QKeySequence(QApplication.translate('ViewManager', 'Alt+Left')), 0, |
|
1158 self.editorActGrp, 'vm_edit_move_left_word_part') |
|
1159 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFT) |
|
1160 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1161 self.editActions.append(act) |
|
1162 |
|
1163 act = E4Action(QApplication.translate('ViewManager', 'Move right one word part'), |
|
1164 QApplication.translate('ViewManager', 'Move right one word part'), |
|
1165 QKeySequence(QApplication.translate('ViewManager', 'Alt+Right')), 0, |
|
1166 self.editorActGrp, 'vm_edit_move_right_word_part') |
|
1167 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHT) |
|
1168 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1169 self.editActions.append(act) |
|
1170 |
|
1171 act = E4Action(QApplication.translate('ViewManager', 'Move left one word'), |
|
1172 QApplication.translate('ViewManager', 'Move left one word'), |
|
1173 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Left')), 0, |
|
1174 self.editorActGrp, 'vm_edit_move_left_word') |
|
1175 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFT) |
|
1176 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1177 self.editActions.append(act) |
|
1178 |
|
1179 act = E4Action(QApplication.translate('ViewManager', 'Move right one word'), |
|
1180 QApplication.translate('ViewManager', 'Move right one word'), |
|
1181 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Right')), |
|
1182 0, |
|
1183 self.editorActGrp, 'vm_edit_move_right_word') |
|
1184 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) |
|
1185 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1186 self.editActions.append(act) |
|
1187 |
|
1188 act = E4Action(QApplication.translate('ViewManager', |
|
1189 'Move to first visible character in line'), |
|
1190 QApplication.translate('ViewManager', |
|
1191 'Move to first visible character in line'), |
|
1192 QKeySequence(QApplication.translate('ViewManager', 'Home')), 0, |
|
1193 self.editorActGrp, 'vm_edit_move_first_visible_char') |
|
1194 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) |
|
1195 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1196 self.editActions.append(act) |
|
1197 |
|
1198 act = E4Action(QApplication.translate('ViewManager', |
|
1199 'Move to start of displayed line'), |
|
1200 QApplication.translate('ViewManager', |
|
1201 'Move to start of displayed line'), |
|
1202 QKeySequence(QApplication.translate('ViewManager', 'Alt+Home')), 0, |
|
1203 self.editorActGrp, 'vm_edit_move_start_line') |
|
1204 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAY) |
|
1205 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1206 self.editActions.append(act) |
|
1207 |
|
1208 act = E4Action(QApplication.translate('ViewManager', 'Move to end of line'), |
|
1209 QApplication.translate('ViewManager', 'Move to end of line'), |
|
1210 QKeySequence(QApplication.translate('ViewManager', 'End')), 0, |
|
1211 self.editorActGrp, 'vm_edit_move_end_line') |
|
1212 self.esm.setMapping(act, QsciScintilla.SCI_LINEEND) |
|
1213 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1214 self.editActions.append(act) |
|
1215 |
|
1216 act = E4Action(QApplication.translate('ViewManager', 'Scroll view down one line'), |
|
1217 QApplication.translate('ViewManager', 'Scroll view down one line'), |
|
1218 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Down')), 0, |
|
1219 self.editorActGrp, 'vm_edit_scroll_down_line') |
|
1220 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLDOWN) |
|
1221 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1222 self.editActions.append(act) |
|
1223 |
|
1224 act = E4Action(QApplication.translate('ViewManager', 'Scroll view up one line'), |
|
1225 QApplication.translate('ViewManager', 'Scroll view up one line'), |
|
1226 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Up')), 0, |
|
1227 self.editorActGrp, 'vm_edit_scroll_up_line') |
|
1228 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLUP) |
|
1229 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1230 self.editActions.append(act) |
|
1231 |
|
1232 act = E4Action(QApplication.translate('ViewManager', 'Move up one paragraph'), |
|
1233 QApplication.translate('ViewManager', 'Move up one paragraph'), |
|
1234 QKeySequence(QApplication.translate('ViewManager', 'Alt+Up')), 0, |
|
1235 self.editorActGrp, 'vm_edit_move_up_para') |
|
1236 self.esm.setMapping(act, QsciScintilla.SCI_PARAUP) |
|
1237 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1238 self.editActions.append(act) |
|
1239 |
|
1240 act = E4Action(QApplication.translate('ViewManager', 'Move down one paragraph'), |
|
1241 QApplication.translate('ViewManager', 'Move down one paragraph'), |
|
1242 QKeySequence(QApplication.translate('ViewManager', 'Alt+Down')), 0, |
|
1243 self.editorActGrp, 'vm_edit_move_down_para') |
|
1244 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWN) |
|
1245 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1246 self.editActions.append(act) |
|
1247 |
|
1248 act = E4Action(QApplication.translate('ViewManager', 'Move up one page'), |
|
1249 QApplication.translate('ViewManager', 'Move up one page'), |
|
1250 QKeySequence(QApplication.translate('ViewManager', 'PgUp')), 0, |
|
1251 self.editorActGrp, 'vm_edit_move_up_page') |
|
1252 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUP) |
|
1253 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1254 self.editActions.append(act) |
|
1255 |
|
1256 act = E4Action(QApplication.translate('ViewManager', 'Move down one page'), |
|
1257 QApplication.translate('ViewManager', 'Move down one page'), |
|
1258 QKeySequence(QApplication.translate('ViewManager', 'PgDown')), 0, |
|
1259 self.editorActGrp, 'vm_edit_move_down_page') |
|
1260 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) |
|
1261 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1262 self.editActions.append(act) |
|
1263 |
|
1264 act = E4Action(QApplication.translate('ViewManager', 'Move to start of text'), |
|
1265 QApplication.translate('ViewManager', 'Move to start of text'), |
|
1266 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Home')), 0, |
|
1267 self.editorActGrp, 'vm_edit_move_start_text') |
|
1268 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTART) |
|
1269 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1270 self.editActions.append(act) |
|
1271 |
|
1272 act = E4Action(QApplication.translate('ViewManager', 'Move to end of text'), |
|
1273 QApplication.translate('ViewManager', 'Move to end of text'), |
|
1274 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+End')), 0, |
|
1275 self.editorActGrp, 'vm_edit_move_end_text') |
|
1276 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTEND) |
|
1277 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1278 self.editActions.append(act) |
|
1279 |
|
1280 act = E4Action(QApplication.translate('ViewManager', 'Indent one level'), |
|
1281 QApplication.translate('ViewManager', 'Indent one level'), |
|
1282 QKeySequence(QApplication.translate('ViewManager', 'Tab')), 0, |
|
1283 self.editorActGrp, 'vm_edit_indent_one_level') |
|
1284 self.esm.setMapping(act, QsciScintilla.SCI_TAB) |
|
1285 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1286 self.editActions.append(act) |
|
1287 |
|
1288 act = E4Action(QApplication.translate('ViewManager', 'Unindent one level'), |
|
1289 QApplication.translate('ViewManager', 'Unindent one level'), |
|
1290 QKeySequence(QApplication.translate('ViewManager', 'Shift+Tab')), 0, |
|
1291 self.editorActGrp, 'vm_edit_unindent_one_level') |
|
1292 self.esm.setMapping(act, QsciScintilla.SCI_BACKTAB) |
|
1293 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1294 self.editActions.append(act) |
|
1295 |
|
1296 act = E4Action(QApplication.translate('ViewManager', |
|
1297 'Extend selection left one character'), |
|
1298 QApplication.translate('ViewManager', |
|
1299 'Extend selection left one character'), |
|
1300 QKeySequence(QApplication.translate('ViewManager', 'Shift+Left')), |
|
1301 0, |
|
1302 self.editorActGrp, 'vm_edit_extend_selection_left_char') |
|
1303 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) |
|
1304 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1305 self.editActions.append(act) |
|
1306 |
|
1307 act = E4Action(QApplication.translate('ViewManager', |
|
1308 'Extend selection right one character'), |
|
1309 QApplication.translate('ViewManager', |
|
1310 'Extend selection right one character'), |
|
1311 QKeySequence(QApplication.translate('ViewManager', 'Shift+Right')), |
|
1312 0, |
|
1313 self.editorActGrp, 'vm_edit_extend_selection_right_char') |
|
1314 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) |
|
1315 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1316 self.editActions.append(act) |
|
1317 |
|
1318 act = E4Action(QApplication.translate('ViewManager', |
|
1319 'Extend selection up one line'), |
|
1320 QApplication.translate('ViewManager', |
|
1321 'Extend selection up one line'), |
|
1322 QKeySequence(QApplication.translate('ViewManager', 'Shift+Up')), 0, |
|
1323 self.editorActGrp, 'vm_edit_extend_selection_up_line') |
|
1324 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPEXTEND) |
|
1325 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1326 self.editActions.append(act) |
|
1327 |
|
1328 act = E4Action(QApplication.translate('ViewManager', |
|
1329 'Extend selection down one line'), |
|
1330 QApplication.translate('ViewManager', |
|
1331 'Extend selection down one line'), |
|
1332 QKeySequence(QApplication.translate('ViewManager', 'Shift+Down')), |
|
1333 0, |
|
1334 self.editorActGrp, 'vm_edit_extend_selection_down_line') |
|
1335 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNEXTEND) |
|
1336 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1337 self.editActions.append(act) |
|
1338 |
|
1339 act = E4Action(QApplication.translate('ViewManager', |
|
1340 'Extend selection left one word part'), |
|
1341 QApplication.translate('ViewManager', |
|
1342 'Extend selection left one word part'), |
|
1343 QKeySequence(QApplication.translate('ViewManager', |
|
1344 'Alt+Shift+Left')), |
|
1345 0, |
|
1346 self.editorActGrp, 'vm_edit_extend_selection_left_word_part') |
|
1347 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFTEXTEND) |
|
1348 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1349 self.editActions.append(act) |
|
1350 |
|
1351 act = E4Action(QApplication.translate('ViewManager', |
|
1352 'Extend selection right one word part'), |
|
1353 QApplication.translate('ViewManager', |
|
1354 'Extend selection right one word part'), |
|
1355 QKeySequence(QApplication.translate('ViewManager', |
|
1356 'Alt+Shift+Right')), |
|
1357 0, |
|
1358 self.editorActGrp, 'vm_edit_extend_selection_right_word_part') |
|
1359 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHTEXTEND) |
|
1360 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1361 self.editActions.append(act) |
|
1362 |
|
1363 act = E4Action(QApplication.translate('ViewManager', |
|
1364 'Extend selection left one word'), |
|
1365 QApplication.translate('ViewManager', |
|
1366 'Extend selection left one word'), |
|
1367 QKeySequence(QApplication.translate('ViewManager', |
|
1368 'Ctrl+Shift+Left')), |
|
1369 0, |
|
1370 self.editorActGrp, 'vm_edit_extend_selection_left_word') |
|
1371 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEXTEND) |
|
1372 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1373 self.editActions.append(act) |
|
1374 |
|
1375 act = E4Action(QApplication.translate('ViewManager', |
|
1376 'Extend selection right one word'), |
|
1377 QApplication.translate('ViewManager', |
|
1378 'Extend selection right one word'), |
|
1379 QKeySequence(QApplication.translate('ViewManager', |
|
1380 'Ctrl+Shift+Right')), |
|
1381 0, |
|
1382 self.editorActGrp, 'vm_edit_extend_selection_right_word') |
|
1383 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEXTEND) |
|
1384 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1385 self.editActions.append(act) |
|
1386 |
|
1387 act = E4Action(QApplication.translate('ViewManager', |
|
1388 'Extend selection to first visible character in line'), |
|
1389 QApplication.translate('ViewManager', |
|
1390 'Extend selection to first visible character in line'), |
|
1391 QKeySequence(QApplication.translate('ViewManager', 'Shift+Home')), |
|
1392 0, |
|
1393 self.editorActGrp, 'vm_edit_extend_selection_first_visible_char') |
|
1394 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) |
|
1395 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1396 self.editActions.append(act) |
|
1397 |
|
1398 act = E4Action(QApplication.translate('ViewManager', |
|
1399 'Extend selection to start of line'), |
|
1400 QApplication.translate('ViewManager', |
|
1401 'Extend selection to start of line'), |
|
1402 QKeySequence(QApplication.translate('ViewManager', |
|
1403 'Alt+Shift+Home')), |
|
1404 0, |
|
1405 self.editorActGrp, 'vm_edit_extend_selection_start_line') |
|
1406 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAYEXTEND) |
|
1407 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1408 self.editActions.append(act) |
|
1409 |
|
1410 act = E4Action(QApplication.translate('ViewManager', |
|
1411 'Extend selection to end of line'), |
|
1412 QApplication.translate('ViewManager', |
|
1413 'Extend selection to end of line'), |
|
1414 QKeySequence(QApplication.translate('ViewManager', 'Shift+End')), 0, |
|
1415 self.editorActGrp, 'vm_edit_extend_selection_end_line') |
|
1416 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDEXTEND) |
|
1417 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1418 self.editActions.append(act) |
|
1419 |
|
1420 act = E4Action(QApplication.translate('ViewManager', |
|
1421 'Extend selection up one paragraph'), |
|
1422 QApplication.translate('ViewManager', |
|
1423 'Extend selection up one paragraph'), |
|
1424 QKeySequence(QApplication.translate('ViewManager', 'Alt+Shift+Up')), |
|
1425 0, |
|
1426 self.editorActGrp, 'vm_edit_extend_selection_up_para') |
|
1427 self.esm.setMapping(act, QsciScintilla.SCI_PARAUPEXTEND) |
|
1428 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1429 self.editActions.append(act) |
|
1430 |
|
1431 act = E4Action(QApplication.translate('ViewManager', |
|
1432 'Extend selection down one paragraph'), |
|
1433 QApplication.translate('ViewManager', |
|
1434 'Extend selection down one paragraph'), |
|
1435 QKeySequence(QApplication.translate('ViewManager', |
|
1436 'Alt+Shift+Down')), |
|
1437 0, |
|
1438 self.editorActGrp, 'vm_edit_extend_selection_down_para') |
|
1439 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWNEXTEND) |
|
1440 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1441 self.editActions.append(act) |
|
1442 |
|
1443 act = E4Action(QApplication.translate('ViewManager', |
|
1444 'Extend selection up one page'), |
|
1445 QApplication.translate('ViewManager', |
|
1446 'Extend selection up one page'), |
|
1447 QKeySequence(QApplication.translate('ViewManager', 'Shift+PgUp')), |
|
1448 0, |
|
1449 self.editorActGrp, 'vm_edit_extend_selection_up_page') |
|
1450 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPEXTEND) |
|
1451 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1452 self.editActions.append(act) |
|
1453 |
|
1454 act = E4Action(QApplication.translate('ViewManager', |
|
1455 'Extend selection down one page'), |
|
1456 QApplication.translate('ViewManager', |
|
1457 'Extend selection down one page'), |
|
1458 QKeySequence(QApplication.translate('ViewManager', 'Shift+PgDown')), |
|
1459 0, |
|
1460 self.editorActGrp, 'vm_edit_extend_selection_down_page') |
|
1461 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNEXTEND) |
|
1462 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1463 self.editActions.append(act) |
|
1464 |
|
1465 act = E4Action(QApplication.translate('ViewManager', |
|
1466 'Extend selection to start of text'), |
|
1467 QApplication.translate('ViewManager', |
|
1468 'Extend selection to start of text'), |
|
1469 QKeySequence(QApplication.translate('ViewManager', |
|
1470 'Ctrl+Shift+Home')), |
|
1471 0, |
|
1472 self.editorActGrp, 'vm_edit_extend_selection_start_text') |
|
1473 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTARTEXTEND) |
|
1474 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1475 self.editActions.append(act) |
|
1476 |
|
1477 act = E4Action(QApplication.translate('ViewManager', |
|
1478 'Extend selection to end of text'), |
|
1479 QApplication.translate('ViewManager', |
|
1480 'Extend selection to end of text'), |
|
1481 QKeySequence(QApplication.translate('ViewManager', |
|
1482 'Ctrl+Shift+End')), |
|
1483 0, |
|
1484 self.editorActGrp, 'vm_edit_extend_selection_end_text') |
|
1485 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTENDEXTEND) |
|
1486 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1487 self.editActions.append(act) |
|
1488 |
|
1489 act = E4Action(QApplication.translate('ViewManager', |
|
1490 'Delete previous character'), |
|
1491 QApplication.translate('ViewManager', 'Delete previous character'), |
|
1492 QKeySequence(QApplication.translate('ViewManager', 'Backspace')), |
|
1493 QKeySequence(QApplication.translate('ViewManager', |
|
1494 'Shift+Backspace')), |
|
1495 self.editorActGrp, 'vm_edit_delete_previous_char') |
|
1496 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACK) |
|
1497 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1498 self.editActions.append(act) |
|
1499 |
|
1500 act = E4Action(QApplication.translate('ViewManager', |
|
1501 'Delete previous character if not at line start'), |
|
1502 QApplication.translate('ViewManager', |
|
1503 'Delete previous character if not at line start'), |
|
1504 0, 0, |
|
1505 self.editorActGrp, 'vm_edit_delet_previous_char_not_line_start') |
|
1506 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACKNOTLINE) |
|
1507 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1508 self.editActions.append(act) |
|
1509 |
|
1510 act = E4Action(QApplication.translate('ViewManager', 'Delete current character'), |
|
1511 QApplication.translate('ViewManager', 'Delete current character'), |
|
1512 QKeySequence(QApplication.translate('ViewManager', 'Del')), 0, |
|
1513 self.editorActGrp, 'vm_edit_delete_current_char') |
|
1514 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) |
|
1515 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1516 self.editActions.append(act) |
|
1517 |
|
1518 act = E4Action(QApplication.translate('ViewManager', 'Delete word to left'), |
|
1519 QApplication.translate('ViewManager', 'Delete word to left'), |
|
1520 QKeySequence(QApplication.translate('ViewManager', |
|
1521 'Ctrl+Backspace')), |
|
1522 0, |
|
1523 self.editorActGrp, 'vm_edit_delete_word_left') |
|
1524 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDLEFT) |
|
1525 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1526 self.editActions.append(act) |
|
1527 |
|
1528 act = E4Action(QApplication.translate('ViewManager', 'Delete word to right'), |
|
1529 QApplication.translate('ViewManager', 'Delete word to right'), |
|
1530 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Del')), 0, |
|
1531 self.editorActGrp, 'vm_edit_delete_word_right') |
|
1532 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHT) |
|
1533 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1534 self.editActions.append(act) |
|
1535 |
|
1536 act = E4Action(QApplication.translate('ViewManager', 'Delete line to left'), |
|
1537 QApplication.translate('ViewManager', 'Delete line to left'), |
|
1538 QKeySequence(QApplication.translate('ViewManager', |
|
1539 'Ctrl+Shift+Backspace')), |
|
1540 0, |
|
1541 self.editorActGrp, 'vm_edit_delete_line_left') |
|
1542 self.esm.setMapping(act, QsciScintilla.SCI_DELLINELEFT) |
|
1543 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1544 self.editActions.append(act) |
|
1545 |
|
1546 act = E4Action(QApplication.translate('ViewManager', 'Delete line to right'), |
|
1547 QApplication.translate('ViewManager', 'Delete line to right'), |
|
1548 QKeySequence(QApplication.translate('ViewManager', |
|
1549 'Ctrl+Shift+Del')), |
|
1550 0, |
|
1551 self.editorActGrp, 'vm_edit_delete_line_right') |
|
1552 self.esm.setMapping(act, QsciScintilla.SCI_DELLINERIGHT) |
|
1553 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1554 self.editActions.append(act) |
|
1555 |
|
1556 act = E4Action(QApplication.translate('ViewManager', 'Insert new line'), |
|
1557 QApplication.translate('ViewManager', 'Insert new line'), |
|
1558 QKeySequence(QApplication.translate('ViewManager', 'Return')), |
|
1559 QKeySequence(QApplication.translate('ViewManager', 'Enter')), |
|
1560 self.editorActGrp, 'vm_edit_insert_line') |
|
1561 self.esm.setMapping(act, QsciScintilla.SCI_NEWLINE) |
|
1562 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1563 self.editActions.append(act) |
|
1564 |
|
1565 act = E4Action(QApplication.translate('ViewManager', |
|
1566 'Insert new line below current line'), |
|
1567 QApplication.translate('ViewManager', |
|
1568 'Insert new line below current line'), |
|
1569 QKeySequence(QApplication.translate('ViewManager', 'Shift+Return')), |
|
1570 QKeySequence(QApplication.translate('ViewManager', 'Shift+Enter')), |
|
1571 self.editorActGrp, 'vm_edit_insert_line_below') |
|
1572 self.connect(act, SIGNAL('triggered()'), self.__newLineBelow) |
|
1573 self.editActions.append(act) |
|
1574 |
|
1575 act = E4Action(QApplication.translate('ViewManager', 'Delete current line'), |
|
1576 QApplication.translate('ViewManager', 'Delete current line'), |
|
1577 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+U')), |
|
1578 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Shift+L')), |
|
1579 self.editorActGrp, 'vm_edit_delete_current_line') |
|
1580 self.esm.setMapping(act, QsciScintilla.SCI_LINEDELETE) |
|
1581 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1582 self.editActions.append(act) |
|
1583 |
|
1584 act = E4Action(QApplication.translate('ViewManager', 'Duplicate current line'), |
|
1585 QApplication.translate('ViewManager', 'Duplicate current line'), |
|
1586 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+D')), 0, |
|
1587 self.editorActGrp, 'vm_edit_duplicate_current_line') |
|
1588 self.esm.setMapping(act, QsciScintilla.SCI_LINEDUPLICATE) |
|
1589 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1590 self.editActions.append(act) |
|
1591 |
|
1592 act = E4Action(QApplication.translate('ViewManager', |
|
1593 'Swap current and previous lines'), |
|
1594 QApplication.translate('ViewManager', |
|
1595 'Swap current and previous lines'), |
|
1596 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+T')), 0, |
|
1597 self.editorActGrp, 'vm_edit_swap_current_previous_line') |
|
1598 self.esm.setMapping(act, QsciScintilla.SCI_LINETRANSPOSE) |
|
1599 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1600 self.editActions.append(act) |
|
1601 |
|
1602 act = E4Action(QApplication.translate('ViewManager', 'Cut current line'), |
|
1603 QApplication.translate('ViewManager', 'Cut current line'), |
|
1604 QKeySequence(QApplication.translate('ViewManager', 'Alt+Shift+L')), |
|
1605 0, |
|
1606 self.editorActGrp, 'vm_edit_cut_current_line') |
|
1607 self.esm.setMapping(act, QsciScintilla.SCI_LINECUT) |
|
1608 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1609 self.editActions.append(act) |
|
1610 |
|
1611 act = E4Action(QApplication.translate('ViewManager', 'Copy current line'), |
|
1612 QApplication.translate('ViewManager', 'Copy current line'), |
|
1613 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Shift+T')), |
|
1614 0, |
|
1615 self.editorActGrp, 'vm_edit_copy_current_line') |
|
1616 self.esm.setMapping(act, QsciScintilla.SCI_LINECOPY) |
|
1617 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1618 self.editActions.append(act) |
|
1619 |
|
1620 act = E4Action(QApplication.translate('ViewManager', 'Toggle insert/overtype'), |
|
1621 QApplication.translate('ViewManager', 'Toggle insert/overtype'), |
|
1622 QKeySequence(QApplication.translate('ViewManager', 'Ins')), 0, |
|
1623 self.editorActGrp, 'vm_edit_toggle_insert_overtype') |
|
1624 self.esm.setMapping(act, QsciScintilla.SCI_EDITTOGGLEOVERTYPE) |
|
1625 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1626 self.editActions.append(act) |
|
1627 |
|
1628 act = E4Action(QApplication.translate('ViewManager', |
|
1629 'Convert selection to lower case'), |
|
1630 QApplication.translate('ViewManager', |
|
1631 'Convert selection to lower case'), |
|
1632 QKeySequence(QApplication.translate('ViewManager', 'Alt+Shift+U')), |
|
1633 0, |
|
1634 self.editorActGrp, 'vm_edit_convert_selection_lower') |
|
1635 self.esm.setMapping(act, QsciScintilla.SCI_LOWERCASE) |
|
1636 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1637 self.editActions.append(act) |
|
1638 |
|
1639 act = E4Action(QApplication.translate('ViewManager', |
|
1640 'Convert selection to upper case'), |
|
1641 QApplication.translate('ViewManager', |
|
1642 'Convert selection to upper case'), |
|
1643 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Shift+U')), |
|
1644 0, |
|
1645 self.editorActGrp, 'vm_edit_convert_selection_upper') |
|
1646 self.esm.setMapping(act, QsciScintilla.SCI_UPPERCASE) |
|
1647 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1648 self.editActions.append(act) |
|
1649 |
|
1650 act = E4Action(QApplication.translate('ViewManager', |
|
1651 'Move to end of displayed line'), |
|
1652 QApplication.translate('ViewManager', |
|
1653 'Move to end of displayed line'), |
|
1654 QKeySequence(QApplication.translate('ViewManager', 'Alt+End')), 0, |
|
1655 self.editorActGrp, 'vm_edit_move_end_displayed_line') |
|
1656 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAY) |
|
1657 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1658 self.editActions.append(act) |
|
1659 |
|
1660 act = E4Action(QApplication.translate('ViewManager', |
|
1661 'Extend selection to end of displayed line'), |
|
1662 QApplication.translate('ViewManager', |
|
1663 'Extend selection to end of displayed line'), |
|
1664 0, 0, |
|
1665 self.editorActGrp, 'vm_edit_extend_selection_end_displayed_line') |
|
1666 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAYEXTEND) |
|
1667 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1668 self.editActions.append(act) |
|
1669 |
|
1670 act = E4Action(QApplication.translate('ViewManager', 'Formfeed'), |
|
1671 QApplication.translate('ViewManager', 'Formfeed'), |
|
1672 0, 0, |
|
1673 self.editorActGrp, 'vm_edit_formfeed') |
|
1674 self.esm.setMapping(act, QsciScintilla.SCI_FORMFEED) |
|
1675 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1676 self.editActions.append(act) |
|
1677 |
|
1678 act = E4Action(QApplication.translate('ViewManager', 'Escape'), |
|
1679 QApplication.translate('ViewManager', 'Escape'), |
|
1680 QKeySequence(QApplication.translate('ViewManager', 'Esc')), 0, |
|
1681 self.editorActGrp, 'vm_edit_escape') |
|
1682 self.esm.setMapping(act, QsciScintilla.SCI_CANCEL) |
|
1683 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1684 self.editActions.append(act) |
|
1685 |
|
1686 act = E4Action(QApplication.translate('ViewManager', |
|
1687 'Extend rectangular selection down one line'), |
|
1688 QApplication.translate('ViewManager', |
|
1689 'Extend rectangular selection down one line'), |
|
1690 QKeySequence(QApplication.translate('ViewManager', |
|
1691 'Alt+Ctrl+Down')), |
|
1692 0, |
|
1693 self.editorActGrp, 'vm_edit_extend_rect_selection_down_line') |
|
1694 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNRECTEXTEND) |
|
1695 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1696 self.editActions.append(act) |
|
1697 |
|
1698 act = E4Action(QApplication.translate('ViewManager', |
|
1699 'Extend rectangular selection up one line'), |
|
1700 QApplication.translate('ViewManager', |
|
1701 'Extend rectangular selection up one line'), |
|
1702 QKeySequence(QApplication.translate('ViewManager', 'Alt+Ctrl+Up')), |
|
1703 0, |
|
1704 self.editorActGrp, 'vm_edit_extend_rect_selection_up_line') |
|
1705 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPRECTEXTEND) |
|
1706 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1707 self.editActions.append(act) |
|
1708 |
|
1709 act = E4Action(QApplication.translate('ViewManager', |
|
1710 'Extend rectangular selection left one character'), |
|
1711 QApplication.translate('ViewManager', |
|
1712 'Extend rectangular selection left one character'), |
|
1713 QKeySequence(QApplication.translate('ViewManager', |
|
1714 'Alt+Ctrl+Left')), |
|
1715 0, |
|
1716 self.editorActGrp, 'vm_edit_extend_rect_selection_left_char') |
|
1717 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTRECTEXTEND) |
|
1718 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1719 self.editActions.append(act) |
|
1720 |
|
1721 act = E4Action(QApplication.translate('ViewManager', |
|
1722 'Extend rectangular selection right one character'), |
|
1723 QApplication.translate('ViewManager', |
|
1724 'Extend rectangular selection right one character'), |
|
1725 QKeySequence(QApplication.translate('ViewManager', |
|
1726 'Alt+Ctrl+Right')), |
|
1727 0, |
|
1728 self.editorActGrp, 'vm_edit_extend_rect_selection_right_char') |
|
1729 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTRECTEXTEND) |
|
1730 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1731 self.editActions.append(act) |
|
1732 |
|
1733 act = E4Action(QApplication.translate('ViewManager', |
|
1734 'Extend rectangular selection to first' |
|
1735 ' visible character in line'), |
|
1736 QApplication.translate('ViewManager', |
|
1737 'Extend rectangular selection to first' |
|
1738 ' visible character in line'), |
|
1739 QKeySequence(QApplication.translate('ViewManager', |
|
1740 'Alt+Ctrl+Home')), |
|
1741 0, |
|
1742 self.editorActGrp, |
|
1743 'vm_edit_extend_rect_selection_first_visible_char') |
|
1744 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMERECTEXTEND) |
|
1745 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1746 self.editActions.append(act) |
|
1747 |
|
1748 act = E4Action(QApplication.translate('ViewManager', |
|
1749 'Extend rectangular selection to end of line'), |
|
1750 QApplication.translate('ViewManager', |
|
1751 'Extend rectangular selection to end of line'), |
|
1752 QKeySequence(QApplication.translate('ViewManager', 'Alt+Ctrl+End')), |
|
1753 0, |
|
1754 self.editorActGrp, 'vm_edit_extend_rect_selection_end_line') |
|
1755 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDRECTEXTEND) |
|
1756 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1757 self.editActions.append(act) |
|
1758 |
|
1759 act = E4Action(QApplication.translate('ViewManager', |
|
1760 'Extend rectangular selection up one page'), |
|
1761 QApplication.translate('ViewManager', |
|
1762 'Extend rectangular selection up one page'), |
|
1763 QKeySequence(QApplication.translate('ViewManager', |
|
1764 'Alt+Ctrl+PgUp')), |
|
1765 0, |
|
1766 self.editorActGrp, 'vm_edit_extend_rect_selection_up_page') |
|
1767 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPRECTEXTEND) |
|
1768 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1769 self.editActions.append(act) |
|
1770 |
|
1771 act = E4Action(QApplication.translate('ViewManager', |
|
1772 'Extend rectangular selection down one page'), |
|
1773 QApplication.translate('ViewManager', |
|
1774 'Extend rectangular selection down one page'), |
|
1775 QKeySequence(QApplication.translate('ViewManager', |
|
1776 'Alt+Ctrl+PgDown')), |
|
1777 0, |
|
1778 self.editorActGrp, 'vm_edit_extend_rect_selection_down_page') |
|
1779 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNRECTEXTEND) |
|
1780 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1781 self.editActions.append(act) |
|
1782 |
|
1783 act = E4Action(QApplication.translate('ViewManager', |
|
1784 'Duplicate current selection'), |
|
1785 QApplication.translate('ViewManager', |
|
1786 'Duplicate current selection'), |
|
1787 QKeySequence(QApplication.translate('ViewManager', 'Ctrl+Shift+D')), |
|
1788 0, |
|
1789 self.editorActGrp, 'vm_edit_duplicate_current_selection') |
|
1790 self.esm.setMapping(act, QsciScintilla.SCI_SELECTIONDUPLICATE) |
|
1791 self.connect(act, SIGNAL('triggered()'), self.esm, SLOT('map()')) |
|
1792 self.editActions.append(act) |
|
1793 |
|
1794 self.editorActGrp.setEnabled(False) |
|
1795 |
|
1796 def initEditMenu(self): |
|
1797 """ |
|
1798 Public method to create the Edit menu |
|
1799 |
|
1800 @return the generated menu |
|
1801 """ |
|
1802 autocompletionMenu = \ |
|
1803 QMenu(QApplication.translate('ViewManager', '&Autocomplete'), self.ui) |
|
1804 autocompletionMenu.setTearOffEnabled(True) |
|
1805 autocompletionMenu.addAction(self.autoCompleteAct) |
|
1806 autocompletionMenu.addAction(self.autoCompleteFromDocAct) |
|
1807 autocompletionMenu.addAction(self.autoCompleteFromAPIsAct) |
|
1808 autocompletionMenu.addAction(self.autoCompleteFromAllAct) |
|
1809 autocompletionMenu.addSeparator() |
|
1810 autocompletionMenu.addAction(self.calltipsAct) |
|
1811 |
|
1812 searchMenu = \ |
|
1813 QMenu(QApplication.translate('ViewManager', '&Search'), self.ui) |
|
1814 searchMenu.setTearOffEnabled(True) |
|
1815 searchMenu.addAction(self.quickSearchAct) |
|
1816 searchMenu.addAction(self.quickSearchBackAct) |
|
1817 searchMenu.addAction(self.searchAct) |
|
1818 searchMenu.addAction(self.searchNextAct) |
|
1819 searchMenu.addAction(self.searchPrevAct) |
|
1820 searchMenu.addAction(self.replaceAct) |
|
1821 searchMenu.addSeparator() |
|
1822 searchMenu.addAction(self.searchClearMarkersAct) |
|
1823 searchMenu.addSeparator() |
|
1824 searchMenu.addAction(self.searchFilesAct) |
|
1825 searchMenu.addAction(self.replaceFilesAct) |
|
1826 |
|
1827 menu = QMenu(QApplication.translate('ViewManager', '&Edit'), self.ui) |
|
1828 menu.setTearOffEnabled(True) |
|
1829 menu.addAction(self.undoAct) |
|
1830 menu.addAction(self.redoAct) |
|
1831 menu.addAction(self.revertAct) |
|
1832 menu.addSeparator() |
|
1833 menu.addAction(self.cutAct) |
|
1834 menu.addAction(self.copyAct) |
|
1835 menu.addAction(self.pasteAct) |
|
1836 menu.addAction(self.deleteAct) |
|
1837 menu.addSeparator() |
|
1838 menu.addAction(self.indentAct) |
|
1839 menu.addAction(self.unindentAct) |
|
1840 menu.addAction(self.smartIndentAct) |
|
1841 menu.addSeparator() |
|
1842 menu.addAction(self.commentAct) |
|
1843 menu.addAction(self.uncommentAct) |
|
1844 menu.addAction(self.streamCommentAct) |
|
1845 menu.addAction(self.boxCommentAct) |
|
1846 menu.addSeparator() |
|
1847 menu.addMenu(autocompletionMenu) |
|
1848 menu.addSeparator() |
|
1849 menu.addMenu(searchMenu) |
|
1850 menu.addSeparator() |
|
1851 menu.addAction(self.gotoAct) |
|
1852 menu.addAction(self.gotoBraceAct) |
|
1853 menu.addSeparator() |
|
1854 menu.addAction(self.selectBraceAct) |
|
1855 menu.addAction(self.selectAllAct) |
|
1856 menu.addAction(self.deselectAllAct) |
|
1857 menu.addSeparator() |
|
1858 menu.addAction(self.shortenEmptyAct) |
|
1859 menu.addAction(self.convertEOLAct) |
|
1860 |
|
1861 return menu |
|
1862 |
|
1863 def initEditToolbar(self, toolbarManager): |
|
1864 """ |
|
1865 Public method to create the Edit toolbar |
|
1866 |
|
1867 @param toolbarManager reference to a toolbar manager object (E4ToolBarManager) |
|
1868 @return the generated toolbar |
|
1869 """ |
|
1870 tb = QToolBar(QApplication.translate('ViewManager', 'Edit'), self.ui) |
|
1871 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
1872 tb.setObjectName("EditToolbar") |
|
1873 tb.setToolTip(QApplication.translate('ViewManager', 'Edit')) |
|
1874 |
|
1875 tb.addAction(self.undoAct) |
|
1876 tb.addAction(self.redoAct) |
|
1877 tb.addSeparator() |
|
1878 tb.addAction(self.cutAct) |
|
1879 tb.addAction(self.copyAct) |
|
1880 tb.addAction(self.pasteAct) |
|
1881 tb.addAction(self.deleteAct) |
|
1882 tb.addSeparator() |
|
1883 tb.addAction(self.indentAct) |
|
1884 tb.addAction(self.unindentAct) |
|
1885 tb.addSeparator() |
|
1886 tb.addAction(self.commentAct) |
|
1887 tb.addAction(self.uncommentAct) |
|
1888 |
|
1889 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
1890 toolbarManager.addAction(self.smartIndentAct, tb.windowTitle()) |
|
1891 |
|
1892 return tb |
|
1893 |
|
1894 ################################################################## |
|
1895 ## Initialize the search related actions and the search toolbar |
|
1896 ################################################################## |
|
1897 |
|
1898 def __initSearchActions(self): |
|
1899 """ |
|
1900 Private method defining the user interface actions for the search commands. |
|
1901 """ |
|
1902 self.searchActGrp = createActionGroup(self) |
|
1903 |
|
1904 self.searchAct = E4Action(QApplication.translate('ViewManager', 'Search'), |
|
1905 UI.PixmapCache.getIcon("find.png"), |
|
1906 QApplication.translate('ViewManager', '&Search...'), |
|
1907 QKeySequence(QApplication.translate('ViewManager', |
|
1908 "Ctrl+F", "Search|Search")), |
|
1909 0, |
|
1910 self.searchActGrp, 'vm_search') |
|
1911 self.searchAct.setStatusTip(QApplication.translate('ViewManager', |
|
1912 'Search for a text')) |
|
1913 self.searchAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1914 """<b>Search</b>""" |
|
1915 """<p>Search for some text in the current editor. A""" |
|
1916 """ dialog is shown to enter the searchtext and options""" |
|
1917 """ for the search.</p>""" |
|
1918 )) |
|
1919 self.connect(self.searchAct, SIGNAL('triggered()'), self.__search) |
|
1920 self.searchActions.append(self.searchAct) |
|
1921 |
|
1922 self.searchNextAct = E4Action(QApplication.translate('ViewManager', |
|
1923 'Search next'), |
|
1924 UI.PixmapCache.getIcon("findNext.png"), |
|
1925 QApplication.translate('ViewManager', 'Search &next'), |
|
1926 QKeySequence(QApplication.translate('ViewManager', |
|
1927 "F3", "Search|Search next")), |
|
1928 0, |
|
1929 self.searchActGrp, 'vm_search_next') |
|
1930 self.searchNextAct.setStatusTip(QApplication.translate('ViewManager', |
|
1931 'Search next occurrence of text')) |
|
1932 self.searchNextAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1933 """<b>Search next</b>""" |
|
1934 """<p>Search the next occurrence of some text in the current editor.""" |
|
1935 """ The previously entered searchtext and options are reused.</p>""" |
|
1936 )) |
|
1937 self.connect(self.searchNextAct, SIGNAL('triggered()'), self.searchDlg.findNext) |
|
1938 self.searchActions.append(self.searchNextAct) |
|
1939 |
|
1940 self.searchPrevAct = E4Action(QApplication.translate('ViewManager', |
|
1941 'Search previous'), |
|
1942 UI.PixmapCache.getIcon("findPrev.png"), |
|
1943 QApplication.translate('ViewManager', 'Search &previous'), |
|
1944 QKeySequence(QApplication.translate('ViewManager', |
|
1945 "Shift+F3", "Search|Search previous")), |
|
1946 0, |
|
1947 self.searchActGrp, 'vm_search_previous') |
|
1948 self.searchPrevAct.setStatusTip(QApplication.translate('ViewManager', |
|
1949 'Search previous occurrence of text')) |
|
1950 self.searchPrevAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1951 """<b>Search previous</b>""" |
|
1952 """<p>Search the previous occurrence of some text in the current editor.""" |
|
1953 """ The previously entered searchtext and options are reused.</p>""" |
|
1954 )) |
|
1955 self.connect(self.searchPrevAct, SIGNAL('triggered()'), self.searchDlg.findPrev) |
|
1956 self.searchActions.append(self.searchPrevAct) |
|
1957 |
|
1958 self.searchClearMarkersAct = E4Action(QApplication.translate('ViewManager', |
|
1959 'Clear search markers'), |
|
1960 UI.PixmapCache.getIcon("findClear.png"), |
|
1961 QApplication.translate('ViewManager', 'Clear search markers'), |
|
1962 QKeySequence(QApplication.translate('ViewManager', |
|
1963 "Ctrl+3", "Search|Clear search markers")), |
|
1964 0, |
|
1965 self.searchActGrp, 'vm_clear_search_markers') |
|
1966 self.searchClearMarkersAct.setStatusTip(QApplication.translate('ViewManager', |
|
1967 'Clear all displayed search markers')) |
|
1968 self.searchClearMarkersAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1969 """<b>Clear search markers</b>""" |
|
1970 """<p>Clear all displayed search markers.</p>""" |
|
1971 )) |
|
1972 self.connect(self.searchClearMarkersAct, SIGNAL('triggered()'), |
|
1973 self.__searchClearMarkers) |
|
1974 self.searchActions.append(self.searchClearMarkersAct) |
|
1975 |
|
1976 self.replaceAct = E4Action(QApplication.translate('ViewManager', 'Replace'), |
|
1977 QApplication.translate('ViewManager', '&Replace...'), |
|
1978 QKeySequence(QApplication.translate('ViewManager', |
|
1979 "Ctrl+R", "Search|Replace")), |
|
1980 0, |
|
1981 self.searchActGrp, 'vm_search_replace') |
|
1982 self.replaceAct.setStatusTip(QApplication.translate('ViewManager', |
|
1983 'Replace some text')) |
|
1984 self.replaceAct.setWhatsThis(QApplication.translate('ViewManager', |
|
1985 """<b>Replace</b>""" |
|
1986 """<p>Search for some text in the current editor and replace it. A""" |
|
1987 """ dialog is shown to enter the searchtext, the replacement text""" |
|
1988 """ and options for the search and replace.</p>""" |
|
1989 )) |
|
1990 self.connect(self.replaceAct, SIGNAL('triggered()'), self.__replace) |
|
1991 self.searchActions.append(self.replaceAct) |
|
1992 |
|
1993 self.quickSearchAct = E4Action(QApplication.translate('ViewManager', |
|
1994 'Quicksearch'), |
|
1995 UI.PixmapCache.getIcon("quickFindNext.png"), |
|
1996 QApplication.translate('ViewManager', '&Quicksearch'), |
|
1997 QKeySequence(QApplication.translate('ViewManager', |
|
1998 "Ctrl+Shift+K", "Search|Quicksearch")), |
|
1999 0, |
|
2000 self.searchActGrp, 'vm_quicksearch') |
|
2001 self.quickSearchAct.setStatusTip(QApplication.translate('ViewManager', |
|
2002 'Perform a quicksearch')) |
|
2003 self.quickSearchAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2004 """<b>Quicksearch</b>""" |
|
2005 """<p>This activates the quicksearch function of the IDE by""" |
|
2006 """ giving focus to the quicksearch entry field. If this field""" |
|
2007 """ is already active and contains text, it searches for the""" |
|
2008 """ next occurrence of this text.</p>""" |
|
2009 )) |
|
2010 self.connect(self.quickSearchAct, SIGNAL('triggered()'), self.__quickSearch) |
|
2011 self.searchActions.append(self.quickSearchAct) |
|
2012 |
|
2013 self.quickSearchBackAct = E4Action(QApplication.translate('ViewManager', |
|
2014 'Quicksearch backwards'), |
|
2015 UI.PixmapCache.getIcon("quickFindPrev.png"), |
|
2016 QApplication.translate('ViewManager', 'Quicksearch &backwards'), |
|
2017 QKeySequence(QApplication.translate('ViewManager', |
|
2018 "Ctrl+Shift+J", "Search|Quicksearch backwards")), |
|
2019 0, self.searchActGrp, 'vm_quicksearch_backwards') |
|
2020 self.quickSearchBackAct.setStatusTip(QApplication.translate('ViewManager', |
|
2021 'Perform a quicksearch backwards')) |
|
2022 self.quickSearchBackAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2023 """<b>Quicksearch backwards</b>""" |
|
2024 """<p>This searches the previous occurrence of the quicksearch text.</p>""" |
|
2025 )) |
|
2026 self.connect(self.quickSearchBackAct, SIGNAL('triggered()'), |
|
2027 self.__quickSearchPrev) |
|
2028 self.searchActions.append(self.quickSearchBackAct) |
|
2029 |
|
2030 self.quickSearchExtendAct = E4Action(QApplication.translate('ViewManager', |
|
2031 'Quicksearch extend'), |
|
2032 UI.PixmapCache.getIcon("quickFindExtend.png"), |
|
2033 QApplication.translate('ViewManager', 'Quicksearch e&xtend'), |
|
2034 QKeySequence(QApplication.translate('ViewManager', |
|
2035 "Ctrl+Shift+H", "Search|Quicksearch extend")), |
|
2036 0, |
|
2037 self.searchActGrp, 'vm_quicksearch_extend') |
|
2038 self.quickSearchExtendAct.setStatusTip(QApplication.translate('ViewManager', \ |
|
2039 'Extend the quicksearch to the end of the current word')) |
|
2040 self.quickSearchExtendAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2041 """<b>Quicksearch extend</b>""" |
|
2042 """<p>This extends the quicksearch text to the end of the word""" |
|
2043 """ currently found.</p>""" |
|
2044 )) |
|
2045 self.connect(self.quickSearchExtendAct, SIGNAL('triggered()'), |
|
2046 self.__quickSearchExtend) |
|
2047 self.searchActions.append(self.quickSearchExtendAct) |
|
2048 |
|
2049 self.gotoAct = E4Action(QApplication.translate('ViewManager', 'Goto Line'), |
|
2050 UI.PixmapCache.getIcon("goto.png"), |
|
2051 QApplication.translate('ViewManager', '&Goto Line...'), |
|
2052 QKeySequence(QApplication.translate('ViewManager', |
|
2053 "Ctrl+G", "Search|Goto Line")), |
|
2054 0, |
|
2055 self.searchActGrp, 'vm_search_goto_line') |
|
2056 self.gotoAct.setStatusTip(QApplication.translate('ViewManager', 'Goto Line')) |
|
2057 self.gotoAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2058 """<b>Goto Line</b>""" |
|
2059 """<p>Go to a specific line of text in the current editor.""" |
|
2060 """ A dialog is shown to enter the linenumber.</p>""" |
|
2061 )) |
|
2062 self.connect(self.gotoAct, SIGNAL('triggered()'), self.__goto) |
|
2063 self.searchActions.append(self.gotoAct) |
|
2064 |
|
2065 self.gotoBraceAct = E4Action(QApplication.translate('ViewManager', 'Goto Brace'), |
|
2066 UI.PixmapCache.getIcon("gotoBrace.png"), |
|
2067 QApplication.translate('ViewManager', 'Goto &Brace'), |
|
2068 QKeySequence(QApplication.translate('ViewManager', |
|
2069 "Ctrl+L", "Search|Goto Brace")), |
|
2070 0, |
|
2071 self.searchActGrp, 'vm_search_goto_brace') |
|
2072 self.gotoBraceAct.setStatusTip(QApplication.translate('ViewManager', |
|
2073 'Goto Brace')) |
|
2074 self.gotoBraceAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2075 """<b>Goto Brace</b>""" |
|
2076 """<p>Go to the matching brace in the current editor.</p>""" |
|
2077 )) |
|
2078 self.connect(self.gotoBraceAct, SIGNAL('triggered()'), self.__gotoBrace) |
|
2079 self.searchActions.append(self.gotoBraceAct) |
|
2080 |
|
2081 self.searchActGrp.setEnabled(False) |
|
2082 |
|
2083 self.searchFilesAct = E4Action(QApplication.translate('ViewManager', |
|
2084 'Search in Files'), |
|
2085 UI.PixmapCache.getIcon("projectFind.png"), |
|
2086 QApplication.translate('ViewManager', 'Search in &Files...'), |
|
2087 QKeySequence(QApplication.translate('ViewManager', |
|
2088 "Shift+Ctrl+F", "Search|Search Files")), |
|
2089 0, |
|
2090 self, 'vm_search_in_files') |
|
2091 self.searchFilesAct.setStatusTip(QApplication.translate('ViewManager', |
|
2092 'Search for a text in files')) |
|
2093 self.searchFilesAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2094 """<b>Search in Files</b>""" |
|
2095 """<p>Search for some text in the files of a directory tree""" |
|
2096 """ or the project. A dialog is shown to enter the searchtext""" |
|
2097 """ and options for the search and to display the result.</p>""" |
|
2098 )) |
|
2099 self.connect(self.searchFilesAct, SIGNAL('triggered()'), self.__searchFiles) |
|
2100 self.searchActions.append(self.searchFilesAct) |
|
2101 |
|
2102 self.replaceFilesAct = E4Action(QApplication.translate('ViewManager', |
|
2103 'Replace in Files'), |
|
2104 QApplication.translate('ViewManager', 'Replace in F&iles...'), |
|
2105 QKeySequence(QApplication.translate('ViewManager', |
|
2106 "Shift+Ctrl+R", "Search|Replace in Files")), |
|
2107 0, |
|
2108 self, 'vm_replace_in_files') |
|
2109 self.replaceFilesAct.setStatusTip(QApplication.translate('ViewManager', |
|
2110 'Search for a text in files and replace it')) |
|
2111 self.replaceFilesAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2112 """<b>Replace in Files</b>""" |
|
2113 """<p>Search for some text in the files of a directory tree""" |
|
2114 """ or the project and replace it. A dialog is shown to enter""" |
|
2115 """ the searchtext, the replacement text and options for the""" |
|
2116 """ search and to display the result.</p>""" |
|
2117 )) |
|
2118 self.connect(self.replaceFilesAct, SIGNAL('triggered()'), self.__replaceFiles) |
|
2119 self.searchActions.append(self.replaceFilesAct) |
|
2120 |
|
2121 def initSearchToolbars(self, toolbarManager): |
|
2122 """ |
|
2123 Public method to create the Search toolbars |
|
2124 |
|
2125 @param toolbarManager reference to a toolbar manager object (E4ToolBarManager) |
|
2126 @return a tuple of the generated toolbar (search, quicksearch) |
|
2127 """ |
|
2128 qtb = QToolBar(QApplication.translate('ViewManager', 'Quicksearch'), self.ui) |
|
2129 qtb.setIconSize(UI.Config.ToolBarIconSize) |
|
2130 qtb.setObjectName("QuicksearchToolbar") |
|
2131 qtb.setToolTip(QApplication.translate('ViewManager', 'Quicksearch')) |
|
2132 |
|
2133 self.quickFindLineEdit = QuickSearchLineEdit(self) |
|
2134 self.quickFindtextCombo = QComboBox(self) |
|
2135 self.quickFindtextCombo.setEditable(True) |
|
2136 self.quickFindtextCombo.setLineEdit(self.quickFindLineEdit) |
|
2137 self.quickFindtextCombo.setDuplicatesEnabled(False) |
|
2138 self.quickFindtextCombo.setInsertPolicy(QComboBox.InsertAtTop) |
|
2139 self.quickFindtextCombo.lastActive = None |
|
2140 self.quickFindtextCombo.lastCursorPos = None |
|
2141 self.quickFindtextCombo.leForegroundColor = \ |
|
2142 self.quickFindtextCombo.lineEdit().palette().color(QPalette.Text) |
|
2143 self.quickFindtextCombo.leBackgroundColor = \ |
|
2144 self.quickFindtextCombo.lineEdit().palette().color(QPalette.Base) |
|
2145 self.quickFindtextCombo.lastSearchText = "" |
|
2146 self.quickFindtextCombo._editor = self.quickFindtextCombo.lineEdit() |
|
2147 # this allows us not to jump across searched text |
|
2148 # just because of autocompletion enabled |
|
2149 self.quickFindtextCombo.setAutoCompletion(False) |
|
2150 self.quickFindtextCombo.setMinimumWidth(250) |
|
2151 self.quickFindtextCombo.addItem("") |
|
2152 self.quickFindtextCombo.setWhatsThis(QApplication.translate('ViewManager', |
|
2153 """<p>Enter the searchtext directly into this field.""" |
|
2154 """ The search will be performed case insensitive.""" |
|
2155 """ The quicksearch function is activated upon activation""" |
|
2156 """ of the quicksearch next action (default key Ctrl+Shift+K),""" |
|
2157 """ if this entry field does not have the input focus.""" |
|
2158 """ Otherwise it searches for the next occurrence of the""" |
|
2159 """ text entered. The quicksearch backwards action""" |
|
2160 """ (default key Ctrl+Shift+J) searches backward.""" |
|
2161 """ Activating the 'quicksearch extend' action""" |
|
2162 """ (default key Ctrl+Shift+H) extends the current""" |
|
2163 """ searchtext to the end of the currently found word.""" |
|
2164 """ The quicksearch can be ended by pressing the Return key""" |
|
2165 """ while the quicksearch entry has the the input focus.</p>""" |
|
2166 )) |
|
2167 self.connect(self.quickFindtextCombo._editor, SIGNAL('returnPressed()'), |
|
2168 self.__quickSearchEnter) |
|
2169 self.connect(self.quickFindtextCombo._editor, |
|
2170 SIGNAL('textChanged(const QString&)'), self.__quickSearchText) |
|
2171 self.connect(self.quickFindtextCombo._editor, SIGNAL('escPressed()'), |
|
2172 self.__quickSearchEscape) |
|
2173 self.connect(self.quickFindtextCombo._editor, SIGNAL('gotFocus()'), |
|
2174 self.__quickSearchFocusIn) |
|
2175 self.quickFindtextAction = QWidgetAction(self) |
|
2176 self.quickFindtextAction.setDefaultWidget(self.quickFindtextCombo) |
|
2177 self.quickFindtextAction.setObjectName("vm_quickfindtext_action") |
|
2178 self.quickFindtextAction.setText(self.trUtf8("Quicksearch Textedit")) |
|
2179 qtb.addAction(self.quickFindtextAction) |
|
2180 qtb.addAction(self.quickSearchAct) |
|
2181 qtb.addAction(self.quickSearchBackAct) |
|
2182 qtb.addAction(self.quickSearchExtendAct) |
|
2183 self.quickFindtextCombo.setEnabled(False) |
|
2184 |
|
2185 tb = QToolBar(QApplication.translate('ViewManager', 'Search'), self.ui) |
|
2186 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
2187 tb.setObjectName("SearchToolbar") |
|
2188 tb.setToolTip(QApplication.translate('ViewManager', 'Search')) |
|
2189 |
|
2190 tb.addAction(self.searchAct) |
|
2191 tb.addAction(self.searchNextAct) |
|
2192 tb.addAction(self.searchPrevAct) |
|
2193 tb.addSeparator() |
|
2194 tb.addAction(self.searchClearMarkersAct) |
|
2195 tb.addSeparator() |
|
2196 tb.addAction(self.searchFilesAct) |
|
2197 |
|
2198 tb.setAllowedAreas(Qt.ToolBarAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea)) |
|
2199 |
|
2200 toolbarManager.addToolBar(qtb, qtb.windowTitle()) |
|
2201 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
2202 toolbarManager.addAction(self.gotoAct, tb.windowTitle()) |
|
2203 toolbarManager.addAction(self.gotoBraceAct, tb.windowTitle()) |
|
2204 |
|
2205 return tb, qtb |
|
2206 |
|
2207 ################################################################## |
|
2208 ## Initialize the view related actions, view menu and toolbar |
|
2209 ################################################################## |
|
2210 |
|
2211 def __initViewActions(self): |
|
2212 """ |
|
2213 Private method defining the user interface actions for the view commands. |
|
2214 """ |
|
2215 self.viewActGrp = createActionGroup(self) |
|
2216 self.viewFoldActGrp = createActionGroup(self) |
|
2217 |
|
2218 self.zoomInAct = E4Action(QApplication.translate('ViewManager', 'Zoom in'), |
|
2219 UI.PixmapCache.getIcon("zoomIn.png"), |
|
2220 QApplication.translate('ViewManager', 'Zoom &in'), |
|
2221 QKeySequence(QApplication.translate('ViewManager', |
|
2222 "Ctrl++", "View|Zoom in")), |
|
2223 0, |
|
2224 self.viewActGrp, 'vm_view_zoom_in') |
|
2225 self.zoomInAct.setStatusTip(QApplication.translate('ViewManager', |
|
2226 'Zoom in on the text')) |
|
2227 self.zoomInAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2228 """<b>Zoom in</b>""" |
|
2229 """<p>Zoom in on the text. This makes the text bigger.</p>""" |
|
2230 )) |
|
2231 self.connect(self.zoomInAct, SIGNAL('triggered()'), self.__zoomIn) |
|
2232 self.viewActions.append(self.zoomInAct) |
|
2233 |
|
2234 self.zoomOutAct = E4Action(QApplication.translate('ViewManager', 'Zoom out'), |
|
2235 UI.PixmapCache.getIcon("zoomOut.png"), |
|
2236 QApplication.translate('ViewManager', 'Zoom &out'), |
|
2237 QKeySequence(QApplication.translate('ViewManager', |
|
2238 "Ctrl+-", "View|Zoom out")), |
|
2239 0, |
|
2240 self.viewActGrp, 'vm_view_zoom_out') |
|
2241 self.zoomOutAct.setStatusTip(QApplication.translate('ViewManager', |
|
2242 'Zoom out on the text')) |
|
2243 self.zoomOutAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2244 """<b>Zoom out</b>""" |
|
2245 """<p>Zoom out on the text. This makes the text smaller.</p>""" |
|
2246 )) |
|
2247 self.connect(self.zoomOutAct, SIGNAL('triggered()'), self.__zoomOut) |
|
2248 self.viewActions.append(self.zoomOutAct) |
|
2249 |
|
2250 self.zoomToAct = E4Action(QApplication.translate('ViewManager', 'Zoom'), |
|
2251 UI.PixmapCache.getIcon("zoomTo.png"), |
|
2252 QApplication.translate('ViewManager', '&Zoom'), |
|
2253 QKeySequence(QApplication.translate('ViewManager', |
|
2254 "Ctrl+#", "View|Zoom")), |
|
2255 0, |
|
2256 self.viewActGrp, 'vm_view_zoom') |
|
2257 self.zoomToAct.setStatusTip(QApplication.translate('ViewManager', |
|
2258 'Zoom the text')) |
|
2259 self.zoomToAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2260 """<b>Zoom</b>""" |
|
2261 """<p>Zoom the text. This opens a dialog where the""" |
|
2262 """ desired size can be entered.</p>""" |
|
2263 )) |
|
2264 self.connect(self.zoomToAct, SIGNAL('triggered()'), self.__zoom) |
|
2265 self.viewActions.append(self.zoomToAct) |
|
2266 |
|
2267 self.toggleAllAct = E4Action(QApplication.translate('ViewManager', |
|
2268 'Toggle all folds'), |
|
2269 QApplication.translate('ViewManager', 'Toggle &all folds'), |
|
2270 0, 0, self.viewFoldActGrp, 'vm_view_toggle_all_folds') |
|
2271 self.toggleAllAct.setStatusTip(QApplication.translate('ViewManager', |
|
2272 'Toggle all folds')) |
|
2273 self.toggleAllAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2274 """<b>Toggle all folds</b>""" |
|
2275 """<p>Toggle all folds of the current editor.</p>""" |
|
2276 )) |
|
2277 self.connect(self.toggleAllAct, SIGNAL('triggered()'), self.__toggleAll) |
|
2278 self.viewActions.append(self.toggleAllAct) |
|
2279 |
|
2280 self.toggleAllChildrenAct = \ |
|
2281 E4Action(QApplication.translate('ViewManager', |
|
2282 'Toggle all folds (including children)'), |
|
2283 QApplication.translate('ViewManager', |
|
2284 'Toggle all &folds (including children)'), |
|
2285 0, 0, self.viewFoldActGrp, 'vm_view_toggle_all_folds_children') |
|
2286 self.toggleAllChildrenAct.setStatusTip(QApplication.translate('ViewManager', |
|
2287 'Toggle all folds (including children)')) |
|
2288 self.toggleAllChildrenAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2289 """<b>Toggle all folds (including children)</b>""" |
|
2290 """<p>Toggle all folds of the current editor including""" |
|
2291 """ all children.</p>""" |
|
2292 )) |
|
2293 self.connect(self.toggleAllChildrenAct, SIGNAL('triggered()'), |
|
2294 self.__toggleAllChildren) |
|
2295 self.viewActions.append(self.toggleAllChildrenAct) |
|
2296 |
|
2297 self.toggleCurrentAct = E4Action(QApplication.translate('ViewManager', |
|
2298 'Toggle current fold'), |
|
2299 QApplication.translate('ViewManager', 'Toggle ¤t fold'), |
|
2300 0, 0, self.viewFoldActGrp, 'vm_view_toggle_current_fold') |
|
2301 self.toggleCurrentAct.setStatusTip(QApplication.translate('ViewManager', |
|
2302 'Toggle current fold')) |
|
2303 self.toggleCurrentAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2304 """<b>Toggle current fold</b>""" |
|
2305 """<p>Toggle the folds of the current line of the current editor.</p>""" |
|
2306 )) |
|
2307 self.connect(self.toggleCurrentAct, SIGNAL('triggered()'), self.__toggleCurrent) |
|
2308 self.viewActions.append(self.toggleCurrentAct) |
|
2309 |
|
2310 self.unhighlightAct = E4Action(QApplication.translate('ViewManager', |
|
2311 'Remove all highlights'), |
|
2312 UI.PixmapCache.getIcon("unhighlight.png"), |
|
2313 QApplication.translate('ViewManager', |
|
2314 'Remove all highlights'), |
|
2315 0, 0, self, 'vm_view_unhighlight') |
|
2316 self.unhighlightAct.setStatusTip(QApplication.translate('ViewManager', |
|
2317 'Remove all highlights')) |
|
2318 self.unhighlightAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2319 """<b>Remove all highlights</b>""" |
|
2320 """<p>Remove the highlights of all editors.</p>""" |
|
2321 )) |
|
2322 self.connect(self.unhighlightAct, SIGNAL('triggered()'), self.unhighlight) |
|
2323 self.viewActions.append(self.unhighlightAct) |
|
2324 |
|
2325 self.splitViewAct = E4Action(QApplication.translate('ViewManager', 'Split view'), |
|
2326 UI.PixmapCache.getIcon("splitVertical.png"), |
|
2327 QApplication.translate('ViewManager', '&Split view'), |
|
2328 0, 0, self, 'vm_view_split_view') |
|
2329 self.splitViewAct.setStatusTip(QApplication.translate('ViewManager', |
|
2330 'Add a split to the view')) |
|
2331 self.splitViewAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2332 """<b>Split view</b>""" |
|
2333 """<p>Add a split to the view.</p>""" |
|
2334 )) |
|
2335 self.connect(self.splitViewAct, SIGNAL('triggered()'), self.__splitView) |
|
2336 self.viewActions.append(self.splitViewAct) |
|
2337 |
|
2338 self.splitOrientationAct = E4Action(QApplication.translate('ViewManager', |
|
2339 'Arrange horizontally'), |
|
2340 QApplication.translate('ViewManager', |
|
2341 'Arrange &horizontally'), |
|
2342 0, 0, self, 'vm_view_arrange_horizontally', True) |
|
2343 self.splitOrientationAct.setStatusTip(QApplication.translate('ViewManager', |
|
2344 'Arrange the splitted views horizontally')) |
|
2345 self.splitOrientationAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2346 """<b>Arrange horizontally</b>""" |
|
2347 """<p>Arrange the splitted views horizontally.</p>""" |
|
2348 )) |
|
2349 self.splitOrientationAct.setChecked(False) |
|
2350 self.connect(self.splitOrientationAct, SIGNAL('toggled(bool)'), |
|
2351 self.__splitOrientation) |
|
2352 self.viewActions.append(self.splitOrientationAct) |
|
2353 |
|
2354 self.splitRemoveAct = E4Action(QApplication.translate('ViewManager', |
|
2355 'Remove split'), |
|
2356 UI.PixmapCache.getIcon("remsplitVertical.png"), |
|
2357 QApplication.translate('ViewManager', '&Remove split'), |
|
2358 0, 0, self, 'vm_view_remove_split') |
|
2359 self.splitRemoveAct.setStatusTip(QApplication.translate('ViewManager', |
|
2360 'Remove the current split')) |
|
2361 self.splitRemoveAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2362 """<b>Remove split</b>""" |
|
2363 """<p>Remove the current split.</p>""" |
|
2364 )) |
|
2365 self.connect(self.splitRemoveAct, SIGNAL('triggered()'), self.removeSplit) |
|
2366 self.viewActions.append(self.splitRemoveAct) |
|
2367 |
|
2368 self.nextSplitAct = E4Action(QApplication.translate('ViewManager', 'Next split'), |
|
2369 QApplication.translate('ViewManager', '&Next split'), |
|
2370 QKeySequence(QApplication.translate('ViewManager', |
|
2371 "Ctrl+Alt+N", "View|Next split")), |
|
2372 0, |
|
2373 self, 'vm_next_split') |
|
2374 self.nextSplitAct.setStatusTip(QApplication.translate('ViewManager', |
|
2375 'Move to the next split')) |
|
2376 self.nextSplitAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2377 """<b>Next split</b>""" |
|
2378 """<p>Move to the next split.</p>""" |
|
2379 )) |
|
2380 self.connect(self.nextSplitAct, SIGNAL('triggered()'), self.nextSplit) |
|
2381 self.viewActions.append(self.nextSplitAct) |
|
2382 |
|
2383 self.prevSplitAct = E4Action(QApplication.translate('ViewManager', |
|
2384 'Previous split'), |
|
2385 QApplication.translate('ViewManager', '&Previous split'), |
|
2386 QKeySequence(QApplication.translate('ViewManager', |
|
2387 "Ctrl+Alt+P", "View|Previous split")), |
|
2388 0, self, 'vm_previous_split') |
|
2389 self.prevSplitAct.setStatusTip(QApplication.translate('ViewManager', |
|
2390 'Move to the previous split')) |
|
2391 self.prevSplitAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2392 """<b>Previous split</b>""" |
|
2393 """<p>Move to the previous split.</p>""" |
|
2394 )) |
|
2395 self.connect(self.prevSplitAct, SIGNAL('triggered()'), self.prevSplit) |
|
2396 self.viewActions.append(self.prevSplitAct) |
|
2397 |
|
2398 self.viewActGrp.setEnabled(False) |
|
2399 self.viewFoldActGrp.setEnabled(False) |
|
2400 self.unhighlightAct.setEnabled(False) |
|
2401 self.splitViewAct.setEnabled(False) |
|
2402 self.splitOrientationAct.setEnabled(False) |
|
2403 self.splitRemoveAct.setEnabled(False) |
|
2404 self.nextSplitAct.setEnabled(False) |
|
2405 self.prevSplitAct.setEnabled(False) |
|
2406 |
|
2407 def initViewMenu(self): |
|
2408 """ |
|
2409 Public method to create the View menu |
|
2410 |
|
2411 @return the generated menu |
|
2412 """ |
|
2413 menu = QMenu(QApplication.translate('ViewManager', '&View'), self.ui) |
|
2414 menu.setTearOffEnabled(True) |
|
2415 menu.addActions(self.viewActGrp.actions()) |
|
2416 menu.addSeparator() |
|
2417 menu.addActions(self.viewFoldActGrp.actions()) |
|
2418 menu.addSeparator() |
|
2419 menu.addAction(self.unhighlightAct) |
|
2420 if self.canSplit(): |
|
2421 menu.addSeparator() |
|
2422 menu.addAction(self.splitViewAct) |
|
2423 menu.addAction(self.splitOrientationAct) |
|
2424 menu.addAction(self.splitRemoveAct) |
|
2425 menu.addAction(self.nextSplitAct) |
|
2426 menu.addAction(self.prevSplitAct) |
|
2427 |
|
2428 return menu |
|
2429 |
|
2430 def initViewToolbar(self, toolbarManager): |
|
2431 """ |
|
2432 Public method to create the View toolbar |
|
2433 |
|
2434 @param toolbarManager reference to a toolbar manager object (E4ToolBarManager) |
|
2435 @return the generated toolbar |
|
2436 """ |
|
2437 tb = QToolBar(QApplication.translate('ViewManager', 'View'), self.ui) |
|
2438 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
2439 tb.setObjectName("ViewToolbar") |
|
2440 tb.setToolTip(QApplication.translate('ViewManager', 'View')) |
|
2441 |
|
2442 tb.addActions(self.viewActGrp.actions()) |
|
2443 |
|
2444 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
2445 toolbarManager.addAction(self.unhighlightAct, tb.windowTitle()) |
|
2446 toolbarManager.addAction(self.splitViewAct, tb.windowTitle()) |
|
2447 toolbarManager.addAction(self.splitRemoveAct, tb.windowTitle()) |
|
2448 |
|
2449 return tb |
|
2450 |
|
2451 ################################################################## |
|
2452 ## Initialize the macro related actions and macro menu |
|
2453 ################################################################## |
|
2454 |
|
2455 def __initMacroActions(self): |
|
2456 """ |
|
2457 Private method defining the user interface actions for the macro commands. |
|
2458 """ |
|
2459 self.macroActGrp = createActionGroup(self) |
|
2460 |
|
2461 self.macroStartRecAct = E4Action(QApplication.translate('ViewManager', |
|
2462 'Start Macro Recording'), |
|
2463 QApplication.translate('ViewManager', |
|
2464 'S&tart Macro Recording'), |
|
2465 0, 0, self.macroActGrp, 'vm_macro_start_recording') |
|
2466 self.macroStartRecAct.setStatusTip(QApplication.translate('ViewManager', |
|
2467 'Start Macro Recording')) |
|
2468 self.macroStartRecAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2469 """<b>Start Macro Recording</b>""" |
|
2470 """<p>Start recording editor commands into a new macro.</p>""" |
|
2471 )) |
|
2472 self.connect(self.macroStartRecAct, SIGNAL('triggered()'), |
|
2473 self.__macroStartRecording) |
|
2474 self.macroActions.append(self.macroStartRecAct) |
|
2475 |
|
2476 self.macroStopRecAct = E4Action(QApplication.translate('ViewManager', |
|
2477 'Stop Macro Recording'), |
|
2478 QApplication.translate('ViewManager', |
|
2479 'Sto&p Macro Recording'), |
|
2480 0, 0, self.macroActGrp, 'vm_macro_stop_recording') |
|
2481 self.macroStopRecAct.setStatusTip(QApplication.translate('ViewManager', |
|
2482 'Stop Macro Recording')) |
|
2483 self.macroStopRecAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2484 """<b>Stop Macro Recording</b>""" |
|
2485 """<p>Stop recording editor commands into a new macro.</p>""" |
|
2486 )) |
|
2487 self.connect(self.macroStopRecAct, SIGNAL('triggered()'), |
|
2488 self.__macroStopRecording) |
|
2489 self.macroActions.append(self.macroStopRecAct) |
|
2490 |
|
2491 self.macroRunAct = E4Action(QApplication.translate('ViewManager', 'Run Macro'), |
|
2492 QApplication.translate('ViewManager', '&Run Macro'), |
|
2493 0, 0, self.macroActGrp, 'vm_macro_run') |
|
2494 self.macroRunAct.setStatusTip(QApplication.translate('ViewManager', 'Run Macro')) |
|
2495 self.macroRunAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2496 """<b>Run Macro</b>""" |
|
2497 """<p>Run a previously recorded editor macro.</p>""" |
|
2498 )) |
|
2499 self.connect(self.macroRunAct, SIGNAL('triggered()'), self.__macroRun) |
|
2500 self.macroActions.append(self.macroRunAct) |
|
2501 |
|
2502 self.macroDeleteAct = E4Action(QApplication.translate('ViewManager', |
|
2503 'Delete Macro'), |
|
2504 QApplication.translate('ViewManager', '&Delete Macro'), |
|
2505 0, 0, self.macroActGrp, 'vm_macro_delete') |
|
2506 self.macroDeleteAct.setStatusTip(QApplication.translate('ViewManager', |
|
2507 'Delete Macro')) |
|
2508 self.macroDeleteAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2509 """<b>Delete Macro</b>""" |
|
2510 """<p>Delete a previously recorded editor macro.</p>""" |
|
2511 )) |
|
2512 self.connect(self.macroDeleteAct, SIGNAL('triggered()'), self.__macroDelete) |
|
2513 self.macroActions.append(self.macroDeleteAct) |
|
2514 |
|
2515 self.macroLoadAct = E4Action(QApplication.translate('ViewManager', 'Load Macro'), |
|
2516 QApplication.translate('ViewManager', '&Load Macro'), |
|
2517 0, 0, self.macroActGrp, 'vm_macro_load') |
|
2518 self.macroLoadAct.setStatusTip(QApplication.translate('ViewManager', |
|
2519 'Load Macro')) |
|
2520 self.macroLoadAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2521 """<b>Load Macro</b>""" |
|
2522 """<p>Load an editor macro from a file.</p>""" |
|
2523 )) |
|
2524 self.connect(self.macroLoadAct, SIGNAL('triggered()'), self.__macroLoad) |
|
2525 self.macroActions.append(self.macroLoadAct) |
|
2526 |
|
2527 self.macroSaveAct = E4Action(QApplication.translate('ViewManager', 'Save Macro'), |
|
2528 QApplication.translate('ViewManager', '&Save Macro'), |
|
2529 0, 0, self.macroActGrp, 'vm_macro_save') |
|
2530 self.macroSaveAct.setStatusTip(QApplication.translate('ViewManager', |
|
2531 'Save Macro')) |
|
2532 self.macroSaveAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2533 """<b>Save Macro</b>""" |
|
2534 """<p>Save a previously recorded editor macro to a file.</p>""" |
|
2535 )) |
|
2536 self.connect(self.macroSaveAct, SIGNAL('triggered()'), self.__macroSave) |
|
2537 self.macroActions.append(self.macroSaveAct) |
|
2538 |
|
2539 self.macroActGrp.setEnabled(False) |
|
2540 |
|
2541 def initMacroMenu(self): |
|
2542 """ |
|
2543 Public method to create the Macro menu |
|
2544 |
|
2545 @return the generated menu |
|
2546 """ |
|
2547 menu = QMenu(QApplication.translate('ViewManager', "&Macros"), self.ui) |
|
2548 menu.setTearOffEnabled(True) |
|
2549 menu.addActions(self.macroActGrp.actions()) |
|
2550 |
|
2551 return menu |
|
2552 |
|
2553 ##################################################################### |
|
2554 ## Initialize the bookmark related actions, bookmark menu and toolbar |
|
2555 ##################################################################### |
|
2556 |
|
2557 def __initBookmarkActions(self): |
|
2558 """ |
|
2559 Private method defining the user interface actions for the bookmarks commands. |
|
2560 """ |
|
2561 self.bookmarkActGrp = createActionGroup(self) |
|
2562 |
|
2563 self.bookmarkToggleAct = E4Action(QApplication.translate('ViewManager', |
|
2564 'Toggle Bookmark'), |
|
2565 UI.PixmapCache.getIcon("bookmarkToggle.png"), |
|
2566 QApplication.translate('ViewManager', '&Toggle Bookmark'), |
|
2567 QKeySequence(QApplication.translate('ViewManager', |
|
2568 "Alt+Ctrl+T", "Bookmark|Toggle")), 0, |
|
2569 self.bookmarkActGrp, 'vm_bookmark_toggle') |
|
2570 self.bookmarkToggleAct.setStatusTip(QApplication.translate('ViewManager', |
|
2571 'Toggle Bookmark')) |
|
2572 self.bookmarkToggleAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2573 """<b>Toggle Bookmark</b>""" |
|
2574 """<p>Toggle a bookmark at the current line of the current editor.</p>""" |
|
2575 )) |
|
2576 self.connect(self.bookmarkToggleAct, SIGNAL('triggered()'), self.__toggleBookmark) |
|
2577 self.bookmarkActions.append(self.bookmarkToggleAct) |
|
2578 |
|
2579 self.bookmarkNextAct = E4Action(QApplication.translate('ViewManager', |
|
2580 'Next Bookmark'), |
|
2581 UI.PixmapCache.getIcon("bookmarkNext.png"), |
|
2582 QApplication.translate('ViewManager', '&Next Bookmark'), |
|
2583 QKeySequence(QApplication.translate('ViewManager', |
|
2584 "Ctrl+PgDown", "Bookmark|Next")), 0, |
|
2585 self.bookmarkActGrp, 'vm_bookmark_next') |
|
2586 self.bookmarkNextAct.setStatusTip(QApplication.translate('ViewManager', |
|
2587 'Next Bookmark')) |
|
2588 self.bookmarkNextAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2589 """<b>Next Bookmark</b>""" |
|
2590 """<p>Go to next bookmark of the current editor.</p>""" |
|
2591 )) |
|
2592 self.connect(self.bookmarkNextAct, SIGNAL('triggered()'), self.__nextBookmark) |
|
2593 self.bookmarkActions.append(self.bookmarkNextAct) |
|
2594 |
|
2595 self.bookmarkPreviousAct = E4Action(QApplication.translate('ViewManager', |
|
2596 'Previous Bookmark'), |
|
2597 UI.PixmapCache.getIcon("bookmarkPrevious.png"), |
|
2598 QApplication.translate('ViewManager', '&Previous Bookmark'), |
|
2599 QKeySequence(QApplication.translate('ViewManager', |
|
2600 "Ctrl+PgUp", "Bookmark|Previous")), |
|
2601 0, self.bookmarkActGrp, 'vm_bookmark_previous') |
|
2602 self.bookmarkPreviousAct.setStatusTip(QApplication.translate('ViewManager', |
|
2603 'Previous Bookmark')) |
|
2604 self.bookmarkPreviousAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2605 """<b>Previous Bookmark</b>""" |
|
2606 """<p>Go to previous bookmark of the current editor.</p>""" |
|
2607 )) |
|
2608 self.connect(self.bookmarkPreviousAct, SIGNAL('triggered()'), |
|
2609 self.__previousBookmark) |
|
2610 self.bookmarkActions.append(self.bookmarkPreviousAct) |
|
2611 |
|
2612 self.bookmarkClearAct = E4Action(QApplication.translate('ViewManager', |
|
2613 'Clear Bookmarks'), |
|
2614 QApplication.translate('ViewManager', '&Clear Bookmarks'), |
|
2615 QKeySequence(QApplication.translate('ViewManager', |
|
2616 "Alt+Ctrl+C", "Bookmark|Clear")), |
|
2617 0, |
|
2618 self.bookmarkActGrp, 'vm_bookmark_clear') |
|
2619 self.bookmarkClearAct.setStatusTip(QApplication.translate('ViewManager', |
|
2620 'Clear Bookmarks')) |
|
2621 self.bookmarkClearAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2622 """<b>Clear Bookmarks</b>""" |
|
2623 """<p>Clear bookmarks of all editors.</p>""" |
|
2624 )) |
|
2625 self.connect(self.bookmarkClearAct, SIGNAL('triggered()'), |
|
2626 self.__clearAllBookmarks) |
|
2627 self.bookmarkActions.append(self.bookmarkClearAct) |
|
2628 |
|
2629 self.syntaxErrorGotoAct = E4Action(QApplication.translate('ViewManager', |
|
2630 'Goto Syntax Error'), |
|
2631 UI.PixmapCache.getIcon("syntaxErrorGoto.png"), |
|
2632 QApplication.translate('ViewManager', '&Goto Syntax Error'), |
|
2633 0, 0, |
|
2634 self.bookmarkActGrp, 'vm_syntaxerror_goto') |
|
2635 self.syntaxErrorGotoAct.setStatusTip(QApplication.translate('ViewManager', |
|
2636 'Goto Syntax Error')) |
|
2637 self.syntaxErrorGotoAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2638 """<b>Goto Syntax Error</b>""" |
|
2639 """<p>Go to next syntax error of the current editor.</p>""" |
|
2640 )) |
|
2641 self.connect(self.syntaxErrorGotoAct, SIGNAL('triggered()'), self.__gotoSyntaxError) |
|
2642 self.bookmarkActions.append(self.syntaxErrorGotoAct) |
|
2643 |
|
2644 self.syntaxErrorClearAct = E4Action(QApplication.translate('ViewManager', |
|
2645 'Clear Syntax Errors'), |
|
2646 QApplication.translate('ViewManager', 'Clear &Syntax Errors'), |
|
2647 0, 0, |
|
2648 self.bookmarkActGrp, 'vm_syntaxerror_clear') |
|
2649 self.syntaxErrorClearAct.setStatusTip(QApplication.translate('ViewManager', |
|
2650 'Clear Syntax Errors')) |
|
2651 self.syntaxErrorClearAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2652 """<b>Clear Syntax Errors</b>""" |
|
2653 """<p>Clear syntax errors of all editors.</p>""" |
|
2654 )) |
|
2655 self.connect(self.syntaxErrorClearAct, SIGNAL('triggered()'), |
|
2656 self.__clearAllSyntaxErrors) |
|
2657 self.bookmarkActions.append(self.syntaxErrorClearAct) |
|
2658 |
|
2659 self.notcoveredNextAct = E4Action(QApplication.translate('ViewManager', |
|
2660 'Next uncovered line'), |
|
2661 UI.PixmapCache.getIcon("notcoveredNext.png"), |
|
2662 QApplication.translate('ViewManager', '&Next uncovered line'), |
|
2663 0, 0, |
|
2664 self.bookmarkActGrp, 'vm_uncovered_next') |
|
2665 self.notcoveredNextAct.setStatusTip(QApplication.translate('ViewManager', |
|
2666 'Next uncovered line')) |
|
2667 self.notcoveredNextAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2668 """<b>Next uncovered line</b>""" |
|
2669 """<p>Go to next line of the current editor marked as not covered.</p>""" |
|
2670 )) |
|
2671 self.connect(self.notcoveredNextAct, SIGNAL('triggered()'), self.__nextUncovered) |
|
2672 self.bookmarkActions.append(self.notcoveredNextAct) |
|
2673 |
|
2674 self.notcoveredPreviousAct = E4Action(QApplication.translate('ViewManager', |
|
2675 'Previous uncovered line'), |
|
2676 UI.PixmapCache.getIcon("notcoveredPrev.png"), |
|
2677 QApplication.translate('ViewManager', |
|
2678 '&Previous uncovered line'), |
|
2679 0, 0, |
|
2680 self.bookmarkActGrp, 'vm_uncovered_previous') |
|
2681 self.notcoveredPreviousAct.setStatusTip(QApplication.translate('ViewManager', |
|
2682 'Previous uncovered line')) |
|
2683 self.notcoveredPreviousAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2684 """<b>Previous uncovered line</b>""" |
|
2685 """<p>Go to previous line of the current editor marked""" |
|
2686 """ as not covered.</p>""" |
|
2687 )) |
|
2688 self.connect(self.notcoveredPreviousAct, SIGNAL('triggered()'), |
|
2689 self.__previousUncovered) |
|
2690 self.bookmarkActions.append(self.notcoveredPreviousAct) |
|
2691 |
|
2692 self.taskNextAct = E4Action(QApplication.translate('ViewManager', |
|
2693 'Next Task'), |
|
2694 UI.PixmapCache.getIcon("taskNext.png"), |
|
2695 QApplication.translate('ViewManager', '&Next Task'), |
|
2696 0, 0, |
|
2697 self.bookmarkActGrp, 'vm_task_next') |
|
2698 self.taskNextAct.setStatusTip(QApplication.translate('ViewManager', |
|
2699 'Next Task')) |
|
2700 self.taskNextAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2701 """<b>Next Task</b>""" |
|
2702 """<p>Go to next line of the current editor having a task.</p>""" |
|
2703 )) |
|
2704 self.connect(self.taskNextAct, SIGNAL('triggered()'), self.__nextTask) |
|
2705 self.bookmarkActions.append(self.taskNextAct) |
|
2706 |
|
2707 self.taskPreviousAct = E4Action(QApplication.translate('ViewManager', |
|
2708 'Previous Task'), |
|
2709 UI.PixmapCache.getIcon("taskPrev.png"), |
|
2710 QApplication.translate('ViewManager', |
|
2711 '&Previous Task'), |
|
2712 0, 0, |
|
2713 self.bookmarkActGrp, 'vm_task_previous') |
|
2714 self.taskPreviousAct.setStatusTip(QApplication.translate('ViewManager', |
|
2715 'Previous Task')) |
|
2716 self.taskPreviousAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2717 """<b>Previous Task</b>""" |
|
2718 """<p>Go to previous line of the current editor having a task.</p>""" |
|
2719 )) |
|
2720 self.connect(self.taskPreviousAct, SIGNAL('triggered()'), self.__previousTask) |
|
2721 self.bookmarkActions.append(self.taskPreviousAct) |
|
2722 |
|
2723 self.bookmarkActGrp.setEnabled(False) |
|
2724 |
|
2725 def initBookmarkMenu(self): |
|
2726 """ |
|
2727 Public method to create the Bookmark menu |
|
2728 |
|
2729 @return the generated menu |
|
2730 """ |
|
2731 menu = QMenu(QApplication.translate('ViewManager', '&Bookmarks'), self.ui) |
|
2732 self.bookmarksMenu = QMenu(QApplication.translate('ViewManager', '&Bookmarks'), |
|
2733 menu) |
|
2734 menu.setTearOffEnabled(True) |
|
2735 |
|
2736 menu.addAction(self.bookmarkToggleAct) |
|
2737 menu.addAction(self.bookmarkNextAct) |
|
2738 menu.addAction(self.bookmarkPreviousAct) |
|
2739 menu.addAction(self.bookmarkClearAct) |
|
2740 menu.addSeparator() |
|
2741 self.menuBookmarksAct = menu.addMenu(self.bookmarksMenu) |
|
2742 menu.addSeparator() |
|
2743 menu.addAction(self.syntaxErrorGotoAct) |
|
2744 menu.addAction(self.syntaxErrorClearAct) |
|
2745 menu.addSeparator() |
|
2746 menu.addAction(self.notcoveredNextAct) |
|
2747 menu.addAction(self.notcoveredPreviousAct) |
|
2748 menu.addSeparator() |
|
2749 menu.addAction(self.taskNextAct) |
|
2750 menu.addAction(self.taskPreviousAct) |
|
2751 |
|
2752 self.connect(self.bookmarksMenu, SIGNAL('aboutToShow()'), |
|
2753 self.__showBookmarksMenu) |
|
2754 self.connect(self.bookmarksMenu, SIGNAL('triggered(QAction *)'), |
|
2755 self.__bookmarkSelected) |
|
2756 self.connect(menu, SIGNAL('aboutToShow()'), self.__showBookmarkMenu) |
|
2757 |
|
2758 return menu |
|
2759 |
|
2760 def initBookmarkToolbar(self, toolbarManager): |
|
2761 """ |
|
2762 Public method to create the Bookmark toolbar |
|
2763 |
|
2764 @param toolbarManager reference to a toolbar manager object (E4ToolBarManager) |
|
2765 @return the generated toolbar |
|
2766 """ |
|
2767 tb = QToolBar(QApplication.translate('ViewManager', 'Bookmarks'), self.ui) |
|
2768 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
2769 tb.setObjectName("BookmarksToolbar") |
|
2770 tb.setToolTip(QApplication.translate('ViewManager', 'Bookmarks')) |
|
2771 |
|
2772 tb.addAction(self.bookmarkToggleAct) |
|
2773 tb.addAction(self.bookmarkNextAct) |
|
2774 tb.addAction(self.bookmarkPreviousAct) |
|
2775 tb.addSeparator() |
|
2776 tb.addAction(self.syntaxErrorGotoAct) |
|
2777 tb.addSeparator() |
|
2778 tb.addAction(self.taskNextAct) |
|
2779 tb.addAction(self.taskPreviousAct) |
|
2780 |
|
2781 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
2782 toolbarManager.addAction(self.notcoveredNextAct, tb.windowTitle()) |
|
2783 toolbarManager.addAction(self.notcoveredPreviousAct, tb.windowTitle()) |
|
2784 |
|
2785 return tb |
|
2786 |
|
2787 ################################################################## |
|
2788 ## Initialize the spell checking related actions |
|
2789 ################################################################## |
|
2790 |
|
2791 def __initSpellingActions(self): |
|
2792 """ |
|
2793 Private method to initialize the spell checking actions. |
|
2794 """ |
|
2795 self.spellingActGrp = createActionGroup(self) |
|
2796 |
|
2797 self.spellCheckAct = E4Action(QApplication.translate('ViewManager', |
|
2798 'Spell check'), |
|
2799 UI.PixmapCache.getIcon("spellchecking.png"), |
|
2800 QApplication.translate('ViewManager', |
|
2801 '&Spell Check...'), |
|
2802 QKeySequence(QApplication.translate('ViewManager', |
|
2803 "Shift+F7", "Spelling|Spell Check")), |
|
2804 0, |
|
2805 self.spellingActGrp, 'vm_spelling_spellcheck') |
|
2806 self.spellCheckAct.setStatusTip(QApplication.translate('ViewManager', |
|
2807 'Perform spell check of current editor')) |
|
2808 self.spellCheckAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2809 """<b>Spell check</b>""" |
|
2810 """<p>Perform a spell check of the current editor.</p>""" |
|
2811 )) |
|
2812 self.connect(self.spellCheckAct, SIGNAL('triggered()'), self.__spellCheck) |
|
2813 self.spellingActions.append(self.spellCheckAct) |
|
2814 |
|
2815 self.autoSpellCheckAct = E4Action(QApplication.translate('ViewManager', |
|
2816 'Automatic spell checking'), |
|
2817 UI.PixmapCache.getIcon("autospellchecking.png"), |
|
2818 QApplication.translate('ViewManager', |
|
2819 '&Automatic spell checking'), |
|
2820 0, 0, |
|
2821 self.spellingActGrp, 'vm_spelling_autospellcheck') |
|
2822 self.autoSpellCheckAct.setStatusTip(QApplication.translate('ViewManager', |
|
2823 '(De-)Activate automatic spell checking')) |
|
2824 self.autoSpellCheckAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2825 """<b>Automatic spell checking</b>""" |
|
2826 """<p>Activate or deactivate the automatic spell checking function of""" |
|
2827 """ all editors.</p>""" |
|
2828 )) |
|
2829 self.autoSpellCheckAct.setCheckable(True) |
|
2830 self.autoSpellCheckAct.setChecked( |
|
2831 Preferences.getEditor("AutoSpellCheckingEnabled")) |
|
2832 self.connect(self.autoSpellCheckAct, SIGNAL('triggered()'), |
|
2833 self.__setAutoSpellChecking) |
|
2834 self.spellingActions.append(self.autoSpellCheckAct) |
|
2835 |
|
2836 self.__enableSpellingActions() |
|
2837 |
|
2838 def __enableSpellingActions(self): |
|
2839 """ |
|
2840 Private method to set the enabled state of the spelling actions. |
|
2841 """ |
|
2842 spellingAvailable = SpellChecker.isAvailable() |
|
2843 |
|
2844 self.spellCheckAct.setEnabled(len(self.editors) != 0 and spellingAvailable) |
|
2845 self.autoSpellCheckAct.setEnabled(spellingAvailable) |
|
2846 |
|
2847 def addToExtrasMenu(self, menu): |
|
2848 """ |
|
2849 Public method to add some actions to the extras menu. |
|
2850 """ |
|
2851 menu.addAction(self.spellCheckAct) |
|
2852 menu.addAction(self.autoSpellCheckAct) |
|
2853 menu.addSeparator() |
|
2854 |
|
2855 def initSpellingToolbar(self, toolbarManager): |
|
2856 """ |
|
2857 Public method to create the Spelling toolbar |
|
2858 |
|
2859 @param toolbarManager reference to a toolbar manager object (E4ToolBarManager) |
|
2860 @return the generated toolbar |
|
2861 """ |
|
2862 tb = QToolBar(QApplication.translate('ViewManager', 'Spelling'), self.ui) |
|
2863 tb.setIconSize(UI.Config.ToolBarIconSize) |
|
2864 tb.setObjectName("SpellingToolbar") |
|
2865 tb.setToolTip(QApplication.translate('ViewManager', 'Spelling')) |
|
2866 |
|
2867 tb.addAction(self.spellCheckAct) |
|
2868 tb.addAction(self.autoSpellCheckAct) |
|
2869 |
|
2870 toolbarManager.addToolBar(tb, tb.windowTitle()) |
|
2871 |
|
2872 return tb |
|
2873 |
|
2874 ################################################################## |
|
2875 ## Methods and slots that deal with file and window handling |
|
2876 ################################################################## |
|
2877 |
|
2878 def openFiles(self, prog = None): |
|
2879 """ |
|
2880 Public slot to open some files. |
|
2881 |
|
2882 @param prog name of file to be opened (string) |
|
2883 """ |
|
2884 # Get the file name if one wasn't specified. |
|
2885 if prog is None: |
|
2886 # set the cwd of the dialog based on the following search criteria: |
|
2887 # 1: Directory of currently active editor |
|
2888 # 2: Directory of currently active project |
|
2889 # 3: CWD |
|
2890 filter = self._getOpenFileFilter() |
|
2891 progs = QFileDialog.getOpenFileNamesAndFilter(\ |
|
2892 self.ui, |
|
2893 QApplication.translate('ViewManager', "Open files"), |
|
2894 self._getOpenStartDir(), |
|
2895 QScintilla.Lexers.getOpenFileFiltersList(True, True), |
|
2896 filter |
|
2897 )[0] |
|
2898 else: |
|
2899 progs = [prog] |
|
2900 |
|
2901 for prog in progs: |
|
2902 prog = Utilities.normabspath(prog) |
|
2903 # Open up the new files. |
|
2904 self.openSourceFile(prog) |
|
2905 |
|
2906 def checkDirty(self, editor, autosave = False): |
|
2907 """ |
|
2908 Public method to check dirty status and open a message window. |
|
2909 |
|
2910 @param editor editor window to check |
|
2911 @param autosave flag indicating that the file should be saved |
|
2912 automatically (boolean) |
|
2913 @return flag indicating successful reset of the dirty flag (boolean) |
|
2914 """ |
|
2915 if editor.isModified(): |
|
2916 fn = editor.getFileName() |
|
2917 # ignore the dirty status, if there is more than one open editor |
|
2918 # for the same file |
|
2919 if fn and self.getOpenEditorCount(fn) > 1: |
|
2920 return True |
|
2921 |
|
2922 if fn is None: |
|
2923 fn = editor.getNoName() |
|
2924 autosave = False |
|
2925 if autosave: |
|
2926 res = QMessageBox.Save |
|
2927 else: |
|
2928 res = QMessageBox.warning(self.ui, |
|
2929 QApplication.translate('ViewManager', "File Modified"), |
|
2930 QApplication.translate('ViewManager', |
|
2931 """<p>The file <b>{0}</b> has unsaved changes.</p>""") |
|
2932 .format(fn), |
|
2933 QMessageBox.StandardButtons(\ |
|
2934 QMessageBox.Abort | \ |
|
2935 QMessageBox.Discard | \ |
|
2936 QMessageBox.Save), |
|
2937 QMessageBox.Save) |
|
2938 if res == QMessageBox.Save: |
|
2939 ok, newName = editor.saveFile() |
|
2940 if ok: |
|
2941 self.setEditorName(editor, newName) |
|
2942 return ok |
|
2943 elif res == QMessageBox.Abort or res == QMessageBox.Cancel: |
|
2944 return False |
|
2945 |
|
2946 return True |
|
2947 |
|
2948 def checkAllDirty(self): |
|
2949 """ |
|
2950 Public method to check the dirty status of all editors. |
|
2951 |
|
2952 @return flag indicating successful reset of all dirty flags (boolean) |
|
2953 """ |
|
2954 for editor in self.editors: |
|
2955 if not self.checkDirty(editor): |
|
2956 return False |
|
2957 |
|
2958 return True |
|
2959 |
|
2960 def closeEditor(self, editor): |
|
2961 """ |
|
2962 Public method to close an editor window. |
|
2963 |
|
2964 @param editor editor window to be closed |
|
2965 @return flag indicating success (boolean) |
|
2966 """ |
|
2967 # save file if necessary |
|
2968 if not self.checkDirty(editor): |
|
2969 return False |
|
2970 |
|
2971 # get the filename of the editor for later use |
|
2972 fn = editor.getFileName() |
|
2973 |
|
2974 # remove the window |
|
2975 self._removeView(editor) |
|
2976 self.editors.remove(editor) |
|
2977 |
|
2978 # send a signal, if it was the last editor for this filename |
|
2979 if fn and self.getOpenEditor(fn) is None: |
|
2980 self.emit(SIGNAL('editorClosed'), fn) |
|
2981 self.emit(SIGNAL('editorClosedEd'), editor) |
|
2982 |
|
2983 # send a signal, if it was the very last editor |
|
2984 if not len(self.editors): |
|
2985 self.__lastEditorClosed() |
|
2986 self.emit(SIGNAL('lastEditorClosed')) |
|
2987 |
|
2988 return True |
|
2989 |
|
2990 def closeCurrentWindow(self): |
|
2991 """ |
|
2992 Public method to close the current window. |
|
2993 |
|
2994 @return flag indicating success (boolean) |
|
2995 """ |
|
2996 aw = self.activeWindow() |
|
2997 if aw is None: |
|
2998 return False |
|
2999 |
|
3000 res = self.closeEditor(aw) |
|
3001 if res and aw == self.currentEditor: |
|
3002 self.currentEditor = None |
|
3003 |
|
3004 return res |
|
3005 |
|
3006 def closeAllWindows(self): |
|
3007 """ |
|
3008 Private method to close all editor windows via file menu. |
|
3009 """ |
|
3010 savedEditors = self.editors[:] |
|
3011 for editor in savedEditors: |
|
3012 self.closeEditor(editor) |
|
3013 |
|
3014 def closeWindow(self, fn): |
|
3015 """ |
|
3016 Public method to close an arbitrary source editor. |
|
3017 |
|
3018 @param fn filename of editor to be closed |
|
3019 @return flag indicating success (boolean) |
|
3020 """ |
|
3021 for editor in self.editors: |
|
3022 if Utilities.samepath(fn, editor.getFileName()): |
|
3023 break |
|
3024 else: |
|
3025 return True |
|
3026 |
|
3027 res = self.closeEditor(editor) |
|
3028 if res and editor == self.currentEditor: |
|
3029 self.currentEditor = None |
|
3030 |
|
3031 return res |
|
3032 |
|
3033 def closeEditorWindow(self, editor): |
|
3034 """ |
|
3035 Public method to close an arbitrary source editor. |
|
3036 |
|
3037 @param editor editor to be closed |
|
3038 """ |
|
3039 if editor is None: |
|
3040 return |
|
3041 |
|
3042 res = self.closeEditor(editor) |
|
3043 if res and editor == self.currentEditor: |
|
3044 self.currentEditor = None |
|
3045 |
|
3046 def exit(self): |
|
3047 """ |
|
3048 Public method to handle the debugged program terminating. |
|
3049 """ |
|
3050 if self.currentEditor is not None: |
|
3051 self.currentEditor.highlight() |
|
3052 self.currentEditor = None |
|
3053 |
|
3054 self.__setSbFile() |
|
3055 |
|
3056 def openSourceFile(self, fn, lineno = None, filetype = "", selection = None): |
|
3057 """ |
|
3058 Public slot to display a file in an editor. |
|
3059 |
|
3060 @param fn name of file to be opened |
|
3061 @param lineno line number to place the cursor at |
|
3062 @param filetype type of the source file (string) |
|
3063 @param selection tuple (start, end) of an area to be selected |
|
3064 """ |
|
3065 try: |
|
3066 newWin, editor = self.getEditor(fn, filetype = filetype) |
|
3067 except IOError: |
|
3068 return |
|
3069 |
|
3070 if newWin: |
|
3071 self._modificationStatusChanged(editor.isModified(), editor) |
|
3072 self._checkActions(editor) |
|
3073 |
|
3074 if lineno is not None and lineno >= 0: |
|
3075 editor.ensureVisibleTop(lineno) |
|
3076 editor.gotoLine(lineno) |
|
3077 |
|
3078 if selection is not None: |
|
3079 editor.setSelection(lineno - 1, selection[0], lineno - 1, selection[1]) |
|
3080 |
|
3081 # insert filename into list of recently opened files |
|
3082 self.addToRecentList(fn) |
|
3083 |
|
3084 def __connectEditor(self, editor): |
|
3085 """ |
|
3086 Private method to establish all editor connections. |
|
3087 |
|
3088 @param editor reference to the editor object to be connected |
|
3089 """ |
|
3090 self.connect(editor, SIGNAL('modificationStatusChanged'), |
|
3091 self._modificationStatusChanged) |
|
3092 self.connect(editor, SIGNAL('cursorChanged'), self.__cursorChanged) |
|
3093 self.connect(editor, SIGNAL('editorSaved'), self.__editorSaved) |
|
3094 self.connect(editor, SIGNAL('breakpointToggled'), self.__breakpointToggled) |
|
3095 self.connect(editor, SIGNAL('bookmarkToggled'), self.__bookmarkToggled) |
|
3096 self.connect(editor, SIGNAL('syntaxerrorToggled'), self._syntaxErrorToggled) |
|
3097 self.connect(editor, SIGNAL('coverageMarkersShown'), |
|
3098 self.__coverageMarkersShown) |
|
3099 self.connect(editor, SIGNAL('autoCompletionAPIsAvailable'), |
|
3100 self.__editorAutoCompletionAPIsAvailable) |
|
3101 self.connect(editor, SIGNAL('undoAvailable'), self.undoAct.setEnabled) |
|
3102 self.connect(editor, SIGNAL('redoAvailable'), self.redoAct.setEnabled) |
|
3103 self.connect(editor, SIGNAL('taskMarkersUpdated'), self.__taskMarkersUpdated) |
|
3104 self.connect(editor, SIGNAL('languageChanged'), self.__editorConfigChanged) |
|
3105 self.connect(editor, SIGNAL('eolChanged'), self.__editorConfigChanged) |
|
3106 self.connect(editor, SIGNAL('encodingChanged'), self.__editorConfigChanged) |
|
3107 self.connect(editor, SIGNAL("selectionChanged()"), |
|
3108 self.searchDlg.selectionChanged) |
|
3109 self.connect(editor, SIGNAL("selectionChanged()"), |
|
3110 self.replaceDlg.selectionChanged) |
|
3111 |
|
3112 def newEditorView(self, fn, caller, filetype = ""): |
|
3113 """ |
|
3114 Public method to create a new editor displaying the given document. |
|
3115 |
|
3116 @param fn filename of this view |
|
3117 @param caller reference to the editor calling this method |
|
3118 @param filetype type of the source file (string) |
|
3119 """ |
|
3120 editor = self.cloneEditor(caller, filetype, fn) |
|
3121 |
|
3122 self._addView(editor, fn, caller.getNoName()) |
|
3123 self._modificationStatusChanged(editor.isModified(), editor) |
|
3124 self._checkActions(editor) |
|
3125 |
|
3126 def cloneEditor(self, caller, filetype, fn): |
|
3127 """ |
|
3128 Public method to clone an editor displaying the given document. |
|
3129 |
|
3130 @param caller reference to the editor calling this method |
|
3131 @param filetype type of the source file (string) |
|
3132 @param fn filename of this view |
|
3133 @return reference to the new editor object (Editor.Editor) |
|
3134 """ |
|
3135 editor = Editor(self.dbs, fn, self, filetype = filetype, editor = caller, |
|
3136 tv = e4App().getObject("TaskViewer")) |
|
3137 self.editors.append(editor) |
|
3138 self.__connectEditor(editor) |
|
3139 self.__editorOpened() |
|
3140 self.emit(SIGNAL('editorOpened'), fn) |
|
3141 self.emit(SIGNAL('editorOpenedEd'), editor) |
|
3142 |
|
3143 return editor |
|
3144 |
|
3145 def addToRecentList(self, fn): |
|
3146 """ |
|
3147 Public slot to add a filename to the list of recently opened files. |
|
3148 |
|
3149 @param fn name of the file to be added |
|
3150 """ |
|
3151 if fn in self.recent: |
|
3152 self.recent.remove(fn) |
|
3153 self.recent.insert(0, fn) |
|
3154 maxRecent = Preferences.getUI("RecentNumber") |
|
3155 if len(self.recent) > maxRecent: |
|
3156 self.recent = self.recent[:maxRecent] |
|
3157 self.__saveRecent() |
|
3158 |
|
3159 def showDebugSource(self, fn, line): |
|
3160 """ |
|
3161 Public method to open the given file and highlight the given line in it. |
|
3162 |
|
3163 @param fn filename of editor to update (string) |
|
3164 @param line line number to highlight (int) |
|
3165 """ |
|
3166 self.openSourceFile(fn, line) |
|
3167 self.setFileLine(fn, line) |
|
3168 |
|
3169 def setFileLine(self, fn, line, error = False, syntaxError = False): |
|
3170 """ |
|
3171 Public method to update the user interface when the current program |
|
3172 or line changes. |
|
3173 |
|
3174 @param fn filename of editor to update (string) |
|
3175 @param line line number to highlight (int) |
|
3176 @param error flag indicating an error highlight (boolean) |
|
3177 @param syntaxError flag indicating a syntax error |
|
3178 """ |
|
3179 try: |
|
3180 newWin, self.currentEditor = self.getEditor(fn) |
|
3181 except IOError: |
|
3182 return |
|
3183 |
|
3184 enc = self.currentEditor.getEncoding() |
|
3185 lang = self.currentEditor.getLanguage() |
|
3186 eol = self.currentEditor.getEolIndicator() |
|
3187 self.__setSbFile(fn, line, encoding = enc, language = lang, eol = eol) |
|
3188 |
|
3189 # Change the highlighted line. |
|
3190 self.currentEditor.highlight(line, error, syntaxError) |
|
3191 |
|
3192 self.currentEditor.highlightVisible() |
|
3193 self._checkActions(self.currentEditor, False) |
|
3194 |
|
3195 def __setSbFile(self, fn = None, line = None, pos = None, |
|
3196 encoding = None, language = None, eol = None): |
|
3197 """ |
|
3198 Private method to set the file info in the status bar. |
|
3199 |
|
3200 @param fn filename to display (string) |
|
3201 @param line line number to display (int) |
|
3202 @param pos character position to display (int) |
|
3203 @param encoding encoding name to display (string) |
|
3204 @param language language to display (string) |
|
3205 @param eol eol indicator to display (string) |
|
3206 """ |
|
3207 if fn is None: |
|
3208 fn = '' |
|
3209 writ = ' ' |
|
3210 else: |
|
3211 if QFileInfo(fn).isWritable(): |
|
3212 writ = ' rw' |
|
3213 else: |
|
3214 writ = ' ro' |
|
3215 self.sbWritable.setText(writ) |
|
3216 self.sbFile.setTextPath(QApplication.translate('ViewManager', 'File: {0}'), fn) |
|
3217 |
|
3218 if line is None: |
|
3219 line = '' |
|
3220 self.sbLine.setText(QApplication.translate('ViewManager', 'Line: {0:5}') |
|
3221 .format(line)) |
|
3222 |
|
3223 if pos is None: |
|
3224 pos = '' |
|
3225 self.sbPos.setText(QApplication.translate('ViewManager', 'Pos: {0:5}') |
|
3226 .format(pos)) |
|
3227 |
|
3228 if encoding is None: |
|
3229 encoding = '' |
|
3230 self.sbEnc.setText(encoding) |
|
3231 |
|
3232 if language is None: |
|
3233 language = '' |
|
3234 self.sbLang.setText(language) |
|
3235 |
|
3236 if eol is None: |
|
3237 eol = '' |
|
3238 self.sbEol.setText(eol) |
|
3239 |
|
3240 def unhighlight(self, current = False): |
|
3241 """ |
|
3242 Public method to switch off all highlights. |
|
3243 |
|
3244 @param current flag indicating only the current editor should be unhighlighted |
|
3245 (boolean) |
|
3246 """ |
|
3247 if current: |
|
3248 if self.currentEditor is not None: |
|
3249 self.currentEditor.highlight() |
|
3250 else: |
|
3251 for editor in self.editors: |
|
3252 editor.highlight() |
|
3253 |
|
3254 def getOpenFilenames(self): |
|
3255 """ |
|
3256 Public method returning a list of the filenames of all editors. |
|
3257 |
|
3258 @return list of all opened filenames (list of strings) |
|
3259 """ |
|
3260 filenames = [] |
|
3261 for editor in self.editors: |
|
3262 fn = editor.getFileName() |
|
3263 if fn is not None and fn not in filenames: |
|
3264 filenames.append(fn) |
|
3265 |
|
3266 return filenames |
|
3267 |
|
3268 def getEditor(self, fn, filetype = ""): |
|
3269 """ |
|
3270 Public method to return the editor displaying the given file. |
|
3271 |
|
3272 If there is no editor with the given file, a new editor window is |
|
3273 created. |
|
3274 |
|
3275 @param fn filename to look for |
|
3276 @param filetype type of the source file (string) |
|
3277 @return tuple of two values giving a flag indicating a new window creation and |
|
3278 a reference to the editor displaying this file |
|
3279 """ |
|
3280 newWin = False |
|
3281 editor = self.activeWindow() |
|
3282 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
|
3283 for editor in self.editors: |
|
3284 if Utilities.samepath(fn, editor.getFileName()): |
|
3285 break |
|
3286 else: |
|
3287 editor = Editor(self.dbs, fn, self, filetype = filetype, |
|
3288 tv = e4App().getObject("TaskViewer")) |
|
3289 self.editors.append(editor) |
|
3290 self.__connectEditor(editor) |
|
3291 self.__editorOpened() |
|
3292 self.emit(SIGNAL('editorOpened'), fn) |
|
3293 self.emit(SIGNAL('editorOpenedEd'), editor) |
|
3294 newWin = True |
|
3295 |
|
3296 if newWin: |
|
3297 self._addView(editor, fn) |
|
3298 else: |
|
3299 self._showView(editor, fn) |
|
3300 |
|
3301 return (newWin, editor) |
|
3302 |
|
3303 def getOpenEditors(self): |
|
3304 """ |
|
3305 Public method to get references to all open editors. |
|
3306 |
|
3307 @return list of references to all open editors (list of QScintilla.editor) |
|
3308 """ |
|
3309 return self.editors |
|
3310 |
|
3311 def getOpenEditorsCount(self): |
|
3312 """ |
|
3313 Public method to get the number of open editors. |
|
3314 |
|
3315 @return number of open editors (integer) |
|
3316 """ |
|
3317 return len(self.editors) |
|
3318 |
|
3319 def getOpenEditor(self, fn): |
|
3320 """ |
|
3321 Public method to return the editor displaying the given file. |
|
3322 |
|
3323 @param fn filename to look for |
|
3324 @return a reference to the editor displaying this file or None, if |
|
3325 no editor was found |
|
3326 """ |
|
3327 for editor in self.editors: |
|
3328 if Utilities.samepath(fn, editor.getFileName()): |
|
3329 return editor |
|
3330 |
|
3331 return None |
|
3332 |
|
3333 def getOpenEditorCount(self, fn): |
|
3334 """ |
|
3335 Public method to return the count of editors displaying the given file. |
|
3336 |
|
3337 @param fn filename to look for |
|
3338 @return count of editors displaying this file (integer) |
|
3339 """ |
|
3340 count = 0 |
|
3341 for editor in self.editors: |
|
3342 if Utilities.samepath(fn, editor.getFileName()): |
|
3343 count += 1 |
|
3344 return count |
|
3345 |
|
3346 def getActiveName(self): |
|
3347 """ |
|
3348 Public method to retrieve the filename of the active window. |
|
3349 |
|
3350 @return filename of active window (string) |
|
3351 """ |
|
3352 aw = self.activeWindow() |
|
3353 if aw: |
|
3354 return aw.getFileName() |
|
3355 else: |
|
3356 return None |
|
3357 |
|
3358 def saveEditor(self, fn): |
|
3359 """ |
|
3360 Public method to save a named editor file. |
|
3361 |
|
3362 @param fn filename of editor to be saved (string) |
|
3363 @return flag indicating success (boolean) |
|
3364 """ |
|
3365 for editor in self.editors: |
|
3366 if Utilities.samepath(fn, editor.getFileName()): |
|
3367 break |
|
3368 else: |
|
3369 return True |
|
3370 |
|
3371 if not editor.isModified(): |
|
3372 return True |
|
3373 else: |
|
3374 ok = editor.saveFile()[0] |
|
3375 return ok |
|
3376 |
|
3377 def saveEditorEd(self, ed): |
|
3378 """ |
|
3379 Public slot to save the contents of an editor. |
|
3380 |
|
3381 @param ed editor to be saved |
|
3382 @return flag indicating success (boolean) |
|
3383 """ |
|
3384 if ed: |
|
3385 if not ed.isModified(): |
|
3386 return True |
|
3387 else: |
|
3388 ok, newName = ed.saveFile() |
|
3389 if ok: |
|
3390 self.setEditorName(ed, newName) |
|
3391 return ok |
|
3392 else: |
|
3393 return False |
|
3394 |
|
3395 def saveCurrentEditor(self): |
|
3396 """ |
|
3397 Public slot to save the contents of the current editor. |
|
3398 """ |
|
3399 aw = self.activeWindow() |
|
3400 self.saveEditorEd(aw) |
|
3401 |
|
3402 def saveAsEditorEd(self, ed): |
|
3403 """ |
|
3404 Public slot to save the contents of an editor to a new file. |
|
3405 |
|
3406 @param ed editor to be saved |
|
3407 """ |
|
3408 if ed: |
|
3409 ok, newName = ed.saveFileAs() |
|
3410 if ok: |
|
3411 self.setEditorName(ed, newName) |
|
3412 else: |
|
3413 return |
|
3414 |
|
3415 def saveAsCurrentEditor(self): |
|
3416 """ |
|
3417 Public slot to save the contents of the current editor to a new file. |
|
3418 """ |
|
3419 aw = self.activeWindow() |
|
3420 self.saveAsEditorEd(aw) |
|
3421 |
|
3422 def saveEditorsList(self, editors): |
|
3423 """ |
|
3424 Public slot to save a list of editors. |
|
3425 |
|
3426 @param editors list of editors to be saved |
|
3427 """ |
|
3428 for editor in editors: |
|
3429 ok, newName = editor.saveFile() |
|
3430 if ok: |
|
3431 self.setEditorName(editor, newName) |
|
3432 |
|
3433 def saveAllEditors(self): |
|
3434 """ |
|
3435 Public slot to save the contents of all editors. |
|
3436 """ |
|
3437 for editor in self.editors: |
|
3438 ok, newName = editor.saveFile() |
|
3439 if ok: |
|
3440 self.setEditorName(editor, newName) |
|
3441 |
|
3442 # restart autosave timer |
|
3443 if self.autosaveInterval > 0: |
|
3444 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
3445 |
|
3446 def saveEditorToProjectEd(self, ed): |
|
3447 """ |
|
3448 Public slot to save the contents of an editor to the current project. |
|
3449 |
|
3450 @param ed editor to be saved |
|
3451 """ |
|
3452 pro = e4App().getObject("Project") |
|
3453 path = pro.ppath |
|
3454 if ed: |
|
3455 ok, newName = ed.saveFileAs(path) |
|
3456 if ok: |
|
3457 self.setEditorName(ed, newName) |
|
3458 pro.appendFile(newName) |
|
3459 ed.addedToProject() |
|
3460 else: |
|
3461 return |
|
3462 |
|
3463 def saveCurrentEditorToProject(self): |
|
3464 """ |
|
3465 Public slot to save the contents of the current editor to the current project. |
|
3466 """ |
|
3467 aw = self.activeWindow() |
|
3468 self.saveEditorToProjectEd(aw) |
|
3469 |
|
3470 def __exportMenuTriggered(self, act): |
|
3471 """ |
|
3472 Private method to handle the selection of an export format. |
|
3473 |
|
3474 @param act reference to the action that was triggered (QAction) |
|
3475 """ |
|
3476 aw = self.activeWindow() |
|
3477 if aw: |
|
3478 exporterFormat = act.data().toString() |
|
3479 aw.exportFile(exporterFormat) |
|
3480 |
|
3481 def newEditor(self): |
|
3482 """ |
|
3483 Public slot to generate a new empty editor. |
|
3484 """ |
|
3485 editor = Editor(self.dbs, None, self, tv = e4App().getObject("TaskViewer")) |
|
3486 self.editors.append(editor) |
|
3487 self.__connectEditor(editor) |
|
3488 self._addView(editor, None) |
|
3489 self.__editorOpened() |
|
3490 self._checkActions(editor) |
|
3491 self.emit(SIGNAL('editorOpened'), "") |
|
3492 self.emit(SIGNAL('editorOpenedEd'), editor) |
|
3493 |
|
3494 def printEditor(self, editor): |
|
3495 """ |
|
3496 Public slot to print an editor. |
|
3497 |
|
3498 @param editor editor to be printed |
|
3499 """ |
|
3500 if editor: |
|
3501 editor.printFile() |
|
3502 else: |
|
3503 return |
|
3504 |
|
3505 def printCurrentEditor(self): |
|
3506 """ |
|
3507 Public slot to print the contents of the current editor. |
|
3508 """ |
|
3509 aw = self.activeWindow() |
|
3510 self.printEditor(aw) |
|
3511 |
|
3512 def printPreviewCurrentEditor(self): |
|
3513 """ |
|
3514 Public slot to show a print preview of the current editor. |
|
3515 """ |
|
3516 aw = self.activeWindow() |
|
3517 if aw: |
|
3518 aw.printPreviewFile() |
|
3519 |
|
3520 def __showFileMenu(self): |
|
3521 """ |
|
3522 Private method to set up the file menu. |
|
3523 """ |
|
3524 self.menuRecentAct.setEnabled(len(self.recent) > 0) |
|
3525 |
|
3526 def __showRecentMenu(self): |
|
3527 """ |
|
3528 Private method to set up recent files menu. |
|
3529 """ |
|
3530 self.__loadRecent() |
|
3531 |
|
3532 self.recentMenu.clear() |
|
3533 |
|
3534 idx = 1 |
|
3535 for rs in self.recent: |
|
3536 if idx < 10: |
|
3537 formatStr = '&%d. %s' |
|
3538 else: |
|
3539 formatStr = '%d. %s' |
|
3540 act = self.recentMenu.addAction(\ |
|
3541 formatStr % (idx, |
|
3542 Utilities.compactPath(rs, self.ui.maxMenuFilePathLen))) |
|
3543 act.setData(QVariant(rs)) |
|
3544 act.setEnabled(QFileInfo(rs).exists()) |
|
3545 idx += 1 |
|
3546 |
|
3547 self.recentMenu.addSeparator() |
|
3548 self.recentMenu.addAction(\ |
|
3549 QApplication.translate('ViewManager', '&Clear'), self.__clearRecent) |
|
3550 |
|
3551 def __openSourceFile(self, act): |
|
3552 """ |
|
3553 Private method to open a file from the list of rencently opened files. |
|
3554 |
|
3555 @param act reference to the action that triggered (QAction) |
|
3556 """ |
|
3557 file = act.data().toString() |
|
3558 if file: |
|
3559 self.openSourceFile(file) |
|
3560 |
|
3561 def __clearRecent(self): |
|
3562 """ |
|
3563 Private method to clear the recent files menu. |
|
3564 """ |
|
3565 self.recent = [] |
|
3566 |
|
3567 def __showBookmarkedMenu(self): |
|
3568 """ |
|
3569 Private method to set up bookmarked files menu. |
|
3570 """ |
|
3571 self.bookmarkedMenu.clear() |
|
3572 |
|
3573 for rp in self.bookmarked: |
|
3574 act = self.bookmarkedMenu.addAction(\ |
|
3575 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)) |
|
3576 act.setData(QVariant(rp)) |
|
3577 act.setEnabled(QFileInfo(rp).exists()) |
|
3578 |
|
3579 if len(self.bookmarked): |
|
3580 self.bookmarkedMenu.addSeparator() |
|
3581 self.bookmarkedMenu.addAction(\ |
|
3582 QApplication.translate('ViewManager', '&Add'), self.__addBookmarked) |
|
3583 self.bookmarkedMenu.addAction(\ |
|
3584 QApplication.translate('ViewManager', '&Edit...'), self.__editBookmarked) |
|
3585 self.bookmarkedMenu.addAction(\ |
|
3586 QApplication.translate('ViewManager', '&Clear'), self.__clearBookmarked) |
|
3587 |
|
3588 def __addBookmarked(self): |
|
3589 """ |
|
3590 Private method to add the current file to the list of bookmarked files. |
|
3591 """ |
|
3592 an = self.getActiveName() |
|
3593 if an is not None and an not in self.bookmarked: |
|
3594 self.bookmarked.append(an) |
|
3595 |
|
3596 def __editBookmarked(self): |
|
3597 """ |
|
3598 Private method to edit the list of bookmarked files. |
|
3599 """ |
|
3600 dlg = BookmarkedFilesDialog(self.bookmarked, self.ui) |
|
3601 if dlg.exec_() == QDialog.Accepted: |
|
3602 self.bookmarked = dlg.getBookmarkedFiles() |
|
3603 |
|
3604 def __clearBookmarked(self): |
|
3605 """ |
|
3606 Private method to clear the bookmarked files menu. |
|
3607 """ |
|
3608 self.bookmarked = [] |
|
3609 |
|
3610 def newProject(self): |
|
3611 """ |
|
3612 Public slot to handle the NewProject signal. |
|
3613 """ |
|
3614 self.saveToProjectAct.setEnabled(True) |
|
3615 |
|
3616 def projectOpened(self): |
|
3617 """ |
|
3618 Public slot to handle the projectOpened signal. |
|
3619 """ |
|
3620 self.saveToProjectAct.setEnabled(True) |
|
3621 for editor in self.editors: |
|
3622 editor.setSpellingForProject() |
|
3623 |
|
3624 def projectClosed(self): |
|
3625 """ |
|
3626 Public slot to handle the projectClosed signal. |
|
3627 """ |
|
3628 self.saveToProjectAct.setEnabled(False) |
|
3629 |
|
3630 def projectFileRenamed(self, oldfn, newfn): |
|
3631 """ |
|
3632 Public slot to handle the projectFileRenamed signal. |
|
3633 |
|
3634 @param oldfn old filename of the file (string) |
|
3635 @param newfn new filename of the file (string) |
|
3636 """ |
|
3637 editor = self.getOpenEditor(oldfn) |
|
3638 if editor: |
|
3639 editor.fileRenamed(newfn) |
|
3640 |
|
3641 def projectLexerAssociationsChanged(self): |
|
3642 """ |
|
3643 Public slot to handle changes of the project lexer associations. |
|
3644 """ |
|
3645 for editor in self.editors: |
|
3646 editor.projectLexerAssociationsChanged() |
|
3647 |
|
3648 def enableEditorsCheckFocusIn(self, enabled): |
|
3649 """ |
|
3650 Public method to set a flag enabling the editors to perform focus in checks. |
|
3651 |
|
3652 @param enabled flag indicating focus in checks should be performed (boolean) |
|
3653 """ |
|
3654 self.editorsCheckFocusIn = enabled |
|
3655 |
|
3656 def editorsCheckFocusInEnabled(self): |
|
3657 """ |
|
3658 Public method returning the flag indicating editors should perform |
|
3659 focus in checks. |
|
3660 |
|
3661 @return flag indicating focus in checks should be performed (boolean) |
|
3662 """ |
|
3663 return self.editorsCheckFocusIn |
|
3664 |
|
3665 def __findFileName(self): |
|
3666 """ |
|
3667 Private method to handle the search for file action. |
|
3668 """ |
|
3669 self.ui.findFileNameDialog.show() |
|
3670 self.ui.findFileNameDialog.raise_() |
|
3671 self.ui.findFileNameDialog.activateWindow() |
|
3672 |
|
3673 ################################################################## |
|
3674 ## Below are the action methods for the edit menu |
|
3675 ################################################################## |
|
3676 |
|
3677 def __editUndo(self): |
|
3678 """ |
|
3679 Private method to handle the undo action. |
|
3680 """ |
|
3681 self.activeWindow().undo() |
|
3682 |
|
3683 def __editRedo(self): |
|
3684 """ |
|
3685 Private method to handle the redo action. |
|
3686 """ |
|
3687 self.activeWindow().redo() |
|
3688 |
|
3689 def __editRevert(self): |
|
3690 """ |
|
3691 Private method to handle the revert action. |
|
3692 """ |
|
3693 self.activeWindow().revertToUnmodified() |
|
3694 |
|
3695 def __editCut(self): |
|
3696 """ |
|
3697 Private method to handle the cut action. |
|
3698 """ |
|
3699 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
3700 e4App().getObject("Shell").cut() |
|
3701 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
3702 e4App().getObject("Terminal").cut() |
|
3703 else: |
|
3704 self.activeWindow().cut() |
|
3705 |
|
3706 def __editCopy(self): |
|
3707 """ |
|
3708 Private method to handle the copy action. |
|
3709 """ |
|
3710 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
3711 e4App().getObject("Shell").copy() |
|
3712 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
3713 e4App().getObject("Terminal").copy() |
|
3714 else: |
|
3715 self.activeWindow().copy() |
|
3716 |
|
3717 def __editPaste(self): |
|
3718 """ |
|
3719 Private method to handle the paste action. |
|
3720 """ |
|
3721 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
3722 e4App().getObject("Shell").paste() |
|
3723 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
3724 e4App().getObject("Terminal").paste() |
|
3725 else: |
|
3726 self.activeWindow().paste() |
|
3727 |
|
3728 def __editDelete(self): |
|
3729 """ |
|
3730 Private method to handle the delete action. |
|
3731 """ |
|
3732 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
3733 e4App().getObject("Shell").clear() |
|
3734 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
3735 e4App().getObject("Terminal").clear() |
|
3736 else: |
|
3737 self.activeWindow().clear() |
|
3738 |
|
3739 def __editIndent(self): |
|
3740 """ |
|
3741 Private method to handle the indent action. |
|
3742 """ |
|
3743 self.activeWindow().indentLineOrSelection() |
|
3744 |
|
3745 def __editUnindent(self): |
|
3746 """ |
|
3747 Private method to handle the unindent action. |
|
3748 """ |
|
3749 self.activeWindow().unindentLineOrSelection() |
|
3750 |
|
3751 def __editSmartIndent(self): |
|
3752 """ |
|
3753 Private method to handle the smart indent action |
|
3754 """ |
|
3755 self.activeWindow().smartIndentLineOrSelection() |
|
3756 |
|
3757 def __editComment(self): |
|
3758 """ |
|
3759 Private method to handle the comment action. |
|
3760 """ |
|
3761 self.activeWindow().commentLineOrSelection() |
|
3762 |
|
3763 def __editUncomment(self): |
|
3764 """ |
|
3765 Private method to handle the uncomment action. |
|
3766 """ |
|
3767 self.activeWindow().uncommentLineOrSelection() |
|
3768 |
|
3769 def __editStreamComment(self): |
|
3770 """ |
|
3771 Private method to handle the stream comment action. |
|
3772 """ |
|
3773 self.activeWindow().streamCommentLineOrSelection() |
|
3774 |
|
3775 def __editBoxComment(self): |
|
3776 """ |
|
3777 Private method to handle the box comment action. |
|
3778 """ |
|
3779 self.activeWindow().boxCommentLineOrSelection() |
|
3780 |
|
3781 def __editSelectBrace(self): |
|
3782 """ |
|
3783 Private method to handle the select to brace action. |
|
3784 """ |
|
3785 self.activeWindow().selectToMatchingBrace() |
|
3786 |
|
3787 def __editSelectAll(self): |
|
3788 """ |
|
3789 Private method to handle the select all action. |
|
3790 """ |
|
3791 self.activeWindow().selectAll(True) |
|
3792 |
|
3793 def __editDeselectAll(self): |
|
3794 """ |
|
3795 Private method to handle the select all action. |
|
3796 """ |
|
3797 self.activeWindow().selectAll(False) |
|
3798 |
|
3799 def __convertEOL(self): |
|
3800 """ |
|
3801 Private method to handle the convert line end characters action. |
|
3802 """ |
|
3803 aw = self.activeWindow() |
|
3804 aw.convertEols(aw.eolMode()) |
|
3805 |
|
3806 def __shortenEmptyLines(self): |
|
3807 """ |
|
3808 Private method to handle the shorten empty lines action. |
|
3809 """ |
|
3810 self.activeWindow().shortenEmptyLines() |
|
3811 |
|
3812 def __editAutoComplete(self): |
|
3813 """ |
|
3814 Private method to handle the autocomplete action. |
|
3815 """ |
|
3816 self.activeWindow().autoComplete() |
|
3817 |
|
3818 def __editAutoCompleteFromDoc(self): |
|
3819 """ |
|
3820 Private method to handle the autocomplete from document action. |
|
3821 """ |
|
3822 self.activeWindow().autoCompleteFromDocument() |
|
3823 |
|
3824 def __editAutoCompleteFromAPIs(self): |
|
3825 """ |
|
3826 Private method to handle the autocomplete from APIs action. |
|
3827 """ |
|
3828 self.activeWindow().autoCompleteFromAPIs() |
|
3829 |
|
3830 def __editAutoCompleteFromAll(self): |
|
3831 """ |
|
3832 Private method to handle the autocomplete from All action. |
|
3833 """ |
|
3834 self.activeWindow().autoCompleteFromAll() |
|
3835 |
|
3836 def __editorAutoCompletionAPIsAvailable(self, available): |
|
3837 """ |
|
3838 Private method to handle the availability of API autocompletion signal. |
|
3839 """ |
|
3840 self.autoCompleteFromAPIsAct.setEnabled(available) |
|
3841 |
|
3842 def __editShowCallTips(self): |
|
3843 """ |
|
3844 Private method to handle the calltips action. |
|
3845 """ |
|
3846 self.activeWindow().callTip() |
|
3847 |
|
3848 ################################################################## |
|
3849 ## Below are the action and utility methods for the search menu |
|
3850 ################################################################## |
|
3851 |
|
3852 def textForFind(self, getCurrentWord = True): |
|
3853 """ |
|
3854 Public method to determine the selection or the current word for the next |
|
3855 find operation. |
|
3856 |
|
3857 @param getCurrentWord flag indicating to return the current word, if no selected |
|
3858 text was found (boolean) |
|
3859 @return selection or current word (string) |
|
3860 """ |
|
3861 aw = self.activeWindow() |
|
3862 if aw is None: |
|
3863 return "" |
|
3864 |
|
3865 return aw.getSearchText(not getCurrentWord) |
|
3866 |
|
3867 def getSRHistory(self, key): |
|
3868 """ |
|
3869 Public method to get the search or replace history list. |
|
3870 |
|
3871 @param key list to return (must be 'search' or 'replace') |
|
3872 @return the requested history list (list of strings) |
|
3873 """ |
|
3874 return self.srHistory[key] |
|
3875 |
|
3876 def __quickSearch(self): |
|
3877 """ |
|
3878 Private slot to handle the incremental quick search. |
|
3879 """ |
|
3880 # first we have to check if quick search is active |
|
3881 # and try to activate it if not |
|
3882 if not self.quickFindtextCombo.lineEdit().hasFocus(): |
|
3883 aw = self.activeWindow() |
|
3884 self.quickFindtextCombo.lastActive = aw |
|
3885 if aw: |
|
3886 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition() |
|
3887 else: |
|
3888 self.quickFindtextCombo.lastCursorPos = None |
|
3889 tff = self.textForFind(False) |
|
3890 if tff: |
|
3891 self.quickFindtextCombo.lineEdit().setText(tff) |
|
3892 self.quickFindtextCombo.lineEdit().setFocus() |
|
3893 self.quickFindtextCombo.lineEdit().selectAll() |
|
3894 else: |
|
3895 self.__quickSearchInEditor(True, False) |
|
3896 |
|
3897 def __quickSearchFocusIn(self): |
|
3898 """ |
|
3899 Private method to handle a focus in signal of the quicksearch lineedit. |
|
3900 """ |
|
3901 self.quickFindtextCombo.lastActive = self.activeWindow() |
|
3902 |
|
3903 def __quickSearchEnter(self): |
|
3904 """ |
|
3905 Private slot to handle the incremental quick search return pressed |
|
3906 (jump back to text) |
|
3907 """ |
|
3908 if self.quickFindtextCombo.lastActive: |
|
3909 self.quickFindtextCombo.lastActive.setFocus() |
|
3910 |
|
3911 def __quickSearchEscape(self): |
|
3912 """ |
|
3913 Private slot to handle the incremental quick search escape pressed |
|
3914 (jump back to text) |
|
3915 """ |
|
3916 if self.quickFindtextCombo.lastActive: |
|
3917 self.quickFindtextCombo.lastActive.setFocus() |
|
3918 aw = self.activeWindow() |
|
3919 if aw and self.quickFindtextCombo.lastCursorPos: |
|
3920 aw.setCursorPosition(self.quickFindtextCombo.lastCursorPos[0], |
|
3921 self.quickFindtextCombo.lastCursorPos[1]) |
|
3922 |
|
3923 def __quickSearchText(self): |
|
3924 """ |
|
3925 Private slot to handle the textChanged signal of the quicksearch edit. |
|
3926 """ |
|
3927 self.__quickSearchInEditor(False, False) |
|
3928 |
|
3929 def __quickSearchPrev(self): |
|
3930 """ |
|
3931 Private slot to handle the quickFindPrev toolbutton action. |
|
3932 """ |
|
3933 self.__quickSearchInEditor(True, True) |
|
3934 |
|
3935 def __quickSearchMarkOccurrences(self, txt): |
|
3936 """ |
|
3937 Private method to mark all occurrences of the search text. |
|
3938 |
|
3939 @param txt text to search for (string) |
|
3940 """ |
|
3941 aw = self.activeWindow() |
|
3942 |
|
3943 lineFrom = 0 |
|
3944 indexFrom = 0 |
|
3945 lineTo = -1 |
|
3946 indexTo = -1 |
|
3947 |
|
3948 aw.clearSearchIndicators() |
|
3949 ok = aw.findFirstTarget(txt, False, False, False, |
|
3950 lineFrom, indexFrom, lineTo, indexTo) |
|
3951 while ok: |
|
3952 tgtPos, tgtLen = aw.getFoundTarget() |
|
3953 try: |
|
3954 aw.setSearchIndicator(tgtPos, tgtLen) |
|
3955 except AttributeError: |
|
3956 self.viewmanager.setSearchIndicator(tgtPos, tgtLen) |
|
3957 ok = aw.findNextTarget() |
|
3958 |
|
3959 def __quickSearchInEditor(self, again, back): |
|
3960 """ |
|
3961 Private slot to perform a quick search. |
|
3962 |
|
3963 @param again flag indicating a repeat of the last search (boolean) |
|
3964 @param back flag indicating a backwards search operation (boolean) |
|
3965 """ |
|
3966 aw = self.activeWindow() |
|
3967 if not aw: |
|
3968 return |
|
3969 |
|
3970 text = self.quickFindtextCombo.lineEdit().text() |
|
3971 if not text: |
|
3972 text = self.quickFindtextCombo.lastSearchText |
|
3973 if not text: |
|
3974 if Preferences.getEditor("QuickSearchMarkersEnabled"): |
|
3975 aw.clearSearchIndicators() |
|
3976 return |
|
3977 else: |
|
3978 self.quickFindtextCombo.lastSearchText = text |
|
3979 |
|
3980 if Preferences.getEditor("QuickSearchMarkersEnabled"): |
|
3981 self.__quickSearchMarkOccurrences(text) |
|
3982 |
|
3983 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection() |
|
3984 cline, cindex = aw.getCursorPosition () |
|
3985 if again: |
|
3986 if back: |
|
3987 if indexFrom != 0: |
|
3988 index = indexFrom - 1 |
|
3989 line = lineFrom |
|
3990 elif lineFrom == 0: |
|
3991 return |
|
3992 else: |
|
3993 line = lineFrom - 1 |
|
3994 index = aw.lineLength(line) |
|
3995 ok = aw.findFirst(text, False, False, False, True, False, line, index) |
|
3996 else: |
|
3997 ok = aw.findFirst(text, False, False, False, True, not back, |
|
3998 cline, cindex) |
|
3999 else: |
|
4000 ok = aw.findFirst(text, False, False, False, True, not back, |
|
4001 lineFrom, indexFrom) |
|
4002 if not ok: |
|
4003 palette = self.quickFindtextCombo.lineEdit().palette() |
|
4004 palette.setColor(QPalette.Base, QColor("red")) |
|
4005 palette.setColor(QPalette.Text, QColor("white")) |
|
4006 self.quickFindtextCombo.lineEdit().setPalette(palette) |
|
4007 else: |
|
4008 palette = self.quickFindtextCombo.lineEdit().palette() |
|
4009 palette.setColor(QPalette.Base, |
|
4010 self.quickFindtextCombo.palette().color(QPalette.Base)) |
|
4011 palette.setColor(QPalette.Text, |
|
4012 self.quickFindtextCombo.palette().color(QPalette.Text)) |
|
4013 self.quickFindtextCombo.lineEdit().setPalette(palette) |
|
4014 |
|
4015 def __quickSearchExtend(self): |
|
4016 """ |
|
4017 Private method to handle the quicksearch extend action. |
|
4018 """ |
|
4019 aw = self.activeWindow() |
|
4020 if aw is None: |
|
4021 return |
|
4022 |
|
4023 txt = self.quickFindtextCombo.lineEdit().text() |
|
4024 if not txt: |
|
4025 return |
|
4026 |
|
4027 line, index = aw.getCursorPosition() |
|
4028 text = aw.text(line) |
|
4029 |
|
4030 re = QRegExp('[^\w_]') |
|
4031 end = re.indexIn(text, index) |
|
4032 if end > index: |
|
4033 ext = text[index:end + 1] |
|
4034 txt += ext |
|
4035 self.quickFindtextCombo.lineEdit().setText(txt) |
|
4036 |
|
4037 def __search(self): |
|
4038 """ |
|
4039 Private method to handle the search action. |
|
4040 """ |
|
4041 self.replaceDlg.close() |
|
4042 self.searchDlg.show(self.textForFind()) |
|
4043 |
|
4044 def __replace(self): |
|
4045 """ |
|
4046 Private method to handle the replace action. |
|
4047 """ |
|
4048 self.searchDlg.close() |
|
4049 self.replaceDlg.show(self.textForFind()) |
|
4050 |
|
4051 def __searchClearMarkers(self): |
|
4052 """ |
|
4053 Private method to clear the search markers of the active window. |
|
4054 """ |
|
4055 self.activeWindow().clearSearchIndicators() |
|
4056 |
|
4057 def __goto(self): |
|
4058 """ |
|
4059 Private method to handle the goto action. |
|
4060 """ |
|
4061 aw = self.activeWindow() |
|
4062 dlg = GotoDialog(aw.lines(), self.ui, None, True) |
|
4063 if dlg.exec_() == QDialog.Accepted: |
|
4064 aw.gotoLine(dlg.getLinenumber()) |
|
4065 |
|
4066 def __gotoBrace(self): |
|
4067 """ |
|
4068 Private method to handle the goto brace action. |
|
4069 """ |
|
4070 self.activeWindow().moveToMatchingBrace() |
|
4071 |
|
4072 def __searchFiles(self): |
|
4073 """ |
|
4074 Private method to handle the search in files action. |
|
4075 """ |
|
4076 self.ui.findFilesDialog.show(self.textForFind()) |
|
4077 self.ui.findFilesDialog.raise_() |
|
4078 self.ui.findFilesDialog.activateWindow() |
|
4079 |
|
4080 def __replaceFiles(self): |
|
4081 """ |
|
4082 Private method to handle the replace in files action. |
|
4083 """ |
|
4084 self.ui.replaceFilesDialog.show(self.textForFind()) |
|
4085 self.ui.replaceFilesDialog.raise_() |
|
4086 self.ui.replaceFilesDialog.activateWindow() |
|
4087 |
|
4088 ################################################################## |
|
4089 ## Below are the action methods for the view menu |
|
4090 ################################################################## |
|
4091 |
|
4092 def __zoomIn(self): |
|
4093 """ |
|
4094 Private method to handle the zoom in action. |
|
4095 """ |
|
4096 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
4097 e4App().getObject("Shell").zoomIn() |
|
4098 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
4099 e4App().getObject("Terminal").zoomIn() |
|
4100 else: |
|
4101 aw = self.activeWindow() |
|
4102 if aw: |
|
4103 aw.zoomIn() |
|
4104 |
|
4105 def __zoomOut(self): |
|
4106 """ |
|
4107 Private method to handle the zoom out action. |
|
4108 """ |
|
4109 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
4110 e4App().getObject("Shell").zoomOut() |
|
4111 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
4112 e4App().getObject("Terminal").zoomOut() |
|
4113 else: |
|
4114 aw = self.activeWindow() |
|
4115 if aw: |
|
4116 aw.zoomOut() |
|
4117 |
|
4118 def __zoom(self): |
|
4119 """ |
|
4120 Private method to handle the zoom action. |
|
4121 """ |
|
4122 if QApplication.focusWidget() == e4App().getObject("Shell"): |
|
4123 aw = e4App().getObject("Shell") |
|
4124 elif QApplication.focusWidget() == e4App().getObject("Terminal"): |
|
4125 aw = e4App().getObject("Terminal") |
|
4126 else: |
|
4127 aw = self.activeWindow() |
|
4128 if aw: |
|
4129 dlg = ZoomDialog(aw.getZoom(), self.ui, None, True) |
|
4130 if dlg.exec_() == QDialog.Accepted: |
|
4131 aw.zoomTo(dlg.getZoomSize()) |
|
4132 |
|
4133 def __toggleAll(self): |
|
4134 """ |
|
4135 Private method to handle the toggle all folds action. |
|
4136 """ |
|
4137 aw = self.activeWindow() |
|
4138 if aw: |
|
4139 aw.foldAll() |
|
4140 |
|
4141 def __toggleAllChildren(self): |
|
4142 """ |
|
4143 Private method to handle the toggle all folds (including children) action. |
|
4144 """ |
|
4145 aw = self.activeWindow() |
|
4146 if aw: |
|
4147 aw.foldAll(True) |
|
4148 |
|
4149 def __toggleCurrent(self): |
|
4150 """ |
|
4151 Private method to handle the toggle current fold action. |
|
4152 """ |
|
4153 aw = self.activeWindow() |
|
4154 if aw: |
|
4155 line, index = aw.getCursorPosition() |
|
4156 aw.foldLine(line) |
|
4157 |
|
4158 def __splitView(self): |
|
4159 """ |
|
4160 Private method to handle the split view action. |
|
4161 """ |
|
4162 self.addSplit() |
|
4163 |
|
4164 def __splitOrientation(self, checked): |
|
4165 """ |
|
4166 Private method to handle the split orientation action. |
|
4167 """ |
|
4168 if checked: |
|
4169 self.setSplitOrientation(Qt.Horizontal) |
|
4170 self.splitViewAct.setIcon(\ |
|
4171 UI.PixmapCache.getIcon("splitHorizontal.png")) |
|
4172 self.splitRemoveAct.setIcon(\ |
|
4173 UI.PixmapCache.getIcon("remsplitHorizontal.png")) |
|
4174 else: |
|
4175 self.setSplitOrientation(Qt.Vertical) |
|
4176 self.splitViewAct.setIcon(\ |
|
4177 UI.PixmapCache.getIcon("splitVertical.png")) |
|
4178 self.splitRemoveAct.setIcon(\ |
|
4179 UI.PixmapCache.getIcon("remsplitVertical.png")) |
|
4180 |
|
4181 ################################################################## |
|
4182 ## Below are the action methods for the macro menu |
|
4183 ################################################################## |
|
4184 |
|
4185 def __macroStartRecording(self): |
|
4186 """ |
|
4187 Private method to handle the start macro recording action. |
|
4188 """ |
|
4189 self.activeWindow().macroRecordingStart() |
|
4190 |
|
4191 def __macroStopRecording(self): |
|
4192 """ |
|
4193 Private method to handle the stop macro recording action. |
|
4194 """ |
|
4195 self.activeWindow().macroRecordingStop() |
|
4196 |
|
4197 def __macroRun(self): |
|
4198 """ |
|
4199 Private method to handle the run macro action. |
|
4200 """ |
|
4201 self.activeWindow().macroRun() |
|
4202 |
|
4203 def __macroDelete(self): |
|
4204 """ |
|
4205 Private method to handle the delete macro action. |
|
4206 """ |
|
4207 self.activeWindow().macroDelete() |
|
4208 |
|
4209 def __macroLoad(self): |
|
4210 """ |
|
4211 Private method to handle the load macro action. |
|
4212 """ |
|
4213 self.activeWindow().macroLoad() |
|
4214 |
|
4215 def __macroSave(self): |
|
4216 """ |
|
4217 Private method to handle the save macro action. |
|
4218 """ |
|
4219 self.activeWindow().macroSave() |
|
4220 |
|
4221 ################################################################## |
|
4222 ## Below are the action methods for the bookmarks menu |
|
4223 ################################################################## |
|
4224 |
|
4225 def __toggleBookmark(self): |
|
4226 """ |
|
4227 Private method to handle the toggle bookmark action. |
|
4228 """ |
|
4229 self.activeWindow().menuToggleBookmark() |
|
4230 |
|
4231 def __nextBookmark(self): |
|
4232 """ |
|
4233 Private method to handle the next bookmark action. |
|
4234 """ |
|
4235 self.activeWindow().nextBookmark() |
|
4236 |
|
4237 def __previousBookmark(self): |
|
4238 """ |
|
4239 Private method to handle the previous bookmark action. |
|
4240 """ |
|
4241 self.activeWindow().previousBookmark() |
|
4242 |
|
4243 def __clearAllBookmarks(self): |
|
4244 """ |
|
4245 Private method to handle the clear all bookmarks action. |
|
4246 """ |
|
4247 for editor in self.editors: |
|
4248 editor.clearBookmarks() |
|
4249 |
|
4250 self.bookmarkNextAct.setEnabled(False) |
|
4251 self.bookmarkPreviousAct.setEnabled(False) |
|
4252 self.bookmarkClearAct.setEnabled(False) |
|
4253 |
|
4254 def __showBookmarkMenu(self): |
|
4255 """ |
|
4256 Private method to set up the bookmark menu. |
|
4257 """ |
|
4258 bookmarksFound = 0 |
|
4259 filenames = self.getOpenFilenames() |
|
4260 for filename in filenames: |
|
4261 editor = self.getOpenEditor(filename) |
|
4262 bookmarksFound = len(editor.getBookmarks()) > 0 |
|
4263 if bookmarksFound: |
|
4264 self.menuBookmarksAct.setEnabled(True) |
|
4265 return |
|
4266 self.menuBookmarksAct.setEnabled(False) |
|
4267 |
|
4268 def __showBookmarksMenu(self): |
|
4269 """ |
|
4270 Private method to handle the show bookmarks menu signal. |
|
4271 """ |
|
4272 self.bookmarksMenu.clear() |
|
4273 |
|
4274 filenames = self.getOpenFilenames() |
|
4275 for filename in sorted(filenames): |
|
4276 editor = self.getOpenEditor(filename) |
|
4277 for bookmark in editor.getBookmarks(): |
|
4278 bmSuffix = " : %d" % bookmark |
|
4279 act = self.bookmarksMenu.addAction( |
|
4280 "%s%s" % ( |
|
4281 Utilities.compactPath( |
|
4282 filename, |
|
4283 self.ui.maxMenuFilePathLen - len(bmSuffix)), |
|
4284 bmSuffix)) |
|
4285 act.setData(QVariant([QVariant(filename), QVariant(bookmark)])) |
|
4286 |
|
4287 def __bookmarkSelected(self, act): |
|
4288 """ |
|
4289 Private method to handle the bookmark selected signal. |
|
4290 |
|
4291 @param act reference to the action that triggered (QAction) |
|
4292 """ |
|
4293 try: |
|
4294 qvList = act.data().toPyObject() |
|
4295 filename = qvList[0] |
|
4296 line = qvList[1] |
|
4297 except AttributeError: |
|
4298 qvList = act.data().toList() |
|
4299 filename = qvList[0].toString() |
|
4300 line = qvList[1].toInt()[0] |
|
4301 self.openSourceFile(filename, line) |
|
4302 |
|
4303 def __bookmarkToggled(self, editor): |
|
4304 """ |
|
4305 Private slot to handle the bookmarkToggled signal. |
|
4306 |
|
4307 It checks some bookmark actions and reemits the signal. |
|
4308 |
|
4309 @param editor editor that sent the signal |
|
4310 """ |
|
4311 if editor.hasBookmarks(): |
|
4312 self.bookmarkNextAct.setEnabled(True) |
|
4313 self.bookmarkPreviousAct.setEnabled(True) |
|
4314 self.bookmarkClearAct.setEnabled(True) |
|
4315 else: |
|
4316 self.bookmarkNextAct.setEnabled(False) |
|
4317 self.bookmarkPreviousAct.setEnabled(False) |
|
4318 self.bookmarkClearAct.setEnabled(False) |
|
4319 self.emit(SIGNAL('bookmarkToggled'), editor) |
|
4320 |
|
4321 def __gotoSyntaxError(self): |
|
4322 """ |
|
4323 Private method to handle the goto syntax error action. |
|
4324 """ |
|
4325 self.activeWindow().gotoSyntaxError() |
|
4326 |
|
4327 def __clearAllSyntaxErrors(self): |
|
4328 """ |
|
4329 Private method to handle the clear all syntax errors action. |
|
4330 """ |
|
4331 for editor in self.editors: |
|
4332 editor.clearSyntaxError() |
|
4333 |
|
4334 def _syntaxErrorToggled(self, editor): |
|
4335 """ |
|
4336 Protected slot to handle the syntaxerrorToggled signal. |
|
4337 |
|
4338 It checks some syntax error actions and reemits the signal. |
|
4339 |
|
4340 @param editor editor that sent the signal |
|
4341 """ |
|
4342 if editor.hasSyntaxErrors(): |
|
4343 self.syntaxErrorGotoAct.setEnabled(True) |
|
4344 self.syntaxErrorClearAct.setEnabled(True) |
|
4345 else: |
|
4346 self.syntaxErrorGotoAct.setEnabled(False) |
|
4347 self.syntaxErrorClearAct.setEnabled(False) |
|
4348 self.emit(SIGNAL('syntaxerrorToggled'), editor) |
|
4349 |
|
4350 def __nextUncovered(self): |
|
4351 """ |
|
4352 Private method to handle the next uncovered action. |
|
4353 """ |
|
4354 self.activeWindow().nextUncovered() |
|
4355 |
|
4356 def __previousUncovered(self): |
|
4357 """ |
|
4358 Private method to handle the previous uncovered action. |
|
4359 """ |
|
4360 self.activeWindow().previousUncovered() |
|
4361 |
|
4362 def __coverageMarkersShown(self, shown): |
|
4363 """ |
|
4364 Private slot to handle the coverageMarkersShown signal. |
|
4365 |
|
4366 @param shown flag indicating whether the markers were shown or cleared |
|
4367 """ |
|
4368 if shown: |
|
4369 self.notcoveredNextAct.setEnabled(True) |
|
4370 self.notcoveredPreviousAct.setEnabled(True) |
|
4371 else: |
|
4372 self.notcoveredNextAct.setEnabled(False) |
|
4373 self.notcoveredPreviousAct.setEnabled(False) |
|
4374 |
|
4375 def __taskMarkersUpdated(self, editor): |
|
4376 """ |
|
4377 Protected slot to handle the syntaxerrorToggled signal. |
|
4378 |
|
4379 It checks some syntax error actions and reemits the signal. |
|
4380 |
|
4381 @param editor editor that sent the signal |
|
4382 """ |
|
4383 if editor.hasTaskMarkers(): |
|
4384 self.taskNextAct.setEnabled(True) |
|
4385 self.taskPreviousAct.setEnabled(True) |
|
4386 else: |
|
4387 self.taskNextAct.setEnabled(False) |
|
4388 self.taskPreviousAct.setEnabled(False) |
|
4389 |
|
4390 def __nextTask(self): |
|
4391 """ |
|
4392 Private method to handle the next task action. |
|
4393 """ |
|
4394 self.activeWindow().nextTask() |
|
4395 |
|
4396 def __previousTask(self): |
|
4397 """ |
|
4398 Private method to handle the previous task action. |
|
4399 """ |
|
4400 self.activeWindow().previousTask() |
|
4401 |
|
4402 ################################################################## |
|
4403 ## Below are the action methods for the spell checking functions |
|
4404 ################################################################## |
|
4405 |
|
4406 def __setAutoSpellChecking(self): |
|
4407 """ |
|
4408 Private slot to set the automatic spell checking of all editors. |
|
4409 """ |
|
4410 enabled = self.autoSpellCheckAct.isChecked() |
|
4411 Preferences.setEditor("AutoSpellCheckingEnabled", int(enabled)) |
|
4412 for editor in self.editors: |
|
4413 editor.setAutoSpellChecking() |
|
4414 |
|
4415 def __spellCheck(self): |
|
4416 """ |
|
4417 Private slot to perform a spell check of the current editor. |
|
4418 """ |
|
4419 aw = self.activeWindow() |
|
4420 if aw: |
|
4421 aw.checkSpelling() |
|
4422 |
|
4423 ################################################################## |
|
4424 ## Below are general utility methods |
|
4425 ################################################################## |
|
4426 |
|
4427 def handleResetUI(self): |
|
4428 """ |
|
4429 Public slot to handle the resetUI signal. |
|
4430 """ |
|
4431 editor = self.activeWindow() |
|
4432 if editor is None: |
|
4433 self.__setSbFile() |
|
4434 else: |
|
4435 line, pos = editor.getCursorPosition() |
|
4436 enc = editor.getEncoding() |
|
4437 lang = editor.getLanguage() |
|
4438 eol = editor.getEolIndicator() |
|
4439 self.__setSbFile(editor.getFileName(), line + 1, pos, enc, lang, eol) |
|
4440 |
|
4441 def closeViewManager(self): |
|
4442 """ |
|
4443 Public method to shutdown the viewmanager. |
|
4444 |
|
4445 If it cannot close all editor windows, it aborts the shutdown process. |
|
4446 |
|
4447 @return flag indicating success (boolean) |
|
4448 """ |
|
4449 self.closeAllWindows() |
|
4450 |
|
4451 # save the list of recently opened projects |
|
4452 self.__saveRecent() |
|
4453 |
|
4454 # save the list of recently opened projects |
|
4455 Preferences.Prefs.settings.setValue('Bookmarked/Sources', |
|
4456 QVariant(self.bookmarked)) |
|
4457 |
|
4458 if len(self.editors): |
|
4459 return False |
|
4460 else: |
|
4461 return True |
|
4462 |
|
4463 def __lastEditorClosed(self): |
|
4464 """ |
|
4465 Private slot to handle the lastEditorClosed signal. |
|
4466 """ |
|
4467 self.closeActGrp.setEnabled(False) |
|
4468 self.saveActGrp.setEnabled(False) |
|
4469 self.exportersMenuAct.setEnabled(False) |
|
4470 self.printAct.setEnabled(False) |
|
4471 if self.printPreviewAct: |
|
4472 self.printPreviewAct.setEnabled(False) |
|
4473 self.editActGrp.setEnabled(False) |
|
4474 self.searchActGrp.setEnabled(False) |
|
4475 self.quickFindtextCombo.setEnabled(False) |
|
4476 self.viewActGrp.setEnabled(False) |
|
4477 self.viewFoldActGrp.setEnabled(False) |
|
4478 self.unhighlightAct.setEnabled(False) |
|
4479 self.splitViewAct.setEnabled(False) |
|
4480 self.splitOrientationAct.setEnabled(False) |
|
4481 self.macroActGrp.setEnabled(False) |
|
4482 self.bookmarkActGrp.setEnabled(False) |
|
4483 self.__enableSpellingActions() |
|
4484 self.__setSbFile() |
|
4485 |
|
4486 # remove all split views, if this is supported |
|
4487 if self.canSplit(): |
|
4488 while self.removeSplit(): pass |
|
4489 |
|
4490 # stop the autosave timer |
|
4491 if self.autosaveTimer.isActive(): |
|
4492 self.autosaveTimer.stop() |
|
4493 |
|
4494 def __editorOpened(self): |
|
4495 """ |
|
4496 Private slot to handle the editorOpened signal. |
|
4497 """ |
|
4498 self.closeActGrp.setEnabled(True) |
|
4499 self.saveActGrp.setEnabled(True) |
|
4500 self.exportersMenuAct.setEnabled(True) |
|
4501 self.printAct.setEnabled(True) |
|
4502 if self.printPreviewAct: |
|
4503 self.printPreviewAct.setEnabled(True) |
|
4504 self.editActGrp.setEnabled(True) |
|
4505 self.searchActGrp.setEnabled(True) |
|
4506 self.quickFindtextCombo.setEnabled(True) |
|
4507 self.viewActGrp.setEnabled(True) |
|
4508 self.viewFoldActGrp.setEnabled(True) |
|
4509 self.unhighlightAct.setEnabled(True) |
|
4510 if self.canSplit(): |
|
4511 self.splitViewAct.setEnabled(True) |
|
4512 self.splitOrientationAct.setEnabled(True) |
|
4513 self.macroActGrp.setEnabled(True) |
|
4514 self.bookmarkActGrp.setEnabled(True) |
|
4515 self.__enableSpellingActions() |
|
4516 |
|
4517 # activate the autosave timer |
|
4518 if not self.autosaveTimer.isActive() and \ |
|
4519 self.autosaveInterval > 0: |
|
4520 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
4521 |
|
4522 def __autosave(self): |
|
4523 """ |
|
4524 Private slot to save the contents of all editors automatically. |
|
4525 |
|
4526 Only named editors will be saved by the autosave timer. |
|
4527 """ |
|
4528 for editor in self.editors: |
|
4529 if editor.shouldAutosave(): |
|
4530 ok, newName = editor.saveFile() |
|
4531 if ok: |
|
4532 self.setEditorName(editor, newName) |
|
4533 |
|
4534 # restart autosave timer |
|
4535 if self.autosaveInterval > 0: |
|
4536 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
4537 |
|
4538 def _checkActions(self, editor, setSb = True): |
|
4539 """ |
|
4540 Protected slot to check some actions for their enable/disable status |
|
4541 and set the statusbar info. |
|
4542 |
|
4543 @param editor editor window |
|
4544 @param setSb flag indicating an update of the status bar is wanted (boolean) |
|
4545 """ |
|
4546 if editor is not None: |
|
4547 self.saveAct.setEnabled(editor.isModified()) |
|
4548 self.revertAct.setEnabled(editor.isModified()) |
|
4549 |
|
4550 self.undoAct.setEnabled(editor.isUndoAvailable()) |
|
4551 self.redoAct.setEnabled(editor.isRedoAvailable()) |
|
4552 |
|
4553 lex = editor.getLexer() |
|
4554 if lex is not None: |
|
4555 self.commentAct.setEnabled(lex.canBlockComment()) |
|
4556 self.uncommentAct.setEnabled(lex.canBlockComment()) |
|
4557 self.streamCommentAct.setEnabled(lex.canStreamComment()) |
|
4558 self.boxCommentAct.setEnabled(lex.canBoxComment()) |
|
4559 else: |
|
4560 self.commentAct.setEnabled(False) |
|
4561 self.uncommentAct.setEnabled(False) |
|
4562 self.streamCommentAct.setEnabled(False) |
|
4563 self.boxCommentAct.setEnabled(False) |
|
4564 |
|
4565 if editor.hasBookmarks(): |
|
4566 self.bookmarkNextAct.setEnabled(True) |
|
4567 self.bookmarkPreviousAct.setEnabled(True) |
|
4568 self.bookmarkClearAct.setEnabled(True) |
|
4569 else: |
|
4570 self.bookmarkNextAct.setEnabled(False) |
|
4571 self.bookmarkPreviousAct.setEnabled(False) |
|
4572 self.bookmarkClearAct.setEnabled(False) |
|
4573 |
|
4574 if editor.hasSyntaxErrors(): |
|
4575 self.syntaxErrorGotoAct.setEnabled(True) |
|
4576 self.syntaxErrorClearAct.setEnabled(True) |
|
4577 else: |
|
4578 self.syntaxErrorGotoAct.setEnabled(False) |
|
4579 self.syntaxErrorClearAct.setEnabled(False) |
|
4580 |
|
4581 if editor.hasCoverageMarkers(): |
|
4582 self.notcoveredNextAct.setEnabled(True) |
|
4583 self.notcoveredPreviousAct.setEnabled(True) |
|
4584 else: |
|
4585 self.notcoveredNextAct.setEnabled(False) |
|
4586 self.notcoveredPreviousAct.setEnabled(False) |
|
4587 |
|
4588 if editor.hasTaskMarkers(): |
|
4589 self.taskNextAct.setEnabled(True) |
|
4590 self.taskPreviousAct.setEnabled(True) |
|
4591 else: |
|
4592 self.taskNextAct.setEnabled(False) |
|
4593 self.taskPreviousAct.setEnabled(False) |
|
4594 |
|
4595 if editor.canAutoCompleteFromAPIs(): |
|
4596 self.autoCompleteFromAPIsAct.setEnabled(True) |
|
4597 else: |
|
4598 self.autoCompleteFromAPIsAct.setEnabled(False) |
|
4599 |
|
4600 if setSb: |
|
4601 line, pos = editor.getCursorPosition() |
|
4602 enc = editor.getEncoding() |
|
4603 lang = editor.getLanguage() |
|
4604 eol = editor.getEolIndicator() |
|
4605 self.__setSbFile(editor.getFileName(), line + 1, pos, enc, lang, eol) |
|
4606 |
|
4607 self.emit(SIGNAL('checkActions'), editor) |
|
4608 |
|
4609 def preferencesChanged(self): |
|
4610 """ |
|
4611 Public slot to handle the preferencesChanged signal. |
|
4612 |
|
4613 This method performs the following actions |
|
4614 <ul> |
|
4615 <li>reread the colours for the syntax highlighting</li> |
|
4616 <li>reloads the already created API objetcs</li> |
|
4617 <li>starts or stops the autosave timer</li> |
|
4618 <li><b>Note</b>: changes in viewmanager type are activated |
|
4619 on an application restart.</li> |
|
4620 </ul> |
|
4621 """ |
|
4622 # reload the APIs |
|
4623 self.apisManager.reloadAPIs() |
|
4624 |
|
4625 # reload editor settings |
|
4626 for editor in self.editors: |
|
4627 editor.readSettings() |
|
4628 |
|
4629 # reload the autosave timer setting |
|
4630 self.autosaveInterval = Preferences.getEditor("AutosaveInterval") |
|
4631 if len(self.editors): |
|
4632 if self.autosaveTimer.isActive() and \ |
|
4633 self.autosaveInterval == 0: |
|
4634 self.autosaveTimer.stop() |
|
4635 elif not self.autosaveTimer.isActive() and \ |
|
4636 self.autosaveInterval > 0: |
|
4637 self.autosaveTimer.start(self.autosaveInterval * 60000) |
|
4638 |
|
4639 self.__enableSpellingActions() |
|
4640 |
|
4641 def __editorSaved(self, fn): |
|
4642 """ |
|
4643 Private slot to handle the editorSaved signal. |
|
4644 |
|
4645 It simply reemits the signal. |
|
4646 |
|
4647 @param fn filename of the saved editor |
|
4648 """ |
|
4649 self.emit(SIGNAL('editorSaved'), fn) |
|
4650 |
|
4651 def __cursorChanged(self, fn, line, pos): |
|
4652 """ |
|
4653 Private slot to handle the cursorChanged signal. |
|
4654 |
|
4655 It emits the signal cursorChanged with parameter editor. |
|
4656 |
|
4657 @param fn filename (string) |
|
4658 @param line line number of the cursor (int) |
|
4659 @param pos position in line of the cursor (int) |
|
4660 """ |
|
4661 editor = self.getOpenEditor(fn) |
|
4662 if editor is None: |
|
4663 editor = self.sender() |
|
4664 |
|
4665 if editor is not None: |
|
4666 enc = editor.getEncoding() |
|
4667 lang = editor.getLanguage() |
|
4668 eol = editor.getEolIndicator() |
|
4669 else: |
|
4670 enc = None |
|
4671 lang = None |
|
4672 eol = None |
|
4673 self.__setSbFile(fn, line, pos, enc, lang, eol) |
|
4674 self.emit(SIGNAL('cursorChanged'), editor) |
|
4675 |
|
4676 def __breakpointToggled(self, editor): |
|
4677 """ |
|
4678 Private slot to handle the breakpointToggled signal. |
|
4679 |
|
4680 It simply reemits the signal. |
|
4681 |
|
4682 @param editor editor that sent the signal |
|
4683 """ |
|
4684 self.emit(SIGNAL('breakpointToggled'), editor) |
|
4685 |
|
4686 def getActions(self, type): |
|
4687 """ |
|
4688 Public method to get a list of all actions. |
|
4689 |
|
4690 @param type string denoting the action set to get. |
|
4691 It must be one of "edit", "file", "search", |
|
4692 "view", "window", "macro" or "bookmark" |
|
4693 @return list of all actions (list of E4Action) |
|
4694 """ |
|
4695 try: |
|
4696 exec 'actionList = self.%sActions[:]' % type |
|
4697 except AttributeError: |
|
4698 actionList = [] |
|
4699 |
|
4700 return actionList |
|
4701 |
|
4702 def __editorCommand(self, cmd): |
|
4703 """ |
|
4704 Private method to send an editor command to the active window. |
|
4705 |
|
4706 @param cmd the scintilla command to be sent |
|
4707 """ |
|
4708 focusWidget = QApplication.focusWidget() |
|
4709 if focusWidget == e4App().getObject("Shell"): |
|
4710 e4App().getObject("Shell").editorCommand(cmd) |
|
4711 elif focusWidget == e4App().getObject("Terminal"): |
|
4712 e4App().getObject("Terminal").editorCommand(cmd) |
|
4713 elif focusWidget == self.quickFindtextCombo: |
|
4714 self.quickFindtextCombo._editor.editorCommand(cmd) |
|
4715 else: |
|
4716 aw = self.activeWindow() |
|
4717 if aw: |
|
4718 aw.editorCommand(cmd) |
|
4719 |
|
4720 def __newLineBelow(self): |
|
4721 """ |
|
4722 Private method to insert a new line below the current one even if |
|
4723 cursor is not at the end of the line. |
|
4724 """ |
|
4725 focusWidget = QApplication.focusWidget() |
|
4726 if focusWidget == e4App().getObject("Shell") or \ |
|
4727 focusWidget == e4App().getObject("Terminal") or \ |
|
4728 focusWidget == self.quickFindtextCombo: |
|
4729 return |
|
4730 else: |
|
4731 aw = self.activeWindow() |
|
4732 if aw: |
|
4733 aw.newLineBelow() |
|
4734 |
|
4735 def __editorConfigChanged(self): |
|
4736 """ |
|
4737 Private method to handle changes of an editors configuration (e.g. language). |
|
4738 """ |
|
4739 editor = self.sender() |
|
4740 fn = editor.getFileName() |
|
4741 line, pos = editor.getCursorPosition() |
|
4742 enc = editor.getEncoding() |
|
4743 lang = editor.getLanguage() |
|
4744 eol = editor.getEolIndicator() |
|
4745 self.__setSbFile(fn, line + 1, pos, encoding = enc, language = lang, eol = eol) |
|
4746 |
|
4747 ################################################################## |
|
4748 ## Below are protected utility methods |
|
4749 ################################################################## |
|
4750 |
|
4751 def _getOpenStartDir(self): |
|
4752 """ |
|
4753 Protected method to return the starting directory for a file open dialog. |
|
4754 |
|
4755 The appropriate starting directory is calculated |
|
4756 using the following search order, until a match is found:<br /> |
|
4757 1: Directory of currently active editor<br /> |
|
4758 2: Directory of currently active Project<br /> |
|
4759 3: CWD |
|
4760 |
|
4761 @return name of directory to start (string) |
|
4762 """ |
|
4763 # if we have an active source, return its path |
|
4764 if self.activeWindow() is not None and \ |
|
4765 self.activeWindow().getFileName(): |
|
4766 return os.path.dirname(self.activeWindow().getFileName()) |
|
4767 |
|
4768 # check, if there is an active project and return its path |
|
4769 elif e4App().getObject("Project").isOpen(): |
|
4770 return e4App().getObject("Project").ppath |
|
4771 |
|
4772 else: |
|
4773 # None will cause open dialog to start with cwd |
|
4774 return "" |
|
4775 |
|
4776 def _getOpenFileFilter(self): |
|
4777 """ |
|
4778 Protected method to return the active filename filter for a file open dialog. |
|
4779 |
|
4780 The appropriate filename filter is determined by file extension of |
|
4781 the currently active editor. |
|
4782 |
|
4783 @return name of the filename filter (string) or None |
|
4784 """ |
|
4785 if self.activeWindow() is not None and \ |
|
4786 self.activeWindow().getFileName(): |
|
4787 ext = os.path.splitext(self.activeWindow().getFileName())[1] |
|
4788 rx = QRegExp(".*\*\.%s[ )].*" % ext[1:]) |
|
4789 filters = QScintilla.Lexers.getOpenFileFiltersList() |
|
4790 index = -1 |
|
4791 for i in range(len(filters)): |
|
4792 if rx.exactMatch(filters[i]): |
|
4793 index = i |
|
4794 break |
|
4795 if index == -1: |
|
4796 return Preferences.getEditor("DefaultOpenFilter") |
|
4797 else: |
|
4798 return filters[index] |
|
4799 else: |
|
4800 return Preferences.getEditor("DefaultOpenFilter") |
|
4801 |
|
4802 ################################################################## |
|
4803 ## Below are API handling methods |
|
4804 ################################################################## |
|
4805 |
|
4806 def getAPIsManager(self): |
|
4807 """ |
|
4808 Public method to get a reference to the APIs manager. |
|
4809 @return the APIs manager object (eric4.QScintilla.APIsManager) |
|
4810 """ |
|
4811 return self.apisManager |