QScintilla/Editor.py

Sat, 05 Jul 2014 15:02:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 15:02:45 +0200
changeset 3682
2543741b47b7
parent 3670
f0cb7579c0b4
child 3778
0c5bc18da740
permissions
-rw-r--r--

Changed a few files to reference eric6.

92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1 # -*- coding: utf-8 -*-
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3155
diff changeset
3 # Copyright (c) 2002 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4 #
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
7 Module implementing the editor component of the eric6 IDE.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
8 """
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
9 from __future__ import unicode_literals
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
10 try:
3177
5af61402d74d Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
11 str = unicode
5af61402d74d Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
12 chr = unichr
5af61402d74d Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
13 except NameError:
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
14 pass
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2517
diff changeset
15
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
16 import os
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
17 import re
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
18 import difflib
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
19
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
20 from PyQt5.QtCore import QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, \
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
21 pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
22 from PyQt5.QtGui import QCursor, QPalette, QFont, QPixmap, QPainter
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
23 from PyQt5.QtWidgets import QLineEdit, QActionGroup, QDialog, QInputDialog, \
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
24 QApplication, QMenu
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
25 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
26 from PyQt5.Qsci import QsciScintilla, QsciMacro, QsciStyledText
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
27
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
28 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
29 from E5Gui import E5FileDialog, E5MessageBox
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
30
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
31 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
32 from .EditorMarkerMap import EditorMarkerMap
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
33
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
34 import Preferences
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
35 import Utilities
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
36
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
37 import UI.PixmapCache
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
38
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
39 EditorAutoCompletionListID = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
40 TemplateCompletionListID = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
41
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
42
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
43 class Editor(QsciScintillaCompat):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
44 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
45 Class implementing the editor component of the eric6 IDE.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
46
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
47 @signal modificationStatusChanged(bool, QsciScintillaCompat) emitted when
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
48 the modification status has changed
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
49 @signal undoAvailable(bool) emitted to signal the undo availability
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
50 @signal redoAvailable(bool) emitted to signal the redo availability
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
51 @signal cursorChanged(str, int, int) emitted when the cursor position
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
52 was changed
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2659
diff changeset
53 @signal cursorLineChanged(int) emitted when the cursor line was changed
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
54 @signal editorAboutToBeSaved(str) emitted before the editor is saved
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
55 @signal editorSaved(str) emitted after the editor has been saved
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
56 @signal editorRenamed(str) emitted after the editor got a new name
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
57 (i.e. after a 'Save As')
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
58 @signal captionChanged(str, QsciScintillaCompat) emitted when the caption
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
59 is updated. Typically due to a readOnly attribute change.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
60 @signal breakpointToggled(QsciScintillaCompat) emitted when a breakpoint
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
61 is toggled
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
62 @signal bookmarkToggled(QsciScintillaCompat) emitted when a bookmark is
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
63 toggled
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
64 @signal syntaxerrorToggled(QsciScintillaCompat) emitted when a syntax error
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
65 was discovered
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
66 @signal autoCompletionAPIsAvailable(bool) emitted after the autocompletion
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
67 function has been configured
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
68 @signal coverageMarkersShown(bool) emitted after the coverage markers have
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
69 been shown or cleared
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
70 @signal taskMarkersUpdated(QsciScintillaCompat) emitted when the task
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
71 markers were updated
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
72 @signal changeMarkersUpdated(QsciScintillaCompat) emitted when the change
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
73 markers were updated
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
74 @signal showMenu(str, QMenu, QsciScintillaCompat) emitted when a menu is
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
75 about to be shown. The name of the menu, a reference to the menu and
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
76 a reference to the editor are given.
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
77 @signal languageChanged(str) emitted when the editors language was set. The
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
78 language is passed as a parameter.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
79 @signal eolChanged(str) emitted when the editors eol type was set. The eol
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
80 string is passed as a parameter.
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
81 @signal encodingChanged(str) emitted when the editors encoding was set. The
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
82 encoding name is passed as a parameter.
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
83 @signal lastEditPositionAvailable() emitted when a last edit position is
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
84 available
1807
9898a95461f1 Added a signal to the editor showing a refresh has happend and connected the editor assembly to it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1768
diff changeset
85 @signal refreshed() emitted to signal a refresh of the editor contents
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
86 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
87 modificationStatusChanged = pyqtSignal(bool, QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
88 undoAvailable = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
89 redoAvailable = pyqtSignal(bool)
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
90 cursorChanged = pyqtSignal(str, int, int)
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2659
diff changeset
91 cursorLineChanged = pyqtSignal(int)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
92 editorAboutToBeSaved = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
93 editorSaved = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
94 editorRenamed = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
95 captionChanged = pyqtSignal(str, QsciScintillaCompat)
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
96 breakpointToggled = pyqtSignal(QsciScintillaCompat)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
97 bookmarkToggled = pyqtSignal(QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
98 syntaxerrorToggled = pyqtSignal(QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
99 autoCompletionAPIsAvailable = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
100 coverageMarkersShown = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
101 taskMarkersUpdated = pyqtSignal(QsciScintillaCompat)
2162
4627e6ea7b6b Added capability to mark changed lines and to navigate between them to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
102 changeMarkersUpdated = pyqtSignal(QsciScintillaCompat)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
103 showMenu = pyqtSignal(str, QMenu, QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
104 languageChanged = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
105 eolChanged = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
106 encodingChanged = pyqtSignal(str)
1169
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
107 lastEditPositionAvailable = pyqtSignal()
1807
9898a95461f1 Added a signal to the editor showing a refresh has happend and connected the editor assembly to it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1768
diff changeset
108 refreshed = pyqtSignal()
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
109
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
110 WarningCode = 1
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
111 WarningStyle = 2
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
112
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
113 # Autocompletion icon definitions
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
114 ClassID = 1
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
115 ClassProtectedID = 2
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
116 ClassPrivateID = 3
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
117 MethodID = 4
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
118 MethodProtectedID = 5
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
119 MethodPrivateID = 6
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
120 AttributeID = 7
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
121 AttributeProtectedID = 8
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
122 AttributePrivateID = 9
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
123 EnumID = 10
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
124
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
125 FromDocumentID = 99
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
126
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
127 TemplateImageID = 100
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
128
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
129 # Cooperation related definitions
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
130 Separator = "@@@"
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
131
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
132 StartEditToken = "START_EDIT"
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
133 EndEditToken = "END_EDIT"
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
134 CancelEditToken = "CANCEL_EDIT"
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
135 RequestSyncToken = "REQUEST_SYNC"
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
136 SyncToken = "SYNC"
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
137
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
138 def __init__(self, dbs, fn=None, vm=None,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
139 filetype="", editor=None, tv=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
140 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
141 Constructor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
142
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
143 @param dbs reference to the debug server object
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
144 @param fn name of the file to be opened (string). If it is None,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
145 a new (empty) editor is opened
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
146 @param vm reference to the view manager object
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
147 (ViewManager.ViewManager)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
148 @param filetype type of the source file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
149 @param editor reference to an Editor object, if this is a cloned view
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
150 @param tv reference to the task viewer object
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
151 @exception IOError raised to indicate an issue accessing the file
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
152 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2517
diff changeset
153 super(Editor, self).__init__()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
154 self.setAttribute(Qt.WA_KeyCompression)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
155 self.setUtf8(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
156
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
157 self.dbs = dbs
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
158 self.taskViewer = tv
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
159 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
160 self.vm = vm
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
161 self.filetype = filetype
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
162 self.filetypeByFlag = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
163 self.noName = ""
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
164 self.project = e5App().getObject("Project")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
165
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
166 # clear some variables
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
167 self.lastHighlight = None # remember the last highlighted line
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
168 self.lastErrorMarker = None # remember the last error line
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
169 self.lastCurrMarker = None # remember the last current line
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
170
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
171 self.breaks = {}
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
172 # key: marker handle,
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
173 # value: (lineno, condition, temporary,
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
174 # enabled, ignorecount)
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
175 self.bookmarks = []
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
176 # bookmarks are just a list of handles to the
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
177 # bookmark markers
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
178 self.syntaxerrors = {}
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
179 # key: marker handle
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
180 # value: list of (error message, error index)
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
181 self.warnings = {}
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
182 # key: marker handle
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
183 # value: list of (warning message, warning type)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
184 self.notcoveredMarkers = [] # just a list of marker handles
2391
f9a6a512bc1e Added functionality to refresh the coverage markers of an editor if such are shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
185 self.showingNotcoveredMarkers = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
186
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
187 self.condHistory = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
188 self.lexer_ = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
189 self.__lexerReset = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
190 self.completer = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
191 self.encoding = Preferences.getEditor("DefaultEncoding")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
192 self.apiLanguage = ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
193 self.lastModified = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
194 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
195 self.inReopenPrompt = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
196 # true if the prompt to reload a changed source is present
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
197 self.inFileRenamed = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
198 # true if we are propagating a rename action
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
199 self.inLanguageChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
200 # true if we are propagating a language change
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
201 self.inEolChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
202 # true if we are propagating an eol change
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
203 self.inEncodingChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
204 # true if we are propagating an encoding change
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
205 self.inDragDrop = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
206 # true if we are in drop mode
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
207 self.inLinesChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
208 # true if we are propagating a lines changed event
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
209 self.__hasTaskMarkers = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
210 # no task markers present
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
211
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
212 self.macros = {} # list of defined macros
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
213 self.curMacro = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
214 self.recording = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
215
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
216 self.acAPI = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
217
1169
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
218 self.__lastEditPosition = None
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
219
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
220 # list of clones
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
221 self.__clones = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
222
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
223 # clear QScintilla defined keyboard commands
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
224 # we do our own handling through the view manager
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
225 self.clearAlternateKeys()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
226 self.clearKeys()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
227
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
228 # initialize the mark occurrences timer
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
229 self.__markOccurrencesTimer = QTimer(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
230 self.__markOccurrencesTimer.setSingleShot(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
231 self.__markOccurrencesTimer.setInterval(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
232 Preferences.getEditor("MarkOccurrencesTimeout"))
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
233 self.__markOccurrencesTimer.timeout.connect(self.__markOccurrences)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
234 self.__markedText = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
235
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
236 # initialize some spellchecking stuff
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
237 self.spell = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
238 self.lastLine = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
239 self.lastIndex = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
240
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
241 # initialize some cooperation stuff
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
242 self.__isSyncing = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
243 self.__receivedWhileSyncing = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
244 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
245 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
246 self.__isShared = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
247 self.__inRemoteSharedEdit = False
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
248
1169
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
249 # connect signals before loading the text
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
250 self.modificationChanged.connect(self.__modificationChanged)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
251 self.cursorPositionChanged.connect(self.__cursorPositionChanged)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
252 self.modificationAttempted.connect(self.__modificationReadOnly)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
253 self.userListActivated.connect(self.__completionListSelected)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
254
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
255 # margins layout
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
256 if QSCINTILLA_VERSION() >= 0x020301:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
257 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
258 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
259 self.__unifiedMargins = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
260
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
261 # define the margins markers
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
262 self.__changeMarkerSaved = self.markerDefine(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
263 self.__createChangeMarkerPixmap(
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
264 "OnlineChangeTraceMarkerSaved"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
265 self.__changeMarkerUnsaved = self.markerDefine(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
266 self.__createChangeMarkerPixmap(
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
267 "OnlineChangeTraceMarkerUnsaved"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
268 self.breakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
269 self.markerDefine(UI.PixmapCache.getPixmap("break.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
270 self.cbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
271 self.markerDefine(UI.PixmapCache.getPixmap("cBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
272 self.tbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
273 self.markerDefine(UI.PixmapCache.getPixmap("tBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
274 self.tcbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
275 self.markerDefine(UI.PixmapCache.getPixmap("tCBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
276 self.dbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
277 self.markerDefine(UI.PixmapCache.getPixmap("breakDisabled.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
278 self.bookmark = \
1106
3e57cd52e0f6 Added icons to the Mercurial extensions menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1063
diff changeset
279 self.markerDefine(UI.PixmapCache.getPixmap("bookmark16.png"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
280 self.syntaxerror = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
281 self.markerDefine(UI.PixmapCache.getPixmap("syntaxError.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
282 self.notcovered = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
283 self.markerDefine(UI.PixmapCache.getPixmap("notcovered.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
284 self.taskmarker = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
285 self.markerDefine(UI.PixmapCache.getPixmap("task.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
286 self.warning = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
287 self.markerDefine(UI.PixmapCache.getPixmap("warning.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
288
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
289 # define the line markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
290 self.currentline = self.markerDefine(QsciScintilla.Background)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
291 self.errorline = self.markerDefine(QsciScintilla.Background)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
292 self.__setLineMarkerColours()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
293
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
294 self.breakpointMask = (1 << self.breakpoint) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
295 (1 << self.cbreakpoint) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
296 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
297 (1 << self.tcbreakpoint) | \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
298 (1 << self.dbreakpoint)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
299
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
300 self.changeMarkersMask = (1 << self.__changeMarkerSaved) | \
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
301 (1 << self.__changeMarkerUnsaved)
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
302
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
303 self.__markerMap = EditorMarkerMap(self)
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
304
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
305 # configure the margins
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
306 self.__setMarginsDisplay()
2640
dedcd4f987e0 Changed the line numbers margin to adjust themselves to the size needed (Editor, Mini Editor, Shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2632
diff changeset
307 self.linesChanged.connect(self.__resizeLinenoMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
308
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
309 self.marginClicked.connect(self.__marginClicked)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
310
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
311 # set the eol mode
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
312 self.__setEolMode()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
313
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
314 # set the text display
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
315 self.__setTextDisplay()
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
316
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
317 # initialize the online syntax check timer
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
318 self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
319 self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
320 self.__initOnlineSyntaxCheck()
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
321
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
322 self.isResourcesFile = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
323 if editor is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
324 if self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
325 if (QFileInfo(self.fileName).size() // 1024) > \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
326 Preferences.getEditor("WarnFilesize"):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
327 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
328 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
329 self.tr("Open File"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
330 self.tr("""<p>The size of the file <b>{0}</b>"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
331 """ is <b>{1} KB</b>."""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
332 """ Do you really want to load it?</p>""")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
333 .format(self.fileName,
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
334 QFileInfo(self.fileName).size() // 1024),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
335 icon=E5MessageBox.Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
336 if not res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
337 raise IOError()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
338 self.readFile(self.fileName, True)
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
339 self.__bindLexer(self.fileName)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
340 self.__bindCompleter(self.fileName)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
341 self.checkSyntax()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
342 self.isResourcesFile = self.fileName.endswith(".qrc")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
343
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
344 self.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
345 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
346 # clone the given editor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
347 self.setDocument(editor.document())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
348 self.breaks = editor.breaks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
349 self.bookmarks = editor.bookmarks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
350 self.syntaxerrors = editor.syntaxerrors
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
351 self.notcoveredMarkers = editor.notcoveredMarkers
2391
f9a6a512bc1e Added functionality to refresh the coverage markers of an editor if such are shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
352 self.showingNotcoveredMarkers = editor.showingNotcoveredMarkers
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
353 self.isResourcesFile = editor.isResourcesFile
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
354 self.lastModified = editor.lastModified
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
355
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
356 self.addClone(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
357 editor.addClone(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
358
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
359 self.gotoLine(1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
360
741
137cc6344b48 Fixed an issue in the Editor class introduced by the annotation job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 730
diff changeset
361 # set the text display again
137cc6344b48 Fixed an issue in the Editor class introduced by the annotation job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 730
diff changeset
362 self.__setTextDisplay()
137cc6344b48 Fixed an issue in the Editor class introduced by the annotation job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 730
diff changeset
363
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
364 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
365 self.__acHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
366 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
367 self.__ctHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
368 self.__setCallTips()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
369
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
370 sh = self.sizeHint()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
371 if sh.height() < 300:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
372 sh.setHeight(300)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
373 self.resize(sh)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
374
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
375 # Make sure tabbing through a QWorkspace works.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
376 self.setFocusPolicy(Qt.StrongFocus)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
377
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
378 self.__updateReadOnly(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
379
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
380 self.setWhatsThis(self.tr(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
381 """<b>A Source Editor Window</b>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
382 """<p>This window is used to display and edit a source file."""
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
383 """ You can open as many of these as you like. The name of the"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
384 """ file is displayed in the window's titlebar.</p>"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
385 """<p>In order to set breakpoints just click in the space"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
386 """ between the line numbers and the fold markers. Via the"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
387 """ context menu of the margins they may be edited.</p>"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
388 """<p>In order to set bookmarks just Shift click in the space"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
389 """ between the line numbers and the fold markers.</p>"""
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
390 """<p>These actions can be reversed via the context menu.</p>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
391 """<p>Ctrl clicking on a syntax error marker shows some info"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
392 """ about this error.</p>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
393 ))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
394
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
395 # Set the editors size, if it is too big for the view manager.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
396 if self.vm is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
397 req = self.size()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
398 bnd = req.boundedTo(self.vm.size())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
399
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
400 if bnd.width() < req.width() or bnd.height() < req.height():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
401 self.resize(bnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
402
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
403 # set the autosave flag
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
404 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
405 self.autosaveManuallyDisabled = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
406
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
407 self.__initContextMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
408 self.__initContextMenuMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
409
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
410 self.__checkEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
411 if editor is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
412 self.__checkLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
413 self.__checkEncoding()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
414 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
415 # it's a clone
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
416 self.__languageChanged(editor.apiLanguage, propagate=False)
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
417 self.__encodingChanged(editor.encoding, propagate=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
418
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
419 self.setAcceptDrops(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
420
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
421 # breakpoint handling
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
422 self.breakpointModel = self.dbs.getBreakPointModel()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
423 self.__restoreBreakpoints()
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
424 self.breakpointModel.rowsAboutToBeRemoved.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
425 self.__deleteBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
426 self.breakpointModel.dataAboutToBeChanged.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
427 self.__breakPointDataAboutToBeChanged)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
428 self.breakpointModel.dataChanged.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
429 self.__changeBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
430 self.breakpointModel.rowsInserted.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
431 self.__addBreakPoints)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
432 self.SCN_MODIFIED.connect(self.__modified)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
433
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
434 # establish connection to some ViewManager action groups
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
435 self.addActions(self.vm.editorActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
436 self.addActions(self.vm.editActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
437 self.addActions(self.vm.copyActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
438 self.addActions(self.vm.viewActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
439
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
440 # register images to be shown in autocompletion lists
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
441 self.__registerImages()
1169
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
442
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
443 # connect signals after loading the text
36a3bb21e6e6 Added editor actions to go to the last edit location and to the previous or next Python or Ruby class or method definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
444 self.textChanged.connect(self.__textChanged)
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
445
2162
4627e6ea7b6b Added capability to mark changed lines and to navigate between them to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
446 # initialize the online change trace timer
4627e6ea7b6b Added capability to mark changed lines and to navigate between them to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
447 self.__initOnlineChangeTrace()
4627e6ea7b6b Added capability to mark changed lines and to navigate between them to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
448
1754
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
449 if self.fileName and \
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
450 self.project.isOpen() and \
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
451 self.project.isProjectSource(self.fileName):
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
452 self.project.projectPropertiesChanged.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
453 self.__projectPropertiesChanged)
1754
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
454
1518
e6e21910210d Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
455 self.grabGesture(Qt.PinchGesture)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
456
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
457 self.SCN_ZOOM.connect(self.__markerMap.update)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
458 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
459
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
460 def __registerImages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
461 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
462 Private method to register images for autocompletion lists.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
463 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
464 self.registerImage(self.ClassID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
465 UI.PixmapCache.getPixmap("class.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
466 self.registerImage(self.ClassProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
467 UI.PixmapCache.getPixmap("class_protected.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
468 self.registerImage(self.ClassPrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
469 UI.PixmapCache.getPixmap("class_private.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
470 self.registerImage(self.MethodID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
471 UI.PixmapCache.getPixmap("method.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
472 self.registerImage(self.MethodProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
473 UI.PixmapCache.getPixmap("method_protected.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
474 self.registerImage(self.MethodPrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
475 UI.PixmapCache.getPixmap("method_private.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
476 self.registerImage(self.AttributeID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
477 UI.PixmapCache.getPixmap("attribute.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
478 self.registerImage(self.AttributeProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
479 UI.PixmapCache.getPixmap("attribute_protected.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
480 self.registerImage(self.AttributePrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
481 UI.PixmapCache.getPixmap("attribute_private.png"))
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
482 self.registerImage(self.EnumID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
483 UI.PixmapCache.getPixmap("enum.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
484
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
485 self.registerImage(self.FromDocumentID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
486 UI.PixmapCache.getPixmap("editor.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
487
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
488 self.registerImage(self.TemplateImageID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
489 UI.PixmapCache.getPixmap("templateViewer.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
490
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
491 def addClone(self, editor):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
492 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
493 Public method to add a clone to our list.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
494
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
495 @param editor reference to the cloned editor (Editor)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
496 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
497 self.__clones.append(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
498
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
499 editor.editorRenamed.connect(self.fileRenamed)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
500 editor.languageChanged.connect(self.languageChanged)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
501 editor.eolChanged.connect(self.__eolChanged)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
502 editor.encodingChanged.connect(self.__encodingChanged)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
503
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
504 def removeClone(self, editor):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
505 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
506 Public method to remove a clone from our list.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
507
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
508 @param editor reference to the cloned editor (Editor)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
509 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
510 if editor in self.__clones:
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
511 editor.editorRenamed.disconnect(self.fileRenamed)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
512 editor.languageChanged.disconnect(self.languageChanged)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
513 editor.eolChanged.disconnect(self.__eolChanged)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
514 editor.encodingChanged.disconnect(self.__encodingChanged)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
515 self.__clones.remove(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
516
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
517 def __bindName(self, line0):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
518 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
519 Private method to generate a dummy filename for binding a lexer.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
520
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
521 @param line0 first line of text to use in the generation process
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
522 (string)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
523 @return dummy file name to be used for binding a lexer (string)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
524 """
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
525 bindName = ""
2221
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
526 line0 = line0.lower()
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
527
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
528 # check first line if it does not start with #!
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
529 if line0.startswith(("<html", "<!doctype html", "<?php")):
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
530 bindName = "dummy.html"
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
531 elif line0.startswith(("<?xml", "<!doctype")):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
532 bindName = "dummy.xml"
2221
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
533 elif line0.startswith("index: "):
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
534 bindName = "dummy.diff"
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
535 elif line0.startswith("\\documentclass"):
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
536 bindName = "dummy.tex"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
537
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
538 # check filetype
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
539 if not bindName and self.filetype:
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
540 if self.filetype in ["Python", "Python2"]:
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
541 bindName = "dummy.py"
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
542 elif self.filetype == "Python3":
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
543 bindName = "dummy.py"
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
544 elif self.filetype == "Ruby":
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
545 bindName = "dummy.rb"
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
546 elif self.filetype == "D":
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
547 bindName = "dummy.d"
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
548 elif self.filetype == "Properties":
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
549 bindName = "dummy.ini"
3438
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
550 elif self.filetype == "JavaScript":
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
551 bindName = "dummy.js"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
552
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
553 # #! marker detection
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
554 if not bindName and line0.startswith("#!"):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
555 if "python3" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
556 bindName = "dummy.py"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
557 self.filetype = "Python3"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
558 elif "python2" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
559 bindName = "dummy.py"
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
560 self.filetype = "Python2"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
561 elif "python" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
562 bindName = "dummy.py"
991
5ec5e707dfa5 Changed algorithm to determine the debugger backend type to be used by analysing a first line starting with '#!'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 989
diff changeset
563 self.filetype = "Python2"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
564 elif ("/bash" in line0 or "/sh" in line0):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
565 bindName = "dummy.sh"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
566 elif "ruby" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
567 bindName = "dummy.rb"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
568 self.filetype = "Ruby"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
569 elif "perl" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
570 bindName = "dummy.pl"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
571 elif "lua" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
572 bindName = "dummy.lua"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
573 elif "dmd" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
574 bindName = "dummy.d"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
575 self.filetype = "D"
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
576
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
577 if not bindName:
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
578 bindName = self.fileName
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 777
diff changeset
579
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
580 return bindName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
581
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
582 def getMenu(self, menuName):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
583 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
584 Public method to get a reference to the main context menu or a submenu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
585
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
586 @param menuName name of the menu (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
587 @return reference to the requested menu (QMenu) or None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
588 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
589 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
590 return self.__menus[menuName]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
591 except KeyError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
592 return None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
593
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
594 def hasMiniMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
595 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
596 Public method to check the miniMenu flag.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
597
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
598 @return flag indicating a minimized context menu (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
599 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
600 return self.miniMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
601
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
602 def __initContextMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
603 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
604 Private method used to setup the context menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
605 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
606 self.miniMenu = Preferences.getEditor("MiniContextMenu")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
607
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
608 self.menuActs = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
609 self.menu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
610 self.__menus = {
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
611 "Main": self.menu,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
612 }
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
613
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
614 self.languagesMenu = self.__initContextMenuLanguages()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
615 self.__menus["Languages"] = self.languagesMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
616 if self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
617 self.resourcesMenu = self.__initContextMenuResources()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
618 self.__menus["Resources"] = self.resourcesMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
619 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
620 self.checksMenu = self.__initContextMenuChecks()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
621 self.menuShow = self.__initContextMenuShow()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
622 self.graphicsMenu = self.__initContextMenuGraphics()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
623 self.autocompletionMenu = self.__initContextMenuAutocompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
624 self.__menus["Checks"] = self.checksMenu
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
625 self.__menus["Show"] = self.menuShow
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
626 self.__menus["Graphics"] = self.graphicsMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
627 self.__menus["Autocompletion"] = self.autocompletionMenu
3583
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
628 self.toolsMenu = self.__initContextMenuTools()
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
629 self.__menus["Tools"] = self.toolsMenu
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
630 self.exportersMenu = self.__initContextMenuExporters()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
631 self.__menus["Exporters"] = self.exportersMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
632 self.eolMenu = self.__initContextMenuEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
633 self.__menus["Eol"] = self.eolMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
634 self.encodingsMenu = self.__initContextMenuEncodings()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
635 self.__menus["Encodings"] = self.encodingsMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
636
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
637 self.menuActs["Undo"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
638 UI.PixmapCache.getIcon("editUndo.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
639 self.tr('Undo'), self.undo)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
640 self.menuActs["Redo"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
641 UI.PixmapCache.getIcon("editRedo.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
642 self.tr('Redo'), self.redo)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
643 self.menuActs["Revert"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
644 self.tr("Revert to last saved state"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
645 self.revertToUnmodified)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
646 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
647 self.menuActs["Cut"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
648 UI.PixmapCache.getIcon("editCut.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
649 self.tr('Cut'), self.cut)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
650 self.menuActs["Copy"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
651 UI.PixmapCache.getIcon("editCopy.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
652 self.tr('Copy'), self.copy)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
653 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
654 UI.PixmapCache.getIcon("editPaste.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
655 self.tr('Paste'), self.paste)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
656 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
657 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
658 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
659 UI.PixmapCache.getIcon("editIndent.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
660 self.tr('Indent'), self.indentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
661 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
662 UI.PixmapCache.getIcon("editUnindent.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
663 self.tr('Unindent'), self.unindentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
664 self.menuActs["Comment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
665 UI.PixmapCache.getIcon("editComment.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
666 self.tr('Comment'), self.commentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
667 self.menuActs["Uncomment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
668 UI.PixmapCache.getIcon("editUncomment.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
669 self.tr('Uncomment'), self.uncommentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
670 self.menuActs["StreamComment"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
671 self.tr('Stream Comment'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
672 self.streamCommentLineOrSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
673 self.menuActs["BoxComment"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
674 self.tr('Box Comment'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
675 self.boxCommentLineOrSelection)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
676 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
677 self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
678 self.tr('Select to brace'), self.selectToMatchingBrace)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
679 self.menu.addAction(self.tr('Select all'), self.__selectAll)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
680 self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
681 self.tr('Deselect all'), self.__deselectAll)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
682 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
683 self.menuActs["SpellCheck"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
684 UI.PixmapCache.getIcon("spellchecking.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
685 self.tr('Check spelling...'), self.checkSpelling)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
686 self.menuActs["SpellCheckSelection"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
687 UI.PixmapCache.getIcon("spellchecking.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
688 self.tr('Check spelling of selection...'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
689 self.__checkSpellingSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
690 self.menuActs["SpellCheckRemove"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
691 self.tr("Remove from dictionary"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
692 self.__removeFromSpellingDictionary)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
693 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
694 self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
695 self.tr('Shorten empty lines'), self.shortenEmptyLines)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
696 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
697 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
698 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
699 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
700 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
701 self.menuActs["MonospacedFont"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
702 self.tr("Use Monospaced Font"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
703 self.handleMonospacedEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
704 self.menuActs["MonospacedFont"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
705 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
706 self.menuActs["AutosaveEnable"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
707 self.tr("Autosave enabled"), self.__autosaveEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
708 self.menuActs["AutosaveEnable"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
709 self.menuActs["AutosaveEnable"].setChecked(self.autosaveEnabled)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
710 self.menuActs["TypingAidsEnabled"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
711 self.tr("Typing aids enabled"), self.__toggleTypingAids)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
712 self.menuActs["TypingAidsEnabled"].setCheckable(True)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
713 self.menuActs["TypingAidsEnabled"].setEnabled(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
714 self.completer is not None)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
715 self.menuActs["TypingAidsEnabled"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
716 self.completer is not None and self.completer.isEnabled())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
717 self.menuActs["AutoCompletionEnable"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
718 self.tr("Autocompletion enabled"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
719 self.__toggleAutoCompletionEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
720 self.menuActs["AutoCompletionEnable"].setCheckable(True)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
721 self.menuActs["AutoCompletionEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
722 self.autoCompletionThreshold() != -1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
723 if not self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
724 self.menu.addMenu(self.autocompletionMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
725 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
726 if self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
727 self.menu.addMenu(self.resourcesMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
728 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
729 self.menuActs["Check"] = self.menu.addMenu(self.checksMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
730 self.menu.addSeparator()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
731 self.menuActs["Show"] = self.menu.addMenu(self.menuShow)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
732 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
733 self.menuActs["Diagrams"] = self.menu.addMenu(self.graphicsMenu)
3583
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
734 self.menu.addSeparator()
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
735 self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu)
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
736 self.menu.addSeparator()
3100
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
737 self.menu.addAction(
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
738 UI.PixmapCache.getIcon("documentNewView.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
739 self.tr('New Document View'), self.__newView)
3100
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
740 self.menuActs["NewSplit"] = self.menu.addAction(
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
741 UI.PixmapCache.getIcon("splitVertical.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
742 self.tr('New Document View (with new split)'),
3100
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
743 self.__newViewNewSplit)
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
744 self.menuActs["NewSplit"].setEnabled(self.vm.canSplit())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
745 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
746 UI.PixmapCache.getIcon("close.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
747 self.tr('Close'), self.__contextClose)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
748 self.menu.addSeparator()
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
749 self.reopenEncodingMenu = self.__initContextMenuReopenWithEncoding()
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
750 self.menuActs["Reopen"] = self.menu.addMenu(self.reopenEncodingMenu)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
751 self.menuActs["Save"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
752 UI.PixmapCache.getIcon("fileSave.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
753 self.tr('Save'), self.__contextSave)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
754 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
755 UI.PixmapCache.getIcon("fileSaveAs.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
756 self.tr('Save As...'), self.__contextSaveAs)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
757 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
758 self.menu.addMenu(self.exportersMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
759 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
760 self.menuActs["OpenRejections"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
761 self.tr("Open 'rejection' file"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
762 self.__contextOpenRejections)
1299
fd5d21389d2b Added an action to the editor context menu and to the tabview and listview view managers to open an associated 'rejections' file (i.e. same file name with '.rej' appended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1295
diff changeset
763 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
764 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
765 UI.PixmapCache.getIcon("printPreview.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
766 self.tr("Print Preview"), self.printPreviewFile)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
767 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
768 UI.PixmapCache.getIcon("print.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
769 self.tr('Print'), self.printFile)
1299
fd5d21389d2b Added an action to the editor context menu and to the tabview and listview view managers to open an associated 'rejections' file (i.e. same file name with '.rej' appended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1295
diff changeset
770 else:
fd5d21389d2b Added an action to the editor context menu and to the tabview and listview view managers to open an associated 'rejections' file (i.e. same file name with '.rej' appended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1295
diff changeset
771 self.menuActs["OpenRejections"] = None
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
772
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
773 self.menu.aboutToShow.connect(self.__showContextMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
774
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
775 self.spellingMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
776 self.__menus["Spelling"] = self.spellingMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
777
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
778 self.spellingMenu.aboutToShow.connect(self.__showContextMenuSpelling)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
779 self.spellingMenu.triggered.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
780 self.__contextMenuSpellingTriggered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
781
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
782 def __initContextMenuAutocompletion(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
783 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
784 Private method used to setup the Checks context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
785
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
786 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
787 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
788 menu = QMenu(self.tr('Autocomplete'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
789
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
790 self.menuActs["acDynamic"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
791 self.tr('dynamic'), self.autoComplete)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
792 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
793 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
794 self.tr('from Document'), self.autoCompleteFromDocument)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
795 self.menuActs["acAPI"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
796 self.tr('from APIs'), self.autoCompleteFromAPIs)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
797 self.menuActs["acAPIDocument"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
798 self.tr('from Document and APIs'), self.autoCompleteFromAll)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
799 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
800 self.menuActs["calltip"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
801 self.tr('Calltip'), self.callTip)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
802
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
803 menu.aboutToShow.connect(self.__showContextMenuAutocompletion)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
804
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
805 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
806
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
807 def __initContextMenuChecks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
808 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
809 Private method used to setup the Checks context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
810
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
811 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
812 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
813 menu = QMenu(self.tr('Check'))
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
814 menu.aboutToShow.connect(self.__showContextMenuChecks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
815 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
816
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
817 def __initContextMenuTools(self):
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
818 """
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
819 Private method used to setup the Tools context sub menu.
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
820
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
821 @return reference to the generated menu (QMenu)
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
822 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
823 menu = QMenu(self.tr('Tools'))
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
824 menu.aboutToShow.connect(self.__showContextMenuTools)
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
825 return menu
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
826
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
827 def __initContextMenuShow(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
828 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
829 Private method used to setup the Show context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
830
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
831 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
832 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
833 menu = QMenu(self.tr('Show'))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
834
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
835 menu.addAction(self.tr('Code metrics...'), self.__showCodeMetrics)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
836 self.coverageMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
837 self.tr('Code coverage...'), self.__showCodeCoverage)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
838 self.coverageShowAnnotationMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
839 self.tr('Show code coverage annotations'),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
840 self.codeCoverageShowAnnotations)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
841 self.coverageHideAnnotationMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
842 self.tr('Hide code coverage annotations'),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
843 self.__codeCoverageHideAnnotations)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
844 self.profileMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
845 self.tr('Profile data...'), self.__showProfileData)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
846
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
847 menu.aboutToShow.connect(self.__showContextMenuShow)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
848
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
849 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
850
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
851 def __initContextMenuGraphics(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
852 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
853 Private method used to setup the diagrams context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
854
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
855 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
856 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
857 menu = QMenu(self.tr('Diagrams'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
858
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
859 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
860 self.tr('Class Diagram...'), self.__showClassDiagram)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
861 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
862 self.tr('Package Diagram...'), self.__showPackageDiagram)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
863 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
864 self.tr('Imports Diagram...'), self.__showImportsDiagram)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
865 self.applicationDiagramMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
866 self.tr('Application Diagram...'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
867 self.__showApplicationDiagram)
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
868 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
869 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
870 UI.PixmapCache.getIcon("open.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
871 self.tr("Load Diagram..."), self.__loadDiagram)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
872
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
873 menu.aboutToShow.connect(self.__showContextMenuGraphics)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
874
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
875 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
876
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
877 def __initContextMenuLanguages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
878 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
879 Private method used to setup the Languages context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
880
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
881 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
882 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
883 menu = QMenu(self.tr("Languages"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
884
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
885 self.languagesActGrp = QActionGroup(self)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
886 self.noLanguageAct = menu.addAction(self.tr("No Language"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
887 self.noLanguageAct.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
888 self.noLanguageAct.setData("None")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
889 self.languagesActGrp.addAction(self.noLanguageAct)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
890 menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
891
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
892 from . import Lexers
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
893 self.supportedLanguages = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
894 supportedLanguages = Lexers.getSupportedLanguages()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
895 languages = sorted(list(supportedLanguages.keys()))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
896 for language in languages:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
897 if language != "Guessed":
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
898 self.supportedLanguages[language] = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
899 supportedLanguages[language][:2]
2217
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2216
diff changeset
900 act = menu.addAction(
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2216
diff changeset
901 UI.PixmapCache.getIcon(supportedLanguages[language][2]),
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2216
diff changeset
902 self.supportedLanguages[language][0])
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
903 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
904 act.setData(language)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
905 self.supportedLanguages[language].append(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
906 self.languagesActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
907
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
908 menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
909 self.pygmentsAct = menu.addAction(self.tr("Guessed"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
910 self.pygmentsAct.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
911 self.pygmentsAct.setData("Guessed")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
912 self.languagesActGrp.addAction(self.pygmentsAct)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
913 self.pygmentsSelAct = menu.addAction(self.tr("Alternatives"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
914 self.pygmentsSelAct.setData("Alternatives")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
915
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
916 menu.triggered.connect(self.__languageMenuTriggered)
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
917 menu.aboutToShow.connect(self.__showContextMenuLanguages)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
918
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
919 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
920
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
921 def __initContextMenuEncodings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
922 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
923 Private method used to setup the Encodings context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
924
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
925 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
926 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
927 self.supportedEncodings = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
928
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
929 menu = QMenu(self.tr("Encodings"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
930
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
931 self.encodingsActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
932
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
933 for encoding in sorted(Utilities.supportedCodecs):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
934 act = menu.addAction(encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
935 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
936 act.setData(encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
937 self.supportedEncodings[encoding] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
938 self.encodingsActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
939
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
940 menu.triggered.connect(self.__encodingsMenuTriggered)
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
941 menu.aboutToShow.connect(self.__showContextMenuEncodings)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
942
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
943 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
944
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
945 def __initContextMenuReopenWithEncoding(self):
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
946 """
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
947 Private method used to setup the Reopen With Encoding context sub menu.
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
948
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
949 @return reference to the generated menu (QMenu)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
950 """
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
951 menu = QMenu(self.tr("Re-Open With Encoding"))
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
952 menu.setIcon(UI.PixmapCache.getIcon("open.png"))
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
953
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
954 for encoding in sorted(Utilities.supportedCodecs):
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
955 act = menu.addAction(encoding)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
956 act.setData(encoding)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
957
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
958 menu.triggered.connect(self.__reopenWithEncodingMenuTriggered)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
959
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
960 return menu
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
961
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
962 def __initContextMenuEol(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
963 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
964 Private method to setup the eol context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
966 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
967 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
968 self.supportedEols = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
969
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
970 menu = QMenu(self.tr("End-of-Line Type"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
971
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
972 self.eolActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
973
2217
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2216
diff changeset
974 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
975 self.tr("Unix"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
976 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
977 act.setData('\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
978 self.supportedEols['\n'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
979 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
980
2217
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2216
diff changeset
981 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
982 self.tr("Windows"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
983 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
984 act.setData('\r\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
985 self.supportedEols['\r\n'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
986 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
987
2217
e80c74f2a25a Added some icons to the "Languages" and "End-of-Line Type" context menus of the editor and changed the status labels for programming language and end-of-line type of the main window to show an icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2216
diff changeset
988 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
989 self.tr("Macintosh"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
990 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
991 act.setData('\r')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
992 self.supportedEols['\r'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
993 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
994
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
995 menu.triggered.connect(self.__eolMenuTriggered)
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
996 menu.aboutToShow.connect(self.__showContextMenuEol)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
997
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
998 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
999
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1000 def __initContextMenuExporters(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1001 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1002 Private method used to setup the Exporters context sub menu.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1003
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1004 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1005 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1006 menu = QMenu(self.tr("Export as"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1007
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1008 from . import Exporters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1009 supportedExporters = Exporters.getSupportedFormats()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1010 exporters = sorted(list(supportedExporters.keys()))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1011 for exporter in exporters:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1012 act = menu.addAction(supportedExporters[exporter])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1013 act.setData(exporter)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1014
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1015 menu.triggered.connect(self.__exportMenuTriggered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1016
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1017 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1018
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1019 def __initContextMenuMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1020 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1021 Private method used to setup the context menu for the margins.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1022 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1023 self.marginMenuActs = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1024
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1025 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1026 self.__initContextMenuUnifiedMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1027 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1028 self.__initContextMenuSeparateMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1029
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1030 def __initContextMenuSeparateMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1031 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1032 Private method used to setup the context menu for the separated
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1033 margins.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1034 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1035 # bookmark margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1036 self.bmMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1037
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1038 self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1039 self.tr('Toggle bookmark'), self.menuToggleBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1040 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1041 self.tr('Next bookmark'), self.nextBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1042 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1043 self.tr('Previous bookmark'), self.previousBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1044 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1045 self.tr('Clear all bookmarks'), self.clearBookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1046
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1047 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1048
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1049 # breakpoint margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1050 self.bpMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <d