QScintilla/Editor.py

Thu, 27 Mar 2014 21:27:08 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Thu, 27 Mar 2014 21:27:08 +0100
branch
BgService
changeset 3442
927186c0d409
parent 3412
9364dab2d472
child 3456
96232974dcdb
permissions
-rw-r--r--

Updated behavior of the Python version detection.

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
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2262
diff changeset
3 # Copyright (c) 2002 - 2013 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 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7 Module implementing the editor component of the eric5 IDE.
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
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1106
diff changeset
20 from PyQt4.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
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
22 from PyQt4.QtGui import QCursor, QPrinter, QPrintDialog, QLineEdit, \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
23 QActionGroup, QDialog, QAbstractPrintDialog, QInputDialog, QApplication, \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
24 QMenu, QPalette, QFont, QPixmap, QPainter
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1106
diff changeset
25 from PyQt4.Qsci import QsciScintilla, QsciMacro, QsciStyledText
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
26
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
27 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
28 from E5Gui import E5FileDialog, E5MessageBox
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
29
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
30 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
31
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
32 import Preferences
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
33 import Utilities
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
34
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
35 import UI.PixmapCache
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 EditorAutoCompletionListID = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
38 TemplateCompletionListID = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
39
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
40
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
41 class Editor(QsciScintillaCompat):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
42 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
43 Class implementing the editor component of the eric5 IDE.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
44
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
45 @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
46 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
47 @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
48 @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
49 @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
50 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
51 @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
52 @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
53 @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
54 @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
55 (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
56 @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
57 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
58 @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
59 is toggled
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
60 @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
61 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
62 @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
63 was discovered
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
64 @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
65 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
66 @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
67 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
68 @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
69 markers were updated
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
70 @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
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 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
73 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
74 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
75 @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
76 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
77 @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
78 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
79 @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
80 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
81 @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
82 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
83 @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
84 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
85 modificationStatusChanged = pyqtSignal(bool, QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
86 undoAvailable = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
87 redoAvailable = pyqtSignal(bool)
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
88 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
89 cursorLineChanged = pyqtSignal(int)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
90 editorAboutToBeSaved = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
91 editorSaved = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
92 editorRenamed = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
93 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
94 breakpointToggled = pyqtSignal(QsciScintillaCompat)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
95 bookmarkToggled = pyqtSignal(QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
96 syntaxerrorToggled = pyqtSignal(QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
97 autoCompletionAPIsAvailable = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
98 coverageMarkersShown = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
99 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
100 changeMarkersUpdated = pyqtSignal(QsciScintillaCompat)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
101 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
102 languageChanged = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
103 eolChanged = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
104 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
105 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
106 refreshed = pyqtSignal()
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
107
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
108 WarningCode = 1
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
109 WarningStyle = 2
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
110
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
111 # 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
112 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
113 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
114 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
115 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
116 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
117 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
118 AttributeID = 7
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
119 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
120 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
121 EnumID = 10
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
122
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
123 FromDocumentID = 99
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 TemplateImageID = 100
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
126
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
127 # Cooperation related definitions
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
128 Separator = "@@@"
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
129
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
130 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
131 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
132 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
133 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
134 SyncToken = "SYNC"
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
135
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
136 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
137 filetype="", editor=None, tv=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
138 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
139 Constructor
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 @param dbs reference to the debug server object
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
142 @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
143 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
144 @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
145 (ViewManager.ViewManager)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
146 @param filetype type of the source file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
147 @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
148 @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
149 @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
150 """
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
151 super(Editor, self).__init__()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
152 self.setAttribute(Qt.WA_DeleteOnClose)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
153 self.setAttribute(Qt.WA_KeyCompression)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
154 self.setUtf8(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
155
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
156 self.dbs = dbs
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
157 self.taskViewer = tv
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
158 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
159 self.vm = vm
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
160 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
161 self.filetypeByFlag = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
162 self.noName = ""
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
163 self.project = e5App().getObject("Project")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
164
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
165 # 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
166 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
167 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
168 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
169
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
170 self.breaks = {}
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
171 # key: marker handle,
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
172 # value: (lineno, condition, temporary,
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
173 # enabled, ignorecount)
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
174 self.bookmarks = []
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
175 # bookmarks are just a list of handles to the
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
176 # bookmark markers
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
177 self.syntaxerrors = {}
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
178 # key: marker handle
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
179 # value: list of (error message, error index)
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
180 self.warnings = {}
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
181 # key: marker handle
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
182 # 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
183 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
184 self.showingNotcoveredMarkers = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
185
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
186 self.condHistory = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
187 self.lexer_ = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
188 self.__lexerReset = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
189 self.completer = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
190 self.encoding = Preferences.getEditor("DefaultEncoding")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
191 self.apiLanguage = ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
192 self.lastModified = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
193 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
194 self.inReopenPrompt = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
195 # 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
196 self.inFileRenamed = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
197 # true if we are propagating a rename action
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
198 self.inLanguageChanged = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
199 # true if we are propagating a language change
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
200 self.inEolChanged = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
201 # true if we are propagating an eol change
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
202 self.inEncodingChanged = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
203 # true if we are propagating an encoding change
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
204 self.inDragDrop = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
205 # true if we are in drop mode
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
206 self.inLinesChanged = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
207 # true if we are propagating a lines changed event
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
208 self.__hasTaskMarkers = False
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
209 # no task markers present
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
210
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
211 self.macros = {} # list of defined macros
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
212 self.curMacro = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
213 self.recording = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
214
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
215 self.acAPI = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
216
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
217 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
218
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
219 # list of clones
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
220 self.__clones = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
221
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
222 # clear QScintilla defined keyboard commands
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
223 # 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
224 self.clearAlternateKeys()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
225 self.clearKeys()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
226
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
227 # initialize the mark occurrences timer
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
228 self.__markOccurrencesTimer = QTimer(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
229 self.__markOccurrencesTimer.setSingleShot(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
230 self.__markOccurrencesTimer.setInterval(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
231 Preferences.getEditor("MarkOccurrencesTimeout"))
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
232 self.__markOccurrencesTimer.timeout.connect(self.__markOccurrences)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
233 self.__markedText = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
234
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
235 # initialize some spellchecking stuff
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
236 self.spell = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
237 self.lastLine = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
238 self.lastIndex = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
239
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
240 # initialize some cooperation stuff
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
241 self.__isSyncing = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
242 self.__receivedWhileSyncing = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
243 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
244 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
245 self.__isShared = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
246 self.__inRemoteSharedEdit = False
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
247
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
248 # 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
249 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
250 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
251 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
252 self.userListActivated.connect(self.__completionListSelected)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
253
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
254 # margins layout
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
255 if QSCINTILLA_VERSION() >= 0x020301:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
256 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
257 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
258 self.__unifiedMargins = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
259
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
260 # 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
261 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
262 self.__createChangeMarkerPixmap(
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
263 "OnlineChangeTraceMarkerSaved"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
264 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
265 self.__createChangeMarkerPixmap(
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
266 "OnlineChangeTraceMarkerUnsaved"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
267 self.breakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
268 self.markerDefine(UI.PixmapCache.getPixmap("break.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
269 self.cbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
270 self.markerDefine(UI.PixmapCache.getPixmap("cBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
271 self.tbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
272 self.markerDefine(UI.PixmapCache.getPixmap("tBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
273 self.tcbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
274 self.markerDefine(UI.PixmapCache.getPixmap("tCBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
275 self.dbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
276 self.markerDefine(UI.PixmapCache.getPixmap("breakDisabled.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
277 self.bookmark = \
1106
3e57cd52e0f6 Added icons to the Mercurial extensions menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1063
diff changeset
278 self.markerDefine(UI.PixmapCache.getPixmap("bookmark16.png"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
279 self.syntaxerror = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
280 self.markerDefine(UI.PixmapCache.getPixmap("syntaxError.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
281 self.notcovered = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
282 self.markerDefine(UI.PixmapCache.getPixmap("notcovered.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
283 self.taskmarker = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
284 self.markerDefine(UI.PixmapCache.getPixmap("task.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
285 self.warning = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
286 self.markerDefine(UI.PixmapCache.getPixmap("warning.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
287
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
288 # define the line markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
289 self.currentline = self.markerDefine(QsciScintilla.Background)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
290 self.errorline = self.markerDefine(QsciScintilla.Background)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
291 self.__setLineMarkerColours()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
292
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
293 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
294 (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
295 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
296 (1 << self.tcbreakpoint) | \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
297 (1 << self.dbreakpoint)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
298
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
299 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
300 (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
301
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
302 # configure the margins
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
303 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
304 self.linesChanged.connect(self.__resizeLinenoMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
305
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
306 self.marginClicked.connect(self.__marginClicked)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
307
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
308 # set the eol mode
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
309 self.__setEolMode()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
310
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
311 # set the text display
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
312 self.__setTextDisplay()
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
313
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
314 # 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
315 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
316 self.syntaxCheckService.syntaxChecked.connect(self.__processResult)
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
317 self.__initOnlineSyntaxCheck()
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
318
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
319 self.isResourcesFile = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
320 if editor is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
321 if self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
322 if (QFileInfo(self.fileName).size() // 1024) > \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
323 Preferences.getEditor("WarnFilesize"):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
324 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
325 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
326 self.trUtf8("Open File"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
327 self.trUtf8("""<p>The size of the file <b>{0}</b>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
328 """ is <b>{1} KB</b>."""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
329 """ 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
330 .format(self.fileName,
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
331 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
332 icon=E5MessageBox.Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
333 if not res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
334 raise IOError()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
335 self.readFile(self.fileName, True)
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
336 self.__bindLexer(self.fileName)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
337 self.__bindCompleter(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
338 self.__autoSyntaxCheck()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
339 self.isResourcesFile = self.fileName.endswith(".qrc")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
340
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
341 self.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
342 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
343 # clone the given editor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
344 self.setDocument(editor.document())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
345 self.breaks = editor.breaks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
346 self.bookmarks = editor.bookmarks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
347 self.syntaxerrors = editor.syntaxerrors
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
348 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
349 self.showingNotcoveredMarkers = editor.showingNotcoveredMarkers
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
350 self.isResourcesFile = editor.isResourcesFile
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
351 self.lastModified = editor.lastModified
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
352
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
353 self.addClone(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
354 editor.addClone(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
355
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
356 self.gotoLine(1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
357
741
137cc6344b48 Fixed an issue in the Editor class introduced by the annotation job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 730
diff changeset
358 # 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
359 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
360
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
361 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
362 self.__acHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
363 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
364 self.__ctHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
365 self.__setCallTips()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
366
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
367 sh = self.sizeHint()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
368 if sh.height() < 300:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
369 sh.setHeight(300)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
370 self.resize(sh)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
371
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
372 # Make sure tabbing through a QWorkspace works.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
373 self.setFocusPolicy(Qt.StrongFocus)
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 self.__updateReadOnly(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
376
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
377 self.setWhatsThis(self.trUtf8(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
378 """<b>A Source Editor Window</b>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
379 """<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
380 """ 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
381 """ 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
382 """<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
383 """ 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
384 """ 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
385 """<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
386 """ 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
387 """<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
388 """<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
389 """ about this error.</p>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
390 ))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
391
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
392 # 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
393 if self.vm is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
394 req = self.size()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
395 bnd = req.boundedTo(self.vm.size())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
396
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
397 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
398 self.resize(bnd)
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 # set the autosave flag
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
401 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
402 self.autosaveManuallyDisabled = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
403
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
404 self.__initContextMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
405 self.__initContextMenuMargins()
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.__checkEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
408 if editor is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
409 self.__checkLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
410 self.__checkEncoding()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
411 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
412 # 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
413 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
414 self.__encodingChanged(editor.encoding, propagate=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
415
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
416 self.setAcceptDrops(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
417
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
418 # breakpoint handling
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
419 self.breakpointModel = self.dbs.getBreakPointModel()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
420 self.__restoreBreakpoints()
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
421 self.breakpointModel.rowsAboutToBeRemoved.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
422 self.__deleteBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
423 self.breakpointModel.dataAboutToBeChanged.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
424 self.__breakPointDataAboutToBeChanged)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
425 self.breakpointModel.dataChanged.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
426 self.__changeBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
427 self.breakpointModel.rowsInserted.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
428 self.__addBreakPoints)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
429 self.SCN_MODIFIED.connect(self.__modified)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
430
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
431 # establish connection to some ViewManager action groups
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
432 self.addActions(self.vm.editorActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
433 self.addActions(self.vm.editActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
434 self.addActions(self.vm.copyActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
435 self.addActions(self.vm.viewActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
436
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
437 # register images to be shown in autocompletion lists
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
438 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
439
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
440 # 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
441 self.textChanged.connect(self.__textChanged)
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
442
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
443 # 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
444 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
445
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
446 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
447 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
448 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
449 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
450 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
451
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
452 self.grabGesture(Qt.PinchGesture)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
453
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
454 def __registerImages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
455 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
456 Private method to register images for autocompletion lists.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
457 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
458 self.registerImage(self.ClassID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
459 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
460 self.registerImage(self.ClassProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
461 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
462 self.registerImage(self.ClassPrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
463 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
464 self.registerImage(self.MethodID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
465 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
466 self.registerImage(self.MethodProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
467 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
468 self.registerImage(self.MethodPrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
469 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
470 self.registerImage(self.AttributeID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
471 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
472 self.registerImage(self.AttributeProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
473 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
474 self.registerImage(self.AttributePrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
475 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
476 self.registerImage(self.EnumID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
477 UI.PixmapCache.getPixmap("enum.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
478
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
479 self.registerImage(self.FromDocumentID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
480 UI.PixmapCache.getPixmap("editor.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
481
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.TemplateImageID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
483 UI.PixmapCache.getPixmap("templateViewer.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
484
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
485 def addClone(self, editor):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
486 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
487 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
488
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
489 @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
490 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
491 self.__clones.append(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
492
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
493 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
494 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
495 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
496 editor.encodingChanged.connect(self.__encodingChanged)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
497
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
498 def removeClone(self, editor):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
499 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
500 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
501
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
502 @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
503 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
504 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
505 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
506 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
507 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
508 editor.encodingChanged.disconnect(self.__encodingChanged)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
509 self.__clones.remove(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
510
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
511 def __bindName(self, line0):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
512 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
513 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
514
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
515 @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
516 (string)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
517 @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
518 """
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
519 bindName = ""
2221
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
520 line0 = line0.lower()
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
521
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
522 # 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
523 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
524 bindName = "dummy.html"
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
525 elif line0.startswith(("<?xml", "<!doctype")):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
526 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
527 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
528 bindName = "dummy.diff"
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
529 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
530 bindName = "dummy.tex"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
531
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
532 # 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
533 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
534 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
535 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
536 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
537 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
538 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
539 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
540 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
541 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
542 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
543 bindName = "dummy.ini"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
544
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
545 # #! 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
546 if not bindName and line0.startswith("#!"):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
547 if "python3" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
548 bindName = "dummy.py"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
549 self.filetype = "Python3"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
550 elif "python2" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
551 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
552 self.filetype = "Python2"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
553 elif "python" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
554 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
555 self.filetype = "Python2"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
556 elif ("/bash" in line0 or "/sh" in line0):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
557 bindName = "dummy.sh"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
558 elif "ruby" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
559 bindName = "dummy.rb"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
560 self.filetype = "Ruby"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
561 elif "perl" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
562 bindName = "dummy.pl"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
563 elif "lua" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
564 bindName = "dummy.lua"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
565 elif "dmd" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
566 bindName = "dummy.d"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
567 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
568
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
569 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
570 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
571
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
572 return bindName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
573
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
574 def getMenu(self, menuName):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
575 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
576 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
577
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
578 @param menuName name of the menu (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
579 @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
580 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
581 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
582 return self.__menus[menuName]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
583 except KeyError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
584 return None
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 def hasMiniMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
587 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
588 Public method to check the miniMenu flag.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
589
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
590 @return flag indicating a minimized context menu (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
591 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
592 return self.miniMenu
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 __initContextMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
595 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
596 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
597 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
598 self.miniMenu = Preferences.getEditor("MiniContextMenu")
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 self.menuActs = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
601 self.menu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
602 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
603 "Main": self.menu,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
604 }
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.languagesMenu = self.__initContextMenuLanguages()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
607 self.__menus["Languages"] = self.languagesMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
608 if self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
609 self.resourcesMenu = self.__initContextMenuResources()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
610 self.__menus["Resources"] = self.resourcesMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
611 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
612 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
613 self.menuShow = self.__initContextMenuShow()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
614 self.graphicsMenu = self.__initContextMenuGraphics()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
615 self.autocompletionMenu = self.__initContextMenuAutocompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
616 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
617 self.__menus["Show"] = self.menuShow
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
618 self.__menus["Graphics"] = self.graphicsMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
619 self.__menus["Autocompletion"] = self.autocompletionMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
620 self.exportersMenu = self.__initContextMenuExporters()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
621 self.__menus["Exporters"] = self.exportersMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
622 self.eolMenu = self.__initContextMenuEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
623 self.__menus["Eol"] = self.eolMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
624 self.encodingsMenu = self.__initContextMenuEncodings()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
625 self.__menus["Encodings"] = self.encodingsMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
626
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
627 self.menuActs["Undo"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
628 UI.PixmapCache.getIcon("editUndo.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
629 self.trUtf8('Undo'), self.undo)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
630 self.menuActs["Redo"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
631 UI.PixmapCache.getIcon("editRedo.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
632 self.trUtf8('Redo'), self.redo)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
633 self.menuActs["Revert"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
634 self.trUtf8("Revert to last saved state"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
635 self.revertToUnmodified)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
636 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
637 self.menuActs["Cut"] = 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("editCut.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
639 self.trUtf8('Cut'), self.cut)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
640 self.menuActs["Copy"] = 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("editCopy.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
642 self.trUtf8('Copy'), self.copy)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
643 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
644 UI.PixmapCache.getIcon("editPaste.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
645 self.trUtf8('Paste'), self.paste)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
646 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
647 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
648 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
649 UI.PixmapCache.getIcon("editIndent.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
650 self.trUtf8('Indent'), self.indentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
651 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
652 UI.PixmapCache.getIcon("editUnindent.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
653 self.trUtf8('Unindent'), self.unindentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
654 self.menuActs["Comment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
655 UI.PixmapCache.getIcon("editComment.png"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
656 self.trUtf8('Comment'), self.commentLineOrSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
657 self.menuActs["Uncomment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
658 UI.PixmapCache.getIcon("editUncomment.png"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
659 self.trUtf8('Uncomment'), self.uncommentLineOrSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
660 self.menuActs["StreamComment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
661 self.trUtf8('Stream Comment'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
662 self.streamCommentLineOrSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
663 self.menuActs["BoxComment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
664 self.trUtf8('Box Comment'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
665 self.boxCommentLineOrSelection)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
666 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
667 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
668 self.trUtf8('Select to brace'), self.selectToMatchingBrace)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
669 self.menu.addAction(self.trUtf8('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
670 self.menu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
671 self.trUtf8('Deselect all'), self.__deselectAll)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
672 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
673 self.menuActs["SpellCheck"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
674 UI.PixmapCache.getIcon("spellchecking.png"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
675 self.trUtf8('Check spelling...'), self.checkSpelling)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
676 self.menuActs["SpellCheckSelection"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
677 UI.PixmapCache.getIcon("spellchecking.png"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
678 self.trUtf8('Check spelling of selection...'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
679 self.__checkSpellingSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
680 self.menuActs["SpellCheckRemove"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
681 self.trUtf8("Remove from dictionary"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
682 self.__removeFromSpellingDictionary)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
683 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
684 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
685 self.trUtf8('Shorten empty lines'), self.shortenEmptyLines)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
686 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
687 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
688 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
689 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
690 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
691 self.menuActs["MonospacedFont"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
692 self.trUtf8("Use Monospaced Font"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
693 self.handleMonospacedEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
694 self.menuActs["MonospacedFont"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
695 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
696 self.menuActs["AutosaveEnable"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
697 self.trUtf8("Autosave enabled"), self.__autosaveEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
698 self.menuActs["AutosaveEnable"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
699 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
700 self.menuActs["TypingAidsEnabled"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
701 self.trUtf8("Typing aids enabled"), self.__toggleTypingAids)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
702 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
703 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
704 self.completer is not None)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
705 self.menuActs["TypingAidsEnabled"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
706 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
707 self.menuActs["AutoCompletionEnable"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
708 self.trUtf8("Autocompletion enabled"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
709 self.__toggleAutoCompletionEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
710 self.menuActs["AutoCompletionEnable"].setCheckable(True)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
711 self.menuActs["AutoCompletionEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
712 self.autoCompletionThreshold() != -1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
713 if not self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
714 self.menu.addMenu(self.autocompletionMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
715 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
716 if self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
717 self.menu.addMenu(self.resourcesMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
718 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
719 self.menuActs["Check"] = self.menu.addMenu(self.checksMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
720 self.menu.addSeparator()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
721 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
722 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
723 self.menuActs["Diagrams"] = self.menu.addMenu(self.graphicsMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
724 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
725 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
726 UI.PixmapCache.getIcon("documentNewView.png"),
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
727 self.trUtf8('New Document View'), self.__newView)
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
728 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
729 UI.PixmapCache.getIcon("splitVertical.png"),
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
730 self.trUtf8('New Document View (with new split)'),
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
731 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
732 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
733 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
734 UI.PixmapCache.getIcon("close.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
735 self.trUtf8('Close'), self.__contextClose)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
736 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
737 self.menuActs["Save"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
738 UI.PixmapCache.getIcon("fileSave.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
739 self.trUtf8('Save'), self.__contextSave)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
740 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
741 UI.PixmapCache.getIcon("fileSaveAs.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
742 self.trUtf8('Save As...'), self.__contextSaveAs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
743 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
744 self.menu.addMenu(self.exportersMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
745 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
746 self.menuActs["OpenRejections"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
747 self.trUtf8("Open 'rejection' file"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
748 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
749 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
750 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
751 UI.PixmapCache.getIcon("printPreview.png"),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
752 self.trUtf8("Print Preview"), self.printPreviewFile)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
753 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
754 UI.PixmapCache.getIcon("print.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
755 self.trUtf8('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
756 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
757 self.menuActs["OpenRejections"] = None
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
758
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
759 self.menu.aboutToShow.connect(self.__showContextMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
760
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
761 self.spellingMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
762 self.__menus["Spelling"] = self.spellingMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
763
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
764 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
765 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
766 self.__contextMenuSpellingTriggered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
767
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
768 def __initContextMenuAutocompletion(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
769 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
770 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
771
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
772 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
773 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
774 menu = QMenu(self.trUtf8('Autocomplete'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
775
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
776 self.menuActs["acDynamic"] = menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
777 self.trUtf8('dynamic'), self.autoComplete)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
778 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
779 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
780 self.trUtf8('from Document'), self.autoCompleteFromDocument)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
781 self.menuActs["acAPI"] = menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
782 self.trUtf8('from APIs'), self.autoCompleteFromAPIs)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
783 self.menuActs["acAPIDocument"] = menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
784 self.trUtf8('from Document and APIs'), self.autoCompleteFromAll)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
785 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
786 self.menuActs["calltip"] = menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
787 self.trUtf8('Calltip'), self.callTip)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
788
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
789 menu.aboutToShow.connect(self.__showContextMenuAutocompletion)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
790
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
791 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
792
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
793 def __initContextMenuChecks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
794 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
795 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
796
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
797 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
798 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
799 menu = QMenu(self.trUtf8('Check'))
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
800 menu.aboutToShow.connect(self.__showContextMenuChecks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
801 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
802
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
803 def __initContextMenuShow(self):
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 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
806
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
807 @return reference to the generated menu (QMenu)
92
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 menu = QMenu(self.trUtf8('Show'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
810
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
811 menu.addAction(self.trUtf8('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
812 self.coverageMenuAct = menu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
813 self.trUtf8('Code coverage...'), self.__showCodeCoverage)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
814 self.coverageShowAnnotationMenuAct = menu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
815 self.trUtf8('Show code coverage annotations'),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
816 self.codeCoverageShowAnnotations)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
817 self.coverageHideAnnotationMenuAct = menu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
818 self.trUtf8('Hide code coverage annotations'),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
819 self.__codeCoverageHideAnnotations)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
820 self.profileMenuAct = menu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
821 self.trUtf8('Profile data...'), self.__showProfileData)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
822
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
823 menu.aboutToShow.connect(self.__showContextMenuShow)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
824
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
825 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
826
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
827 def __initContextMenuGraphics(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 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
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 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
833 menu = QMenu(self.trUtf8('Diagrams'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
834
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
835 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
836 self.trUtf8('Class Diagram...'), self.__showClassDiagram)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
837 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
838 self.trUtf8('Package Diagram...'), self.__showPackageDiagram)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
839 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
840 self.trUtf8('Imports Diagram...'), self.__showImportsDiagram)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
841 self.applicationDiagramMenuAct = menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
842 self.trUtf8('Application Diagram...'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
843 self.__showApplicationDiagram)
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
844 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
845 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
846 UI.PixmapCache.getIcon("open.png"),
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
847 self.trUtf8("Load Diagram..."), self.__loadDiagram)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
848
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
849 menu.aboutToShow.connect(self.__showContextMenuGraphics)
92
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 return menu
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 def __initContextMenuLanguages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
854 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
855 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
856
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
857 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
858 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
859 menu = QMenu(self.trUtf8("Languages"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
860
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
861 self.languagesActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
862 self.noLanguageAct = menu.addAction(self.trUtf8("No Language"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
863 self.noLanguageAct.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
864 self.noLanguageAct.setData("None")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
865 self.languagesActGrp.addAction(self.noLanguageAct)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
866 menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
867
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
868 from . import Lexers
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
869 self.supportedLanguages = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
870 supportedLanguages = Lexers.getSupportedLanguages()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
871 languages = sorted(list(supportedLanguages.keys()))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
872 for language in languages:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
873 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
874 self.supportedLanguages[language] = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
875 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
876 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
877 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
878 self.supportedLanguages[language][0])
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
879 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
880 act.setData(language)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
881 self.supportedLanguages[language].append(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
882 self.languagesActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
883
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
884 menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
885 self.pygmentsAct = menu.addAction(self.trUtf8("Guessed"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
886 self.pygmentsAct.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
887 self.pygmentsAct.setData("Guessed")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
888 self.languagesActGrp.addAction(self.pygmentsAct)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
889 self.pygmentsSelAct = menu.addAction(self.trUtf8("Alternatives"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
890 self.pygmentsSelAct.setData("Alternatives")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
891
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
892 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
893 menu.aboutToShow.connect(self.__showContextMenuLanguages)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
894
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
895 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
896
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
897 def __initContextMenuEncodings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
898 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
899 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
900
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
901 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
902 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
903 self.supportedEncodings = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
904
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
905 menu = QMenu(self.trUtf8("Encodings"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
906
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
907 self.encodingsActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
908
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
909 for encoding in sorted(Utilities.supportedCodecs):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
910 act = menu.addAction(encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
911 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
912 act.setData(encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
913 self.supportedEncodings[encoding] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
914 self.encodingsActGrp.addAction(act)
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.__encodingsMenuTriggered)
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.__showContextMenuEncodings)
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 __initContextMenuEol(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 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
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.supportedEols = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
928
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
929 menu = QMenu(self.trUtf8("End-of-Line Type"))
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.eolActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
932
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
933 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"),
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
934 self.trUtf8("Unix"))
92
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('\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
937 self.supportedEols['\n'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
938 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
939
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
940 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"),
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
941 self.trUtf8("Windows"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
942 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
943 act.setData('\r\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
944 self.supportedEols['\r\n'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
945 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
946
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
947 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"),
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
948 self.trUtf8("Macintosh"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
949 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
950 act.setData('\r')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
951 self.supportedEols['\r'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
952 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
953
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
954 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
955 menu.aboutToShow.connect(self.__showContextMenuEol)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
956
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
957 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
958
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
959 def __initContextMenuExporters(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
960 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
961 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
962
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
963 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
964 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
965 menu = QMenu(self.trUtf8("Export as"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
966
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
967 from . import Exporters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
968 supportedExporters = Exporters.getSupportedFormats()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
969 exporters = sorted(list(supportedExporters.keys()))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
970 for exporter in exporters:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
971 act = menu.addAction(supportedExporters[exporter])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
972 act.setData(exporter)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
973
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
974 menu.triggered.connect(self.__exportMenuTriggered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
975
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
976 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
977
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
978 def __initContextMenuMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
979 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
980 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
981 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
982 self.marginMenuActs = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
983
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
984 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
985 self.__initContextMenuUnifiedMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
986 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
987 self.__initContextMenuSeparateMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
988
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
989 def __initContextMenuSeparateMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
990 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
991 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
992 margins.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
993 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
994 # bookmark margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
995 self.bmMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
996
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
997 self.bmMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
998 self.trUtf8('Toggle bookmark'), self.menuToggleBookmark)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
999 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1000 self.trUtf8('Next bookmark'), self.nextBookmark)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1001 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1002 self.trUtf8('Previous bookmark'), self.previousBookmark)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1003 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1004 self.trUtf8('Clear all bookmarks'), self.clearBookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1005
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1006 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1007
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1008 # breakpoint margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1009 self.bpMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1010
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1011 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1012 self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1013 self.marginMenuActs["TempBreakpoint"] = self.bpMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1014 self.trUtf8('Toggle temporary breakpoint'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1015 self.__menuToggleTemporaryBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1016 self.marginMenuActs["EditBreakpoint"] = self.bpMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1017 self.trUtf8('Edit breakpoint...'), self.menuEditBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1018 self.marginMenuActs["EnableBreakpoint"] = self.bpMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1019 self.trUtf8('Enable breakpoint'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1020 self.__menuToggleBreakpointEnabled)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1021 self.marginMenuActs["NextBreakpoint"] = self.bpMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1022 self.trUtf8('Next breakpoint'), self.menuNextBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1023 self.marginMenuActs["PreviousBreakpoint"] = \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1024 self.bpMarginMenu.addAction(
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1025 self.trUtf8('Previous breakpoint'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1026 self.menuPreviousBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1027 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1028 self.trUtf8('Clear all breakpoints'), self.__menuClearBreakpoints)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1029
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1030 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1031
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1032 # indicator margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1033 self.indicMarginMenu = QMenu()
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 self.marginMenuActs["GotoSyntaxError"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1036 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1037 self.trUtf8('Goto syntax error'), self.gotoSyntaxError)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1038 self.marginMenuActs["ShowSyntaxError"] = \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1039 self.indicMarginMenu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1040 self.trUtf8('Show syntax error message'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1041 self.__showSyntaxError)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1042 self.marginMenuActs["ClearSyntaxError"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1043 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1044 self.trUtf8('Clear syntax error'), self.clearSyntaxError)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1045 self.indicMarginMenu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1046 self.marginMenuActs["NextWarningMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1047 self.indicMarginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1048 self.trUtf8("Next warning"), self.nextWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1049 self.marginMenuActs["PreviousWarningMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1050 self.indicMarginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1051 self.trUtf8("Previous warning"), self.previousWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1052 self.marginMenuActs["ShowWarning"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1053 self.indicMarginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1054 self.trUtf8('Show warning message'), self.__showWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1055 self.marginMenuActs["ClearWarnings"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1056 self.indicMarginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1057 self.trUtf8('Clear warnings'), self.clearWarnings)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1058 self.indicMarginMenu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1059 self.marginMenuActs["NextCoverageMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1060 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1061 self.trUtf8('Next uncovered line'), self.nextUncovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1062 self.marginMenuActs["PreviousCoverageMarker"] = \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1063 self.indicMarginMenu.addAction(
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1064 self.trUtf8('Previous uncovered line'), self.previousUncovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1065 self.indicMarginMenu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1066 self.marginMenuActs["NextTaskMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1067 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1068 self.trUtf8('Next task'), self.nextTask)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1069 self.marginMenuActs["PreviousTaskMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1070 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1071 self.trUtf8('Previous task'), self.previousTask)
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
1072 self.indicMarginMenu.addSeparator()
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
1073 self.marginMenuActs["NextChangeMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1074 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1075 self.trUtf8('Next change'), self.nextChange)
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
1076 self.marginMenuActs["PreviousChangeMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1077 self.indicMarginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1078 self.trUtf8('Previous change'), self.previousChange)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1079
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1080 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1081
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1082 def __initContextMenuUnifiedMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1083 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1084 Private method used to setup the context menu for the unified margins.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1085 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1086 self.marginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1087
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1088 self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1089 self.trUtf8('Toggle bookmark'), self.menuToggleBookmark)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1090 self.marginMenuActs["NextBookmark"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1091 self.trUtf8('Next bookmark'), self.nextBookmark)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1092 self.marginMenuActs["PreviousBookmark"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1093 self.trUtf8('Previous bookmark'), self.previousBookmark)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1094 self.marginMenuActs["ClearBookmark"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1095 self.trUtf8('Clear all bookmarks'), self.clearBookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1096 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1097 self.marginMenuActs["GotoSyntaxError"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1098 self.trUtf8('Goto syntax error'), self.gotoSyntaxError)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1099 self.marginMenuActs["ShowSyntaxError"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1100 self.trUtf8('Show syntax error message'), self.__showSyntaxError)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1101 self.marginMenuActs["ClearSyntaxError"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1102 self.trUtf8('Clear syntax error'), self.clearSyntaxError)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1103 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1104 self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1105 self.trUtf8("Next warning"), self.nextWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1106 self.marginMenuActs["PreviousWarningMarker"] = \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1107 self.marginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1108 self.trUtf8("Previous warning"), self.previousWarning)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1109 self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1110 self.trUtf8('Show warning message'), self.__showWarning)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1111 self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction(
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
1112 self.trUtf8('Clear warnings'), self.clearWarnings)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1113 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1114 self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1115 self.trUtf8('Toggle breakpoint'), self.menuToggleBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1116 self.marginMenuActs["TempBreakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1117 self.trUtf8('Toggle temporary breakpoint'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1118 self.__menuToggleTemporaryBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1119 self.marginMenuActs["EditBreakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1120 self.trUtf8('Edit breakpoint...'), self.menuEditBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1121 self.marginMenuActs["EnableBreakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1122 self.trUtf8('Enable breakpoint'),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1123 self.__menuToggleBreakpointEnabled)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1124 self.marginMenuActs["NextBreakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1125 self.trUtf8('Next breakpoint'), self.menuNextBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1126 self.marginMenuActs["PreviousBreakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1127 self.trUtf8('Previous breakpoint'), self.menuPreviousBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1128 self.marginMenuActs["ClearBreakpoint"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1129 self.trUtf8('Clear all breakpoints'), self.__menuClearBreakpoints)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1130 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1131 self.marginMenuActs["NextCoverageMarker"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1132 self.trUtf8('Next uncovered line'), self.nextUncovered)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1133 self.marginMenuActs["PreviousCoverageMarker"] = \
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1134 self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1135 self.trUtf8('Previous uncovered line'), self.previousUncovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1136 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1137 self.marginMenuActs["NextTaskMarker"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1138 self.trUtf8('Next task'), self.nextTask)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1139 self.marginMenuActs["PreviousTaskMarker"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1140 self.trUtf8('Previous task'), self.previousTask)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1141 self.marginMenu.addSeparator()
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1142 self.marginMenuActs["NextChangeMarker"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1143 self.trUtf8('Next change'), self.nextChange)
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
1144 self.marginMenuActs["PreviousChangeMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1145 self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1146 self.trUtf8('Previous change'), self.previousChange)
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
1147 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1148 self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1149 self.trUtf8('LMB toggles bookmarks'), self.__lmBbookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1150 self.marginMenuActs["LMBbookmarks"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1151 self.marginMenuActs["LMBbookmarks"].setChecked(False)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1152 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1153 self.trUtf8('LMB toggles breakpoints'), self.__lmBbreakpoints)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1154 self.marginMenuActs["LMBbreakpoints"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1155 self.marginMenuActs["LMBbreakpoints"].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1156
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1157 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1158
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1159 def __exportMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1160 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1161 Private method to handle the selection of an export format.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1162
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1163 @param act reference to the action that was triggered (QAction)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1164 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1165 exporterFormat = act.data()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1166 self.exportFile(exporterFormat)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1167
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1168 def exportFile(self, exporterFormat):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1169 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1170 Public method to export the file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1171
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1172 @param exporterFormat format the file should be exported into (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1173 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1174 if exporterFormat:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1175 from . import Exporters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1176 exporter = Exporters.getExporter(exporterFormat, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1177 if exporter:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1178 exporter.exportSource()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1179 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1180 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1181 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1182 self.trUtf8("Export source"),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1183 self.trUtf8(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1184 """<p>No exporter available for the """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
1185 """export format <b>{0}</b>. Aborting...</p>""")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1186 .format(exporterFormat))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1187 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1188 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1189 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1190 self.trUtf8("Export source"),
535
4b00d7336e19 Streamlined the use of QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 520
diff changeset
1191 self.trUtf8("""No export format given. Aborting..."""))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1192
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1193 def __showContextMenuLanguages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1194 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1195 Private slot handling the aboutToShow signal of the languages context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1196 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1197 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1198 if self.apiLanguage.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1199 self.pygmentsSelAct.setText(
812
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1200 self.trUtf8("Alternatives ({0})").format(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1201 self.getLanguage(normalized=False)))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1202 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1203 self.pygmentsSelAct.setText(self.trUtf8("Alternatives"))
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1204 self.showMenu.emit("Languages", self.languagesMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1205
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1206 def __selectPygmentsLexer(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1207 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1208 Private method to select a specific pygments lexer.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1209
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1210 @return name of the selected pygments lexer (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1211 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1212 from pygments.lexers import get_all_lexers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1213 lexerList = sorted([l[0] for l in get_all_lexers()])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1214 try:
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1215 lexerSel = lexerList.index(
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1216 self.getLanguage(normalized=False, forPygments=True))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1217 except ValueError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1218 lexerSel = 0
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
1219 lexerName, ok = QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1220 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1221 self.trUtf8("Pygments Lexer"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1222 self.trUtf8("Select the Pygments lexer to apply."),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1223 lexerList,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1224 lexerSel,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1225 False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1226 if ok and lexerName:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1227 return lexerName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1228 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1229 return ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1230
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1231 def __languageMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1232 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1233 Private method to handle the selection of a lexer language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1234
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1235 @param act reference to the action that was triggered (QAction)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1236 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1237 if act == self.noLanguageAct:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1238 self.__resetLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1239 elif act == self.pygmentsAct:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1240 self.setLanguage("dummy.pygments")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1241 elif act == self.pygmentsSelAct:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1242 language = self.__selectPygmentsLexer()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1243 if language:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1244 self.setLanguage("dummy.pygments", pyname=language)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1245 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1246 language = act.data()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1247 if language:
2219
031fae60d778 Fixed an issue in the editor causing switching the language between Python2 and Python3 to only work every second time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2217
diff changeset
1248 self.filetype = language
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1249 self.setLanguage(self.supportedLanguages[language][1])
802
e8882d16384c Added a pyflakes checker function for Python 2 files and made some additional Python 2 related changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 795
diff changeset
1250 self.__autoSyntaxCheck()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1251
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1252 def __languageChanged(self, language, propagate=True):
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1253 """
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1254 Private slot handling a change of a connected editor's language.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1255
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1256 @param language language to be set (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1257 @keyparam propagate flag indicating to propagate the change (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1258 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1259 if language == '':
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1260 self.__resetLanguage(propagate=propagate)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1261 elif language == "Guessed":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1262 self.setLanguage("dummy.pygments")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1263 elif language.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1264 pyname = language.split("|", 1)[1]
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1265 self.setLanguage("dummy.pygments", pyname=pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1266 else:
2219
031fae60d778 Fixed an issue in the editor causing switching the language between Python2 and Python3 to only work every second time.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2217
diff changeset
1267 self.filetype = language
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1268 self.setLanguage(self.supportedLanguages[language][1],
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1269 propagate=propagate)
802
e8882d16384c Added a pyflakes checker function for Python 2 files and made some additional Python 2 related changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 795
diff changeset
1270 self.__autoSyntaxCheck()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1271
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1272 def __resetLanguage(self, propagate=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1273 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1274 Private method used to reset the language selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1275
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1276 @keyparam propagate flag indicating to propagate the change (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1277 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1278 if self.lexer_ is not None and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1279 (self.lexer_.lexer() == "container" or self.lexer_.lexer() is None):
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1280 self.SCN_STYLENEEDED.disconnect(self.__styleNeeded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1281
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1282 self.apiLanguage = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1283 self.lexer_ = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1284 self.__lexerReset = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1285 self.setLexer()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1286 if self.completer is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1287 self.completer.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1288 self.completer = None
3059
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1289 useMonospaced = self.useMonospaced
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1290 self.__setTextDisplay()
3059
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1291 self.setMonospaced(useMonospaced)
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1292 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1293
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1294 if not self.inLanguageChanged and propagate:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1295 self.inLanguageChanged = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1296 self.languageChanged.emit(self.apiLanguage)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1297 self.inLanguageChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1298
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1299 def setLanguage(self, filename, initTextDisplay=True, propagate=True,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1300 pyname=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1301 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1302 Public method to set a lexer language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1303
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1304 @param filename filename used to determine the associated lexer
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1305 language (string)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1306 @param initTextDisplay flag indicating an initialization of the text
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1307 display is required as well (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1308 @keyparam propagate flag indicating to propagate the change (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1309 @keyparam pyname name of the pygments lexer to use (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1310 """
3059
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1311 self.menuActs["MonospacedFont"].setChecked(False)
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1312
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1313 self.__lexerReset = False
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1314 self.__bindLexer(filename, pyname=pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1315 self.__bindCompleter(filename)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1316 self.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1317 self.__checkLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1318
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1319 # set the text display
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1320 if initTextDisplay:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1321 self.__setTextDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1322
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1323 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1324 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1325 self.__setCallTips()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1326
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1327 if not self.inLanguageChanged and propagate:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1328 self.inLanguageChanged = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1329 self.languageChanged.emit(self.apiLanguage)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1330 self.inLanguageChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1331
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1332 def __checkLanguage(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1333 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1334 Private method to check the selected language of the language submenu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1335 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1336 if self.apiLanguage == "":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1337 self.noLanguageAct.setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1338 elif self.apiLanguage == "Guessed":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1339 self.pygmentsAct.setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1340 elif self.apiLanguage.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1341 act = self.languagesActGrp.checkedAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1342 if act:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1343 act.setChecked(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1344 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1345 self.supportedLanguages[self.apiLanguage][2].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1346
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1347 def projectLexerAssociationsChanged(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1348 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1349 Public slot to handle changes of the project lexer associations.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1350 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1351 self.setLanguage(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1352
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1353 def __showContextMenuEncodings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1354 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1355 Private slot handling the aboutToShow signal of the encodings context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1356 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1357 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1358 self.showMenu.emit("Encodings", self.encodingsMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1359
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1360 def __encodingsMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1361 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1362 Private method to handle the selection of an encoding.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1363
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1364 @param act reference to the action that was triggered (QAction)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1365 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1366 encoding = act.data()
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
1367 self.__encodingChanged("{0}-selected".format(encoding))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1368
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1369 def __checkEncoding(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1370 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1371 Private method to check the selected encoding of the encodings submenu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1372 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1373 try:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1374 self.supportedEncodings[self.__normalizedEncoding()]\
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1375 .setChecked(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1376 except (AttributeError, KeyError):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1377 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1378
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1379 def __encodingChanged(self, encoding, propagate=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1380 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1381 Private slot to handle a change of the encoding.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1382
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1383 @param encoding changed encoding (string)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1384 @keyparam propagate flag indicating to propagate the change (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1385 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1386 self.encoding = encoding
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1387 self.__checkEncoding()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1388
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1389 if not self.inEncodingChanged and propagate:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1390 self.inEncodingChanged = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1391 self.encodingChanged.emit(self.encoding)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1392 self.inEncodingChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1393
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1394 def __normalizedEncoding(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1395 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1396 Private method to calculate the normalized encoding string.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1397
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1398 @return normalized encoding (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1399 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1400 return self.encoding.replace("-default", "")\
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1401 .replace("-guessed", "")\
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1402 .replace("-selected", "")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1403
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1404 def __showContextMenuEol(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1405 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1406 Private slot handling the aboutToShow signal of the eol context menu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1407 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1408 self.showMenu.emit("Eol", self.eolMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1409
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1410 def __eolMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1411 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1412 Private method to handle the selection of an eol type.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1413
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1414 @param act reference to the action that was triggered (QAction)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1415 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1416 eol = act.data()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1417 self.setEolModeByEolString(eol)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1418 self.convertEols(self.eolMode())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1419
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1420 def __checkEol(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1421 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1422 Private method to check the selected eol type of the eol submenu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1423 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1424 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1425 self.supportedEols[self.getLineSeparator()].setChecked(True)
875
606815a46bc0 Fixed a strange issue in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 832
diff changeset
1426 except (AttributeError, TypeError):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1427 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1428
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1429 def __eolChanged(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1430 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1431 Private slot to handle a change of the eol mode.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1432 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1433 self.__checkEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1434
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1435 if not self.inEolChanged:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1436 self.inEolChanged = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1437 eol = self.getLineSeparator()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1438 self.eolChanged.emit(eol)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1439 self.inEolChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1440
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1441 def __bindLexer(self, filename, pyname=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1442 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1443 Private slot to set the correct lexer depending on language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1444
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1445 @param filename filename used to determine the associated lexer
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1446 language (string)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1447 @keyparam pyname name of the pygments lexer to use (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1448 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1449 if self.lexer_ is not None and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1450 (self.lexer_.lexer() == "container" or self.lexer_.lexer() is None):
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1451 self.SCN_STYLENEEDED.disconnect(self.__styleNeeded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1452
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1453 language = ""
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1454 basename = os.path.basename(filename)
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
1455 if self.project.isOpen() and self.project.isProjectFile(filename):
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1456 language = self.project.getEditorLexerAssoc(basename)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1457 if not language:
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1458 language = Preferences.getEditorLexerAssoc(basename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1459 if not language:
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1460 bindName = self.__bindName(self.text(0))
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1461 language = Preferences.getEditorLexerAssoc(bindName)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1462 if language == "Python":
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1463 # correction for Python
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1464 pyVer = Utilities.determinePythonVersion(
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1465 filename, self.text(0), self)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1466 language = "Python{0}".format(pyVer)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1467 if language in ['Python2', 'Python3']:
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1468 self.filetype = language
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1469 else:
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1470 self.filetype = ""
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1471
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1472 if language.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1473 pyname = language.split("|", 1)[1]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1474 language = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1475
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1476 from . import Lexers
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1477 self.lexer_ = Lexers.getLexer(language, self, pyname=pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1478 if self.lexer_ is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1479 self.setLexer()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1480 self.apiLanguage = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1481 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1482
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1483 if pyname:
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
1484 self.apiLanguage = "Pygments|{0}".format(pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1485 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1486 self.apiLanguage = self.lexer_.language()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1487 if self.apiLanguage == "POV":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1488 self.apiLanguage = "Povray"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1489 self.setLexer(self.lexer_)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1490 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1491 if self.lexer_.lexer() == "container" or self.lexer_.lexer() is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1492 self.setStyleBits(self.lexer_.styleBitsNeeded())
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1493 self.SCN_STYLENEEDED.connect(self.__styleNeeded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1494
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1495 # get the font for style 0 and set it as the default font
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
1496 key = 'Scintilla/{0}/style0/font'.format(self.lexer_.language())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1497 fdesc = Preferences.Prefs.settings.value(key)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1498 if fdesc is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1499 font = QFont(fdesc[0], int(fdesc[1]))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1500 self.lexer_.setDefaultFont(font)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1501 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1502
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1503 # now set the lexer properties
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1504 self.lexer_.initProperties()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1505
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1506 # initialize the lexer APIs settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1507 api = self.vm.getAPIsManager().getAPIs(self.apiLanguage)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1508 if api is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1509 self.lexer_.setAPIs(api.getQsciAPIs())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1510 self.acAPI = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1511 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1512 self.acAPI = False
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1513 self.autoCompletionAPIsAvailable.emit(self.acAPI)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1514
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
1515 self.__setAnnotationStyles()
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
1516
1566
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
1517 self.lexer_.setDefaultColor(self.lexer_.color(0))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
1518 self.lexer_.setDefaultPaper(self.lexer_.paper(0))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
1519
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1520 def __styleNeeded(self, position):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1521 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1522 Private slot to handle the need for more styling.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1523
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1524 @param position end position, that needs styling (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1525 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1526 self.lexer_.styleText(self.getEndStyled(), position)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1527
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1528 def getLexer(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1529 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1530 Public method to retrieve a reference to the lexer object.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1531
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1532 @return the lexer object (Lexer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1533 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1534 return self.lexer_
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1535
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1536 def getLanguage(self, normalized=True, forPygments=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1537 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1538 Public method to retrieve the language of the editor.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1539
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1540 @keyparam normalized flag indicating to normalize some Pygments
812
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1541 lexer names (boolean)
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1542 @keyparam forPygments flag indicating to normalize some lexer
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1543 names for Pygments (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1544 @return language of the editor (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1545 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1546 if self.apiLanguage == "Guessed" or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1547 self.apiLanguage.startswith("Pygments|"):
812
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1548 lang = self.lexer_.name()
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1549 if normalized:
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1550 # adjust some Pygments lexer names
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1551 if lang == "Python":
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1552 lang = "Python2"
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1553 elif lang == "Python 3":
240adf04a50e Fixed an issue where selecting a Pygments Python lexer disabled auto completion.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 811
diff changeset
1554 lang = "Python3"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1555 else:
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1556 lang = self.apiLanguage
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1557 if forPygments:
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1558 # adjust some names to Pygments lexer names
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1559 if lang == "Python2":
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1560 lang = "Python"
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1561 elif lang == "Python3":
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1562 lang = "Python 3"
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1563 return lang
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1564
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1565 def __bindCompleter(self, filename):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1566 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1567 Private slot to set the correct typing completer depending on language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1568
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1569 @param filename filename used to determine the associated typing
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1570 completer language (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1571 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1572 if self.completer is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1573 self.completer.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1574 self.completer = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1575
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1576 filename = os.path.basename(filename)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1577 apiLanguage = Preferences.getEditorLexerAssoc(filename)
811
2ed99614dbf4 Fixed an issue with the editor not activating the correct typing completer in some situations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 802
diff changeset
1578 if apiLanguage == "":
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1579 pyVer = self.getPyVersion()
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1580 if pyVer:
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1581 apiLanguage = "Python{0}".format(pyVer)
811
2ed99614dbf4 Fixed an issue with the editor not activating the correct typing completer in some situations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 802
diff changeset
1582 elif self.isRubyFile():
2ed99614dbf4 Fixed an issue with the editor not activating the correct typing completer in some situations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 802
diff changeset
1583 apiLanguage = "Ruby"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1584
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1585 from . import TypingCompleters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1586 self.completer = TypingCompleters.getCompleter(apiLanguage, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1587
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1588 def getCompleter(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1589 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1590 Public method to retrieve a reference to the completer object.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1591
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1592 @return the completer object (CompleterBase)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1593 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1594 return self.completer
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1595
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1596 def __modificationChanged(self, m):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1597 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1598 Private slot to handle the modificationChanged signal.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1599
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1600 It emits the signal modificationStatusChanged with parameters
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1601 m and self.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1602
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1603 @param m modification status
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1604 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1605 if not m and self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1606 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1607 if Preferences.getEditor("AutoCheckSyntax"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1608 self.clearSyntaxError()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1609 self.modificationStatusChanged.emit(m, self)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1610 self.undoAvailable.emit(self.isUndoAvailable())
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1611 self.redoAvailable.emit(self.isRedoAvailable())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1612
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1613 def __cursorPositionChanged(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1614 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1615 Private slot to handle the cursorPositionChanged signal.
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1616
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1617 It emits the signal cursorChanged with parameters fileName,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1618 line and pos.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1619
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1620 @param line line number of the cursor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1621 @param index position in line of the cursor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1622 """
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
1623 self.cursorChanged.emit(self.fileName, line + 1, index)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1624
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1625 if Preferences.getEditor("MarkOccurrencesEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1626 self.__markOccurrencesTimer.stop()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1627 self.__markOccurrencesTimer.start()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1628
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
1629 if self.lastLine != line:
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
1630 self.cursorLineChanged.emit(line)
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
1631
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1632 if self.spell is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1633 # do spell checking
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1634 doSpelling = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1635 if self.lastLine == line:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1636 start, end = self.getWordBoundaries(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1637 line, index, useWordChars=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1638 if start <= self.lastIndex and self.lastIndex <= end:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1639 doSpelling = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1640 if doSpelling:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1641 pos = self.positionFromLineIndex(self.lastLine, self.lastIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1642 self.spell.checkWord(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1643
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1644 self.lastLine = line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1645 self.lastIndex = index
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1646
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1647 def __modificationReadOnly(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1648 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1649 Private slot to handle the modificationAttempted signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1650 """
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1651 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1652 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1653 self.trUtf8("Modification of Read Only file"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1654 self.trUtf8("""You are attempting to change a read only file. """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1655 """Please save to a different file first."""))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1656
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1657 def setNoName(self, noName):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1658 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1659 Public method to set the display string for an unnamed editor.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1660
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1661 @param noName display string for this unnamed editor (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1662 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1663 self.noName = noName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1664
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1665 def getNoName(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1666 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1667 Public method to get the display string for an unnamed editor.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1668
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1669 @return display string for this unnamed editor (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1670 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1671 return self.noName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1672
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1673 def getFileName(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1674 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1675 Public method to return the name of the file being displayed.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1676
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1677 @return filename of the displayed file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1678 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1679 return self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1680
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1681 def getFileType(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1682 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1683 Public method to return the type of the file being displayed.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1684
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1685 @return type of the displayed file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1686 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1687 return self.filetype
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1688
795
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1689 def getFileTypeByFlag(self):
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1690 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1691 Public method to return the type of the file, if it was set by an
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1692 eflag: marker.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1693
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1694 @return type of the displayed file, if set by an eflag: marker or an
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1695 empty string (string)
795
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1696 """
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1697 if self.filetypeByFlag:
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1698 return self.filetype
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1699 else:
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1700 return ""
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1701
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
1702 def determineFileType(self):
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
1703 """
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
1704 Public method to determine the file type using various tests.
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
1705
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
1706 @return type of the displayed file or an empty string (string)
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
1707 """
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
1708 ftype = self.filetype
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
1709 if not ftype:
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1710 pyVer = self.getPyVersion()
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1711 if pyVer:
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1712 ftype = "Python{0}".format(pyVer)
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
1713 elif self.isRubyFile():
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
1714 ftype = "Ruby"
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
1715 else:
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
1716 ftype = ""
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
1717
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
1718 return ftype
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
1719
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1720 def getEncoding(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1721 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1722 Public method to return the current encoding.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1723
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1724 @return current encoding (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1725 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1726 return self.encoding
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1727
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1728 def getPyVersion(self):
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1729 """
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1730 Public methode to return the Python main version (2 or 3) or 0 if it's
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1731 not a Python file at all.
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1732
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1733 @return Python version (2 or 3) or 0 if it's not a Python file (int)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1734 """
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1735 return Utilities.determinePythonVersion(
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1736 self.fileName, self.text(0), self)
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1737
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
1738 def isPy2File(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1739 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1740 Public method to return a flag indicating a Python file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1741
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1742 @return flag indicating a Python file (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1743 """
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1744 return self.getPyVersion() == 2
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1745
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1746 def isPy3File(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1747 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1748 Public method to return a flag indicating a Python3 file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1749
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1750 @return flag indicating a Python3 file (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1751 """
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
1752 return self.getPyVersion() == 3
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1753
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1754 def isRubyFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1755 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1756 Public method to return a flag indicating a Ruby file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1757
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1758 @return flag indicating a Ruby file (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1759 """
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
1760 if self.filetype == "Ruby":
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
1761 return True
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
1762
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
1763 if self.filetype == "":
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
1764 line0 = self.text(0)
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
1765 if line0.startswith("#!") and \
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
1766 "ruby" in line0:
1758
e18f96b1714b A few optimizations and a fix for a bug, that caused incorrect display of breakpoints in the editor margin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1754
diff changeset
1767 self.filetype = "Ruby"
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
1768 return True
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
1769
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
1770 if self.fileName is not None and \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1771 os.path.splitext(self.fileName)[1] in \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1772 self.dbs.getExtensions('Ruby'):
1758
e18f96b1714b A few optimizations and a fix for a bug, that caused incorrect display of breakpoints in the editor margin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1754
diff changeset
1773 self.filetype = "Ruby"
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
1774 return True
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
1775
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
1776 return False
1196
77da430b4080 Added an action to preview the file in the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1169
diff changeset
1777
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1778 def highlightVisible(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1779 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1780 Public method to make sure that the highlight is visible.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1781 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1782 if self.lastHighlight is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1783 lineno = self.markerLine(self.lastHighlight)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1784 self.ensureVisible(lineno + 1)
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1785
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1786 def highlight(self, line=None, error=False, syntaxError=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1787 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1788 Public method to highlight [or de-highlight] a particular line.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1789
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1790 @param line line number to highlight (integer)
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1791 @param error flag indicating whether the error highlight should be
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1792 used (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1793 @param syntaxError flag indicating a syntax error (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1794 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1795 if line is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1796 self.lastHighlight = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1797 if self.lastErrorMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1798 self.markerDeleteHandle(self.lastErrorMarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1799 self.lastErrorMarker = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1800 if self.lastCurrMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1801 self.markerDeleteHandle(self.lastCurrMarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1802 self.lastCurrMarker = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1803 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1804 if error:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1805 if self.lastErrorMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1806 self.markerDeleteHandle(self.lastErrorMarker)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1807 self.lastErrorMarker = self.markerAdd(line - 1, self.errorline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1808 self.lastHighlight = self.lastErrorMarker
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1809 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1810 if self.lastCurrMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1811 self.markerDeleteHandle(self.lastCurrMarker)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1812 self.lastCurrMarker = self.markerAdd(line - 1,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1813 self.currentline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1814 self.lastHighlight = self.lastCurrMarker
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1815 self.setCursorPosition(line - 1, 0)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1816
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1817 def getHighlightPosition(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1818 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1819 Public method to return the position of the highlight bar.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1820
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1821 @return line number of the highlight bar (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1822 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1823 if self.lastHighlight is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1824 return self.markerLine(self.lastHighlight)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1825 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1826 return 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1827
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1828 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1829 ## Breakpoint handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1830 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1831
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1832 def __modified(self, pos, mtype, text, length, linesAdded, line, foldNow,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1833 foldPrev, token, annotationLinesAdded):
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1834 """
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1835 Private method to handle changes of the number of lines.
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1836
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1837 @param pos start position of change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1838 @param mtype flags identifying the change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1839 @param text text that is given to the Undo system (string)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1840 @param length length of the change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1841 @param linesAdded number of added/deleted lines (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1842 @param line line number of a fold level or marker change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1843 @param foldNow new fold level (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1844 @param foldPrev previous fold level (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1845 @param token ???
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1846 @param annotationLinesAdded number of added/deleted annotation lines
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1847 (integer)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1848 """
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1849 if mtype & (self.SC_MOD_INSERTTEXT | self.SC_MOD_DELETETEXT) and \
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1850 linesAdded != 0:
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1851 if self.breaks:
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1852 bps = [] # list of breakpoints
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1853 for handle, (ln, cond, temp, enabled, ignorecount) in \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1854 self.breaks.items():
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1855 line = self.markerLine(handle) + 1
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1856 if ln != line:
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1857 bps.append((ln, line))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1858 self.breaks[handle] = (line, cond, temp, enabled,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1859 ignorecount)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1860 self.inLinesChanged = True
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1861 for ln, line in sorted(bps, reverse=linesAdded > 0):
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1862 index1 = self.breakpointModel.getBreakPointIndex(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1863 self.fileName, ln)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1864 index2 = self.breakpointModel.index(index1.row(), 1)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1865 self.breakpointModel.setData(index2, line)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1866 self.inLinesChanged = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1867
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1868 def __restoreBreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1869 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1870 Private method to restore the breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1871 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1872 for handle in list(self.breaks.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1873 self.markerDeleteHandle(handle)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1874 self.__addBreakPoints(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1875 QModelIndex(), 0, self.breakpointModel.rowCount() - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1876
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1877 def __deleteBreakPoints(self, parentIndex, start, end):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1878 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1879 Private slot to delete breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1880
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1881 @param parentIndex index of parent item (QModelIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1882 @param start start row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1883 @param end end row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1884 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1885 for row in range(start, end + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1886 index = self.breakpointModel.index(row, 0, parentIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1887 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1888 if fn == self.fileName:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1889 self.clearBreakpoint(lineno)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1890
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1891 def __changeBreakPoints(self, startIndex, endIndex):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1892 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1893 Private slot to set changed breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1894
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1895 @param startIndex start index of the breakpoints being changed
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1896 (QModelIndex)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1897 @param endIndex end index of the breakpoints being changed
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1898 (QModelIndex)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1899 """
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1900 if not self.inLinesChanged:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1901 self.__addBreakPoints(QModelIndex(), startIndex.row(),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1902 endIndex.row())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1903
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1904 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1905 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1906 Private slot to handle the dataAboutToBeChanged signal of the
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1907 breakpoint model.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1908
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1909 @param startIndex start index of the rows to be changed (QModelIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1910 @param endIndex end index of the rows to be changed (QModelIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1911 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1912 self.__deleteBreakPoints(QModelIndex(), startIndex.row(),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1913 endIndex.row())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1914
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1915 def __addBreakPoints(self, parentIndex, start, end):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1916 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1917 Private slot to add breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1918
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1919 @param parentIndex index of parent item (QModelIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1920 @param start start row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1921 @param end end row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1922 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1923 for row in range(start, end + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1924 index = self.breakpointModel.index(row, 0, parentIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1925 fn, line, cond, temp, enabled, ignorecount = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1926 self.breakpointModel.getBreakPointByIndex(index)[:6]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1927 if fn == self.fileName:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1928 self.newBreakpointWithProperties(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1929 line, (cond, temp, enabled, ignorecount))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1930
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1931 def clearBreakpoint(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1932 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1933 Public method to clear a breakpoint.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1934
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1935 Note: This doesn't clear the breakpoint in the debugger,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1936 it just deletes it from the editor internal list of breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1937
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1938 @param line linenumber of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1939 """
1758
e18f96b1714b A few optimizations and a fix for a bug, that caused incorrect display of breakpoints in the editor margin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1754
diff changeset
1940 if self.inLinesChanged:
e18f96b1714b A few optimizations and a fix for a bug, that caused incorrect display of breakpoints in the editor margin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1754
diff changeset
1941 return
e18f96b1714b A few optimizations and a fix for a bug, that caused incorrect display of breakpoints in the editor margin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1754
diff changeset
1942
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1943 for handle, (ln, _, _, _, _) in list(self.breaks.items()):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1944 if self.markerLine(handle) == line - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1945 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1946 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1947 # not found, simply ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1948 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1949
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1950 del self.breaks[handle]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1951 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1952
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1953 def newBreakpointWithProperties(self, line, properties):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1954 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1955 Private method to set a new breakpoint and its properties.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1956
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1957 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1958 @param properties properties for the breakpoint (tuple)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1959 (condition, temporary flag, enabled flag, ignore count)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1960 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1961 if not properties[2]:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1962 marker = self.dbreakpoint
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1963 elif properties[0]:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1964 marker = properties[1] and self.tcbreakpoint or self.cbreakpoint
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1965 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1966 marker = properties[1] and self.tbreakpoint or self.breakpoint
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1967
1930
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
1968 if self.markersAtLine(line - 1) & self.breakpointMask == 0:
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
1969 handle = self.markerAdd(line - 1, marker)
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
1970 self.breaks[handle] = (line,) + properties
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
1971 self.breakpointToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1972
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1973 def __toggleBreakpoint(self, line, temporary=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1974 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1975 Private method to toggle a breakpoint.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1976
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1977 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1978 @param temporary flag indicating a temporary breakpoint (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1979 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1980 for handle, (ln, _, _, _, _) in list(self.breaks.items()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1981 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1982 # delete breakpoint or toggle it to the next state
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1983 index = self.breakpointModel.getBreakPointIndex(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1984 self.fileName, line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1985 if Preferences.getDebugger("ThreeStateBreakPoints") and \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1986 not self.breakpointModel.isBreakPointTemporaryByIndex(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1987 index):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1988 self.breakpointModel.deleteBreakPointByIndex(index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1989 self.__addBreakPoint(line, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1990 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1991 self.breakpointModel.deleteBreakPointByIndex(index)
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
1992 self.breakpointToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1993 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1994 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1995 self.__addBreakPoint(line, temporary)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1996
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1997 def __addBreakPoint(self, line, temporary):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1998 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1999 Private method to add a new breakpoint.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2000
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2001 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2002 @param temporary flag indicating a temporary breakpoint (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2003 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2004 if self.fileName and \
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
2005 (self.getPyVersion() or self.isRubyFile()):
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2006 self.breakpointModel.addBreakPoint(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2007 self.fileName, line, ('', temporary, True, 0))
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
2008 self.breakpointToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2009
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2010 def __toggleBreakpointEnabled(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2011 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2012 Private method to toggle a breakpoints enabled status.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2013
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2014 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2015 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2016 for handle, (ln, cond, temp, enabled, ignorecount) in \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2017 self.breaks.items():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2018 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2019 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2020 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2021 # no breakpoint found on that line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2022 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2023
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2024 index = self.breakpointModel.getBreakPointIndex(self.fileName, line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2025 self.breakpointModel.setBreakPointEnabledByIndex(index, not enabled)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2026
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2027 def curLineHasBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2028 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2029 Public method to check for the presence of a breakpoint at the current
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2030 line.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2031
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2032 @return flag indicating the presence of a breakpoint (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2033 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2034 line, _ = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2035 return self.markersAtLine(line) & self.breakpointMask != 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2036
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2037 def hasBreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2038 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2039 Public method to check for the presence of breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2040
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2041 @return flag indicating the presence of breakpoints (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2042 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2043 return len(self.breaks) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2044
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2045 def __menuToggleTemporaryBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2046 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2047 Private slot to handle the 'Toggle temporary breakpoint' context menu
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2048 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2049 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2050 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2051 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2052 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2053 self.__toggleBreakpoint(self.line, 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2054 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2055
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2056 def menuToggleBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2057 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2058 Public slot to handle the 'Toggle breakpoint' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2059 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2060 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2061 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2062 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2063 self.__toggleBreakpoint(self.line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2064 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2065
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2066 def __menuToggleBreakpointEnabled(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2067 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2068 Private slot to handle the 'Enable/Disable breakpoint' context menu
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2069 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2070 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2071 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2072 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2073 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2074 self.__toggleBreakpointEnabled(self.line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2075 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2076
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2077 def menuEditBreakpoint(self, line=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2078 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2079 Public slot to handle the 'Edit breakpoint' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2080
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2081 @param line linenumber of the breakpoint to edit
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2082 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2083 if line is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2084 self.line = line - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2085 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2086 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2087 found = False
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2088 for handle, (ln, cond, temp, enabled, ignorecount) in \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2089 self.breaks.items():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2090 if self.markerLine(handle) == self.line:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2091 found = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2092 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2093
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2094 if found:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2095 index = self.breakpointModel.getBreakPointIndex(self.fileName, ln)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2096 if not index.isValid():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2097 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2098
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2099 from Debugger.EditBreakpointDialog import EditBreakpointDialog
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2100 dlg = EditBreakpointDialog(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2101 (self.fileName, ln),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2102 (cond, temp, enabled, ignorecount),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2103 self.condHistory, self, modal=True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2104 if dlg.exec_() == QDialog.Accepted:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2105 cond, temp, enabled, ignorecount = dlg.getData()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2106 self.breakpointModel.setBreakPointByIndex(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2107 index, self.fileName, ln,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2108 (cond, temp, enabled, ignorecount))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2109
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2110 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2111
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2112 def menuNextBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2113 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2114 Public slot to handle the 'Next breakpoint' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2115 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2116 line, index = self.getCursorPosition()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2117 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2118 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2119 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2120 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2121 bpline = self.markerFindNext(line, self.breakpointMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2122 if bpline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2123 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2124 bpline = self.markerFindNext(0, self.breakpointMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2125 if bpline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2126 self.setCursorPosition(bpline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2127 self.ensureLineVisible(bpline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2128
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2129 def menuPreviousBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2130 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2131 Public slot to handle the 'Previous breakpoint' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2132 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2133 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2134 if line == 0:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2135 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2136 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2137 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2138 bpline = self.markerFindPrevious(line, self.breakpointMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2139 if bpline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2140 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2141 bpline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2142 self.lines() - 1, self.breakpointMask)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2143 if bpline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2144 self.setCursorPosition(bpline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2145 self.ensureLineVisible(bpline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2146
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2147 def __menuClearBreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2148 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2149 Private slot to handle the 'Clear all breakpoints' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2150 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2151 self.__clearBreakpoints(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2152
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2153 def __clearBreakpoints(self, fileName):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2154 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2155 Private slot to clear all breakpoints.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
2156
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
2157 @param fileName name of the file (string)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2158 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2159 idxList = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2160 for handle, (ln, _, _, _, _) in list(self.breaks.items()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2161 index = self.breakpointModel.getBreakPointIndex(fileName, ln)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2162 if index.isValid():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2163 idxList.append(index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2164 if idxList:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2165 self.breakpointModel.deleteBreakPoints(idxList)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2166
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2167 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2168 ## Bookmark handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2169 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2170
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2171 def toggleBookmark(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2172 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2173 Public method to toggle a bookmark.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2174
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2175 @param line line number of the bookmark (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2176 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2177 for handle in self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2178 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2179 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2180 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2181 # set a new bookmark
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2182 handle = self.markerAdd(line - 1, self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2183 self.bookmarks.append(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2184 self.bookmarkToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2185 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2186
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2187 self.bookmarks.remove(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2188 self.markerDeleteHandle(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2189 self.bookmarkToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2190
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2191 def getBookmarks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2192 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2193 Public method to retrieve the bookmarks.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2194
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2195 @return sorted list of all lines containing a bookmark
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2196 (list of integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2197 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2198 bmlist = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2199 for handle in self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2200 bmlist.append(self.markerLine(handle) + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2201
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2202 bmlist.sort()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2203 return bmlist
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2204
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2205 def hasBookmarks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2206 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2207 Public method to check for the presence of bookmarks.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2208
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2209 @return flag indicating the presence of bookmarks (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2210 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2211 return len(self.bookmarks) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2212
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2213 def menuToggleBookmark(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2214 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2215 Public slot to handle the 'Toggle bookmark' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2216 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2217 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2218 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2219 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2220 self.toggleBookmark(self.line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2221 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2222
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2223 def nextBookmark(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2224 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2225 Public slot to handle the 'Next bookmark' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2226 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2227 line, index = self.getCursorPosition()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2228 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2229 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2230 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2231 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2232 bmline = self.markerFindNext(line, 1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2233 if bmline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2234 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2235 bmline = self.markerFindNext(0, 1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2236 if bmline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2237 self.setCursorPosition(bmline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2238 self.ensureLineVisible(bmline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2239
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2240 def previousBookmark(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2241 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2242 Public slot to handle the 'Previous bookmark' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2243 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2244 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2245 if line == 0:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2246 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2247 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2248 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2249 bmline = self.markerFindPrevious(line, 1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2250 if bmline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2251 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2252 bmline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2253 self.lines() - 1, 1 << self.bookmark)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2254 if bmline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2255 self.setCursorPosition(bmline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2256 self.ensureLineVisible(bmline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2257
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2258 def clearBookmarks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2259 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2260 Public slot to handle the 'Clear all bookmarks' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2261 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2262 for handle in self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2263 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2264 self.bookmarks = []
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2265 self.bookmarkToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2266
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2267 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2268 ## Printing methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2269 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2270
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2271 def printFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2272 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2273 Public slot to print the text.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2274 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2275 from .Printer import Printer
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2276 printer = Printer(mode=QPrinter.HighResolution)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2277 sb = e5App().getObject("UserInterface").statusBar()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2278 printDialog = QPrintDialog(printer, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2279 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2280 printDialog.addEnabledOption(QAbstractPrintDialog.PrintSelection)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2281 if printDialog.exec_() == QDialog.Accepted:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2282 sb.showMessage(self.trUtf8('Printing...'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2283 QApplication.processEvents()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2284 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2285 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2286 printer.setDocName(os.path.basename(fn))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2287 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2288 printer.setDocName(self.noName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2289 if printDialog.printRange() == QAbstractPrintDialog.Selection:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2290 # get the selection
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2291 fromLine, fromIndex, toLine, toIndex = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2292 if toIndex == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2293 toLine -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2294 # Qscintilla seems to print one line more than told
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2295 res = printer.printRange(self, fromLine, toLine - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2296 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2297 res = printer.printRange(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2298 if res:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2299 sb.showMessage(self.trUtf8('Printing completed'), 2000)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2300 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2301 sb.showMessage(self.trUtf8('Error while printing'), 2000)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2302 QApplication.processEvents()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2303 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2304 sb.showMessage(self.trUtf8('Printing aborted'), 2000)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2305 QApplication.processEvents()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2306
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2307 def printPreviewFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2308 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2309 Public slot to show a print preview of the text.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2310 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2311 from PyQt4.QtGui import QPrintPreviewDialog
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2312 from .Printer import Printer
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2313
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2314 printer = Printer(mode=QPrinter.HighResolution)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2315 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2316 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2317 printer.setDocName(os.path.basename(fn))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2318 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2319 printer.setDocName(self.noName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2320 preview = QPrintPreviewDialog(printer, self)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2321 preview.paintRequested.connect(self.__printPreview)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2322 preview.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2323
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2324 def __printPreview(self, printer):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2325 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2326 Private slot to generate a print preview.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2327
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2328 @param printer reference to the printer object
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2329 (QScintilla.Printer.Printer)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2330 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2331 printer.printRange(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2332
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2333 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2334 ## Task handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2335 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2336
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2337 def hasTaskMarkers(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2338 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2339 Public method to determine, if this editor contains any task markers.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2340
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2341 @return flag indicating the presence of task markers (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2342 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2343 return self.__hasTaskMarkers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2344
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2345 def nextTask(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2346 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2347 Public slot to handle the 'Next task' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2348 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2349 line, index = self.getCursorPosition()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2350 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2351 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2352 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2353 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2354 taskline = self.markerFindNext(line, 1 << self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2355 if taskline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2356 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2357 taskline = self.markerFindNext(0, 1 << self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2358 if taskline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2359 self.setCursorPosition(taskline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2360 self.ensureLineVisible(taskline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2361
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2362 def previousTask(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2363 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2364 Public slot to handle the 'Previous task' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2365 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2366 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2367 if line == 0:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2368 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2369 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2370 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2371 taskline = self.markerFindPrevious(line, 1 << self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2372 if taskline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2373 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2374 taskline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2375 self.lines() - 1, 1 << self.taskmarker)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2376 if taskline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2377 self.setCursorPosition(taskline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2378 self.ensureLineVisible(taskline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2379
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2380 def extractTasks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2381 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2382 Public slot to extract all tasks.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2383 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2384 from Tasks.Task import Task
1819
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2385 markers = {
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2386 Task.TypeWarning:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2387 Preferences.getTasks("TasksWarningMarkers").split(),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2388 Task.TypeNote:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2389 Preferences.getTasks("TasksNoteMarkers").split(),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2390 Task.TypeTodo:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2391 Preferences.getTasks("TasksTodoMarkers").split(),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2392 Task.TypeFixme:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2393 Preferences.getTasks("TasksFixmeMarkers").split(),
1819
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2394 }
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2395 txtList = self.text().split(self.getLineSeparator())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2396
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2397 # clear all task markers and tasks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2398 self.markerDeleteAll(self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2399 self.taskViewer.clearFileTasks(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2400 self.__hasTaskMarkers = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2401
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2402 # now search tasks and record them
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2403 lineIndex = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2404 for line in txtList:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2405 lineIndex += 1
1819
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2406 shouldBreak = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2407
1819
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2408 for taskType, taskMarkers in markers.items():
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2409 for taskMarker in taskMarkers:
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2410 index = line.find(taskMarker)
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2411 if index > -1:
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2412 task = line[index:]
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2413 self.markerAdd(lineIndex, self.taskmarker)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2414 self.taskViewer.addFileTask(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2415 task, self.fileName, lineIndex + 1, taskType)
1819
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2416 self.__hasTaskMarkers = True
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2417 shouldBreak = True
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2418 break
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2419 if shouldBreak:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2420 break
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2421 self.taskMarkersUpdated.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2422
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2423 ###########################################################################
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
2424 ## Change tracing methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2425 ###########################################################################
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2426
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2427 def __createChangeMarkerPixmap(self, key, size=16, width=4):
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2428 """
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2429 Private method to create a pixmap for the change markers.
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2430
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2431 @param key key of the color to use (string)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2432 @param size size of the pixmap (integer)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2433 @param width width of the marker line (integer)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2434 @return create pixmap (QPixmap)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2435 """
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2436 pixmap = QPixmap(size, size)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2437 pixmap.fill(Qt.transparent)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2438 painter = QPainter(pixmap)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2439 painter.fillRect(size - 4, 0, 4, size,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2440 Preferences.getEditorColour(key))
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2441 painter.end()
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2442 return pixmap
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2443
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
2444 def __initOnlineChangeTrace(self):
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
2445 """
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
2446 Private slot to initialize the online change trace.
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
2447 """
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
2448 self.__hasChangeMarkers = False
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
2449 self.__oldText = self.text()
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2450 self.__lastSavedText = self.text()
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
2451 self.__onlineChangeTraceTimer = QTimer(self)
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
2452 self.__onlineChangeTraceTimer.setSingleShot(True)
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
2453 self.__onlineChangeTraceTimer.setInterval(
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
2454 Preferences.getEditor("OnlineChangeTraceInterval"))
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
2455 self.__onlineChangeTraceTimer.timeout.connect(
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
2456 self.__onlineChangeTraceTimerTimeout)
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
2457 self.textChanged.connect(self.__resetOnlineChangeTraceTimer)
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
2458
2189
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2459 def __reinitOnlineChangeTrace(self):
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2460 """
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2461 Private slot to re-initialize the online change trace.
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2462 """
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2463 self.__oldText = self.text()
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2464 self.__lastSavedText = self.text()
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2465 self.__deleteAllChangeMarkers()
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
2466
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
2467 def __resetOnlineChangeTraceTimer(self):
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
2468 """
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
2469 Private method to reset the online syntax check 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
2470 """
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
2471 if Preferences.getEditor("OnlineChangeTrace"):
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
2472 self.__onlineChangeTraceTimer.stop()
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
2473 self.__onlineChangeTraceTimer.start()
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
2474
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
2475 def __onlineChangeTraceTimerTimeout(self):
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
2476 """
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
2477 Private slot to mark added and changed lines.
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
2478 """
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
2479 self.__deleteAllChangeMarkers()
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
2480
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2481 # step 1: mark saved changes
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
2482 oldL = self.__oldText.splitlines()
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2483 newL = self.__lastSavedText.splitlines()
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2484 matcher = difflib.SequenceMatcher(None, oldL, newL)
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2485
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2486 for token, i1, i2, j1, j2 in matcher.get_opcodes():
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2487 if token in ["insert", "replace"]:
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2488 for lineNo in range(j1, j2):
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2489 self.markerAdd(lineNo, 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
2490 self.__hasChangeMarkers = True
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2491
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2492 # step 2: mark unsaved changes
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2493 oldL = self.__lastSavedText.splitlines()
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
2494 newL = self.text().splitlines()
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
2495 matcher = difflib.SequenceMatcher(None, oldL, newL)
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
2496
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
2497 for token, i1, i2, j1, j2 in matcher.get_opcodes():
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
2498 if token in ["insert", "replace"]:
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
2499 for lineNo in range(j1, j2):
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2500 self.markerAdd(lineNo, self.__changeMarkerUnsaved)
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
2501 self.__hasChangeMarkers = True
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
2502
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
2503 if self.__hasChangeMarkers:
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
2504 self.changeMarkersUpdated.emit(self)
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
2505
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
2506 def __resetOnlineChangeTraceInfo(self):
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
2507 """
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
2508 Private slot to reset the online change trace info.
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
2509 """
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2510 self.__lastSavedText = self.text()
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
2511 self.__deleteAllChangeMarkers()
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
2512
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2513 # mark saved changes
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2514 oldL = self.__oldText.splitlines()
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2515 newL = self.__lastSavedText.splitlines()
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2516 matcher = difflib.SequenceMatcher(None, oldL, newL)
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2517
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2518 for token, i1, i2, j1, j2 in matcher.get_opcodes():
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2519 if token in ["insert", "replace"]:
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2520 for lineNo in range(j1, j2):
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2521 self.markerAdd(lineNo, 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
2522 self.__hasChangeMarkers = True
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2523
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2524 if self.__hasChangeMarkers:
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2525 self.changeMarkersUpdated.emit(self)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2526
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
2527 def __deleteAllChangeMarkers(self):
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
2528 """
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
2529 Private slot to delete all change markers.
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
2530 """
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2531 self.markerDeleteAll(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
2532 self.markerDeleteAll(self.__changeMarkerSaved)
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
2533 self.__hasChangeMarkers = False
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
2534 self.changeMarkersUpdated.emit(self)
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
2535
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
2536 def hasChangeMarkers(self):
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
2537 """
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
2538 Public method to determine, if this editor contains any change markers.
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
2539
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
2540 @return flag indicating the presence of change markers (boolean)
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
2541 """
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
2542 return self.__hasChangeMarkers
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
2543
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
2544 def nextChange(self):
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
2545 """
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
2546 Public slot to handle the 'Next change' context menu action.
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
2547 """
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
2548 line, index = self.getCursorPosition()
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
2549 if line == self.lines() - 1:
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
2550 line = 0
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
2551 else:
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
2552 line += 1
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2553 changeline = self.markerFindNext(line, self.changeMarkersMask)
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
2554 if changeline < 0:
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
2555 # wrap around
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2556 changeline = self.markerFindNext(0, self.changeMarkersMask)
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
2557 if changeline >= 0:
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
2558 self.setCursorPosition(changeline, 0)
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
2559 self.ensureLineVisible(changeline)
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
2560
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
2561 def previousChange(self):
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
2562 """
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
2563 Public slot to handle the 'Previous task' context menu action.
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
2564 """
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
2565 line, index = self.getCursorPosition()
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
2566 if line == 0:
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
2567 line = self.lines() - 1
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
2568 else:
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
2569 line -= 1
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2570 changeline = self.markerFindPrevious(line, self.changeMarkersMask)
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
2571 if changeline < 0:
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
2572 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2573 changeline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2574 self.lines() - 1, self.changeMarkersMask)
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
2575 if changeline >= 0:
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
2576 self.setCursorPosition(changeline, 0)
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
2577 self.ensureLineVisible(changeline)
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
2578
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2579 ###########################################################################
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
2580 ## Flags handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2581 ###########################################################################
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
2582
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
2583 def __processFlags(self):
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
2584 """
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
2585 Private method to extract flags and process them.
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2586
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2587 @return list of change flags (list of string)
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
2588 """
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
2589 txt = self.text()
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
2590 flags = Utilities.extractFlags(txt)
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
2591
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2592 changedFlags = []
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2593
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
2594 # Flag 1: 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
2595 if "FileType" in flags:
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2596 oldFiletype = self.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
2597 if isinstance(flags["FileType"], str):
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
2598 self.filetype = flags["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
2599 self.filetypeByFlag = True
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2600 if oldFiletype != self.filetype:
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2601 changedFlags.append("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
2602 else:
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
2603 if self.filetype != "" and self.filetypeByFlag:
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
2604 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
2605 self.filetypeByFlag = False
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
2606 self.__bindName(txt.splitlines()[0])
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2607 changedFlags.append("FileType")
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2608
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2609 return changedFlags
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
2610
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2611 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2612 ## File handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2613 ###########################################################################
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
2614
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2615 def checkDirty(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2616 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2617 Public method to check dirty status and open a message window.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2618
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2619 @return flag indicating successful reset of the dirty flag (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2620 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2621 if self.isModified():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2622 fn = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2623 if fn is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2624 fn = self.noName
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2625 res = E5MessageBox.okToClearData(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2626 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2627 self.trUtf8("File Modified"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2628 self.trUtf8("<p>The file <b>{0}</b> has unsaved changes.</p>")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2629 .format(fn),
549
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2630 self.saveFile)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2631 if res:
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2632 self.vm.setEditorName(self, self.fileName)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2633 return res
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2634
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2635 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2636
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2637 def revertToUnmodified(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2638 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2639 Public method to revert back to the last saved state.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2640 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2641 undo_ = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2642 while self.isModified():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2643 if undo_:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2644 # try undo first
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2645 if self.isUndoAvailable():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2646 self.undo()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2647 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2648 undo_ = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2649 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2650 # try redo next
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2651 if self.isRedoAvailable():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2652 self.redo()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2653 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2654 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2655 # Couldn't find the unmodified state
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2656
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2657 def readFile(self, fn, createIt=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2658 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2659 Public slot to read the text from a file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2660
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2661 @param fn filename to read from (string)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2662 @param createIt flag indicating the creation of a new file, if the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2663 given one doesn't exist (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2664 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2665 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2666
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2667 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2668 if createIt and not os.path.exists(fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2669 f = open(fn, "w")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2670 f.close()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2671 txt, self.encoding = Utilities.readEncodedFile(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2672 except (UnicodeDecodeError, IOError) as why:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2673 QApplication.restoreOverrideCursor()
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2674 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2675 self.vm,
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2676 self.trUtf8('Open File'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2677 self.trUtf8('<p>The file <b>{0}</b> could not be opened.</p>'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2678 '<p>Reason: {1}</p>')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2679 .format(fn, str(why)))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2680 QApplication.restoreOverrideCursor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2681 raise
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2682 fileEol = self.detectEolString(txt)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2683
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2684 modified = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2685 if (not Preferences.getEditor("TabForIndentation")) and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2686 Preferences.getEditor("ConvertTabsOnLoad") and \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
2687 not (self.lexer_ and
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2688 self.lexer_.alwaysKeepTabs()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2689 txtExpanded = txt.expandtabs(Preferences.getEditor("TabWidth"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2690 if txtExpanded != txt:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2691 modified = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2692 txt = txtExpanded
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2693 del txtExpanded
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2694
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2695 self.setText(txt)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2696
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
2697 # get eric specific flags
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
2698 self.__processFlags()
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
2699
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2700 # perform automatic eol conversion
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2701 if Preferences.getEditor("AutomaticEOLConversion"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2702 self.convertEols(self.eolMode())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2703 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2704 self.setEolModeByEolString(fileEol)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2705
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2706 self.extractTasks()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2707
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2708 QApplication.restoreOverrideCursor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2709
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2710 self.setModified(modified)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2711 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2712
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2713 def __removeTrailingWhitespace(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2714 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2715 Private method to remove trailing whitespace.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2716 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2717 searchRE = r"[ \t]+$" # whitespace at the end of a line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2718
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2719 ok = self.findFirstTarget(searchRE, True, False, False, 0, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2720 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2721 while ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2722 self.replaceTarget("")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2723 ok = self.findNextTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2724 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2725
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2726 def writeFile(self, fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2727 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2728 Public slot to write the text to a file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2729
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2730 @param fn filename to write to (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2731 @return flag indicating success (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2732 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2733 if Preferences.getEditor("StripTrailingWhitespace"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2734 self.__removeTrailingWhitespace()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2735
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2736 txt = self.text()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2737 # work around glitch in scintilla: always make sure,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2738 # that the last line is terminated properly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2739 eol = self.getLineSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2740 if eol:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2741 if len(txt) >= len(eol):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2742 if txt[-len(eol):] != eol:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2743 txt += eol
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2744 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2745 txt += eol
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2746
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2747 # create a backup file, if the option is set
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2748 createBackup = Preferences.getEditor("CreateBackupFile")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2749 if createBackup:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2750 if os.path.islink(fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2751 fn = os.path.realpath(fn)
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
2752 bfn = '{0}~'.format(fn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2753 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2754 permissions = os.stat(fn).st_mode
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2755 perms_valid = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2756 except EnvironmentError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2757 # if there was an error, ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2758 perms_valid = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2759 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2760 os.remove(bfn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2761 except EnvironmentError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2762 # if there was an error, ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2763 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2764 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2765 os.rename(fn, bfn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2766 except EnvironmentError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2767 # if there was an error, ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2768 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2769
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2770 # now write text to the file fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2771 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2772 self.encoding = Utilities.writeEncodedFile(fn, txt, self.encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2773 if createBackup and perms_valid:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2774 os.chmod(fn, permissions)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2775 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2776 except (IOError, Utilities.CodingError, UnicodeError) as why:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2777 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2778 self,
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2779 self.trUtf8('Save File'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2780 self.trUtf8('<p>The file <b>{0}</b> could not be saved.<br/>'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2781 'Reason: {1}</p>')
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2782 .format(fn, str(why)))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2783 return False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2784
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2785 def saveFile(self, saveas=False, path=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2786 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2787 Public slot to save the text to a file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2788
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2789 @param saveas flag indicating a 'save as' action (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2790 @param path directory to save the file in (string)
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
2791 @return flag indicating success (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2792 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2793 if not saveas and not self.isModified():
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
2794 return False # do nothing if text wasn't changed
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2795
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2796 newName = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2797 if saveas or self.fileName is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2798 saveas = True
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2799
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2800 # save to project, if a project is loaded
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2801 if self.project.isOpen():
994
8ed60a191a3a Fixed an issue in isPy2File and isPy3File in the editor and refined the save as function when a project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 991
diff changeset
2802 if self.fileName is not None and \
8ed60a191a3a Fixed an issue in isPy2File and isPy3File in the editor and refined the save as function when a project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 991
diff changeset
2803 self.project.startswithProjectPath(self.fileName):
8ed60a191a3a Fixed an issue in isPy2File and isPy3File in the editor and refined the save as function when a project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 991
diff changeset
2804 path = os.path.dirname(self.fileName)
8ed60a191a3a Fixed an issue in isPy2File and isPy3File in the editor and refined the save as function when a project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 991
diff changeset
2805 else:
8ed60a191a3a Fixed an issue in isPy2File and isPy3File in the editor and refined the save as function when a project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 991
diff changeset
2806 path = self.project.getProjectPath()
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2807
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2808 if not path and self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2809 path = os.path.dirname(self.fileName)
1939
eadb2328d7d4 Introduced a "workspace" directory that is used as the default for opening or saving new files or projects (configurable on Multiproject config page).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1930
diff changeset
2810 if not path:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2811 path = Preferences.getMultiProject("Workspace") or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2812 Utilities.getHomeDir()
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2813
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2814 from . import Lexers
1978
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2815 if self.fileName:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2816 filterPattern = "(*{0})".format(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2817 os.path.splitext(self.fileName)[1])
1978
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2818 for filter in Lexers.getSaveFileFiltersList(True):
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2819 if filterPattern in filter:
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2820 defaultFilter = filter
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2821 break
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2822 else:
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2823 defaultFilter = Preferences.getEditor("DefaultSaveFilter")
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2824 else:
1366fb8e7aed A little enhancement to the editor "Save As" function to use the extension of the current file to select the filter for the file dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1940
diff changeset
2825 defaultFilter = Preferences.getEditor("DefaultSaveFilter")
520
b0f523c3b037 Added code to cope with Linux distributor's usage of KDE wrapper dialogs for the Qt file dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 507
diff changeset
2826 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2827 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2828 self.trUtf8("Save File"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2829 path,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2830 Lexers.getSaveFileFiltersList(True, True),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2831 defaultFilter,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
2832 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2833
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2834 if fn:
718
979d6e242404 Fixed an issue in the editor saving files without extension on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
2835 if fn.endswith("."):
979d6e242404 Fixed an issue in the editor saving files without extension on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
2836 fn = fn[:-1]
979d6e242404 Fixed an issue in the editor saving files without extension on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
2837
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2838 ext = QFileInfo(fn).suffix()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2839 if not ext:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2840 ex = selectedFilter.split("(*")[1].split(")")[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2841 if ex:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2842 fn += ex
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2843 if QFileInfo(fn).exists():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2844 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2845 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2846 self.trUtf8("Save File"),
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
2847 self.trUtf8("<p>The file <b>{0}</b> already exists."
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
2848 " Overwrite it?</p>").format(fn),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2849 icon=E5MessageBox.Warning)
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
2850 if not res:
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
2851 return False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2852 fn = Utilities.toNativeSeparators(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2853 newName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2854 else:
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
2855 return False
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2856
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2857 # save to project, if a project is loaded
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2858 if self.project.isOpen() and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2859 self.project.startswithProjectPath(fn):
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2860 self.setEolModeByEolString(self.project.getEolString())
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2861 self.convertEols(self.eolMode())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2862 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2863 fn = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2864
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2865 self.editorAboutToBeSaved.emit(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2866 if self.writeFile(fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2867 if saveas:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2868 self.__clearBreakpoints(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2869 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2870 self.setModified(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2871 self.setReadOnly(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2872 self.setWindowTitle(self.fileName)
789
c190cd71b097 Fixed an issue introduced by the latest change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 788
diff changeset
2873 # get eric specific flags
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2874 changedFlags = self.__processFlags()
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2875 if not self.__lexerReset and "FileType" in changedFlags:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2876 self.setLanguage(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2877
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2878 if saveas:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2879 self.isResourcesFile = self.fileName.endswith(".qrc")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2880 self.__initContextMenu()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2881 self.editorRenamed.emit(self.fileName)
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2882
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2883 # save to project, if a project is loaded
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2884 if self.project.isOpen() and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2885 self.project.startswithProjectPath(fn):
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2886 self.project.appendFile(self.fileName)
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2887 self.addedToProject()
2517
495777476cc4 Added a line to the editor to reset the lexer after a file was saved to a project (in order to apply project specific lexer settings).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2493
diff changeset
2888 self.setLanguage(self.fileName)
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
2889
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2890 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2891 if newName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2892 self.vm.addToRecentList(newName)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2893 self.editorSaved.emit(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2894 self.__autoSyntaxCheck()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2895 self.extractTasks()
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
2896 self.__resetOnlineChangeTraceInfo()
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
2897 return True
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2898 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2899 self.lastModified = QFileInfo(fn).lastModified()
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
2900 return False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2901
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2902 def saveFileAs(self, path=None, toProject=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2903 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2904 Public slot to save a file with a new name.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2905
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2906 @param path directory to save the file in (string)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2907 @keyparam toProject flag indicating a save to project operation
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2908 (boolean)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2909 @return tuple of two values (boolean, string) giving a success
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2910 indicator and the name of the saved file
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2911 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2912 return self.saveFile(True, path)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2913
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2914 def handleRenamed(self, fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2915 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2916 Public slot to handle the editorRenamed signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2917
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2918 @param fn filename to be set for the editor (string).
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2919 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2920 self.__clearBreakpoints(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2921
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2922 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2923 self.setWindowTitle(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2924
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2925 if self.lexer_ is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2926 self.setLanguage(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2927
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2928 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2929 self.vm.setEditorName(self, self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2930 self.__updateReadOnly(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2931
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2932 def fileRenamed(self, fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2933 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2934 Public slot to handle the editorRenamed signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2935
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2936 @param fn filename to be set for the editor (string).
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2937 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2938 self.handleRenamed(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2939 if not self.inFileRenamed:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2940 self.inFileRenamed = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2941 self.editorRenamed.emit(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2942 self.inFileRenamed = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2943
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2944 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2945 ## Utility methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2946 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2947
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2948 def ensureVisible(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2949 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2950 Public slot to ensure, that the specified line is visible.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2951
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2952 @param line line number to make visible
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2953 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2954 self.ensureLineVisible(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2955
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2956 def ensureVisibleTop(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2957 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2958 Public slot to ensure, that the specified line is visible at the top
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2959 of the editor.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2960
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2961 @param line line number to make visible
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2962 """
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
2963 self.setFirstVisibleLine(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2964
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2965 def __marginClicked(self, margin, line, modifiers):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2966 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2967 Private slot to handle the marginClicked signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2968
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2969 @param margin id of the clicked margin (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2970 @param line line number of the click (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2971 @param modifiers keyboard modifiers (Qt.KeyboardModifiers)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2972 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2973 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2974 if margin == 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2975 if modifiers & Qt.KeyboardModifiers(Qt.ShiftModifier):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2976 if self.marginMenuActs["LMBbreakpoints"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2977 self.toggleBookmark(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2978 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2979 self.__toggleBreakpoint(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2980 elif modifiers & Qt.KeyboardModifiers(Qt.ControlModifier):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2981 if self.markersAtLine(line) & (1 << self.syntaxerror):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2982 self.__showSyntaxError(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2983 elif self.markersAtLine(line) & (1 << self.warning):
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
2984 self.__showWarning(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2985 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2986 if self.marginMenuActs["LMBbreakpoints"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2987 self.__toggleBreakpoint(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2988 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2989 self.toggleBookmark(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2990 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2991 if margin == self.__bmMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2992 self.toggleBookmark(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2993 elif margin == self.__bpMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2994 self.__toggleBreakpoint(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2995 elif margin == self.__indicMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2996 if self.markersAtLine(line) & (1 << self.syntaxerror):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2997 self.__showSyntaxError(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2998 elif self.markersAtLine(line) & (1 << self.warning):
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
2999 self.__showWarning(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3000
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3001 def handleMonospacedEnable(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3002 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3003 Private slot to handle the Use Monospaced Font context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3004 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3005 if self.menuActs["MonospacedFont"].isChecked():
3087
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
3006 if not self.lexer_:
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
3007 self.setMonospaced(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3008 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3009 if self.lexer_:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3010 self.lexer_.readSettings(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3011 Preferences.Prefs.settings, "Scintilla")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3012 self.lexer_.initProperties()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3013 self.setMonospaced(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3014 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3015
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3016 def getWordBoundaries(self, line, index, useWordChars=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3017 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3018 Public method to get the word boundaries at a position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3019
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3020 @param line number of line to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3021 @param index position to look at (int)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3022 @keyparam useWordChars flag indicating to use the wordCharacters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3023 method (boolean)
2213
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3024 @return tuple with start and end indexes of the word at the position
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3025 (integer, integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3026 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3027 text = self.text(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3028 if self.caseSensitive():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3029 cs = Qt.CaseSensitive
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3030 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3031 cs = Qt.CaseInsensitive
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3032 wc = self.wordCharacters()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3033 if wc is None or not useWordChars:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3034 regExp = QRegExp('[^\w_]', cs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3035 else:
448
a1f1b226ff4b Fixed a few unicode related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 429
diff changeset
3036 wc = re.sub('\w', "", wc)
a1f1b226ff4b Fixed a few unicode related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 429
diff changeset
3037 regExp = QRegExp('[^\w{0}]'.format(re.escape(wc)), cs)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3038 start = regExp.lastIndexIn(text, index) + 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3039 end = regExp.indexIn(text, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3040 if start == end + 1 and index > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3041 # we are on a word boundary, try again
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3042 start = regExp.lastIndexIn(text, index - 1) + 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3043 if start == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3044 start = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3045 if end == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3046 end = len(text)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3047
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3048 return (start, end)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3049
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3050 def getWord(self, line, index, direction=0, useWordChars=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3051 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3052 Public method to get the word at a position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3053
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3054 @param line number of line to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3055 @param index position to look at (int)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3056 @param direction direction to look in (0 = whole word, 1 = left,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3057 2 = right)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3058 @keyparam useWordChars flag indicating to use the wordCharacters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3059 method (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3060 @return the word at that position (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3061 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3062 start, end = self.getWordBoundaries(line, index, useWordChars)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3063 if direction == 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3064 end = index
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3065 elif direction == 2:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3066 start = index
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3067 if end > start:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3068 text = self.text(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3069 word = text[start:end]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3070 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3071 word = ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3072 return word
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3073
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3074 def getWordLeft(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3075 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3076 Public method to get the word to the left of a position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3077
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3078 @param line number of line to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3079 @param index position to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3080 @return the word to the left of that position (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3081 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3082 return self.getWord(line, index, 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3083
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3084 def getWordRight(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3085 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3086 Public method to get the word to the right of a position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3087
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3088 @param line number of line to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3089 @param index position to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3090 @return the word to the right of that position (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3091 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3092 return self.getWord(line, index, 2)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3093
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3094 def getCurrentWord(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3095 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3096 Public method to get the word at the current position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3097
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3098 @return the word at that current position (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3099 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3100 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3101 return self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3102
2213
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3103 def getCurrentWordBoundaries(self):
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3104 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3105 Public method to get the word boundaries at the current position.
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3106
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3107 @return tuple with start and end indexes of the current word
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3108 (integer, integer)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3109 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3110 line, index = self.getCursorPosition()
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3111 return self.getWordBoundaries(line, index)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
3112
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3113 def selectWord(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3114 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3115 Public method to select the word at a position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3116
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3117 @param line number of line to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3118 @param index position to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3119 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3120 start, end = self.getWordBoundaries(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3121 self.setSelection(line, start, line, end)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3122
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3123 def selectCurrentWord(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3124 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3125 Public method to select the current word.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3126 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3127 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3128 self.selectWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3129
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3130 def __getCharacter(self, pos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3131 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3132 Private method to get the character to the left of the current position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3133 in the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3134
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3135 @param pos position to get character at (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3136 @return requested character or "", if there are no more (string) and
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3137 the next position (i.e. pos - 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3138 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3139 if pos <= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3140 return "", pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3141
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3142 pos = self.positionBefore(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3143 ch = self.charAt(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3144
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3145 # Don't go past the end of the previous line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3146 if ch == '\n' or ch == '\r':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3147 return "", pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3148
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3149 return ch, pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3150
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3151 def getSearchText(self, selectionOnly=False):
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3152 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3153 Public method to determine the selection or the current word for the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3154 next search operation.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3155
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3156 @param selectionOnly flag indicating that only selected text should be
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3157 returned (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3158 @return selection or current word (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3159 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3160 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3161 text = self.selectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3162 if '\r' in text or '\n' in text:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3163 # the selection contains at least a newline, it is
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3164 # unlikely to be the expression to search for
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3165 return ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3166
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3167 return text
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3168
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3169 if not selectionOnly:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3170 # no selected text, determine the word at the current position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3171 return self.getCurrentWord()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3172
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3173 return ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3174
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3175 def setSearchIndicator(self, startPos, indicLength):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3176 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3177 Public method to set a search indicator for the given range.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3178
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3179 @param startPos start position of the indicator (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3180 @param indicLength length of the indicator (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3181 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3182 self.setIndicatorRange(self.searchIndicator, startPos, indicLength)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3183
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3184 def clearSearchIndicators(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3185 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3186 Public method to clear all search indicators.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3187 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3188 self.clearAllIndicators(self.searchIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3189 self.__markedText = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3190
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3191 def __markOccurrences(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3192 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3193 Private method to mark all occurrences of the current word.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3194 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3195 word = self.getCurrentWord()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3196 if not word:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3197 self.clearSearchIndicators()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3198 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3199
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3200 if self.__markedText == word:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3201 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3202
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3203 self.clearSearchIndicators()
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3204 ok = self.findFirstTarget(word, False, self.caseSensitive(), True,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3205 0, 0)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3206 while ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3207 tgtPos, tgtLen = self.getFoundTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3208 self.setSearchIndicator(tgtPos, tgtLen)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3209 ok = self.findNextTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3210 self.__markedText = word
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3211
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3212 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3213 ## Comment handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3214 ###########################################################################
2493
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3215
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3216 def __isCommentedLine(self, line, commentStr):
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3217 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3218 Private method to check, if the given line is a comment line as
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3219 produced by the configured comment rules.
2493
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3220
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3221 @param line text of the line to check (string)
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3222 @param commentStr comment string to check against (string)
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3223 @return flag indicating a commented line (boolean)
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3224 """
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3225 if Preferences.getEditor("CommentColumn0"):
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3226 return line.startswith(commentStr)
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3227 else:
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3228 return line.strip().startswith(commentStr)
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3229
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3230 def toggleCommentBlock(self):
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3231 """
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3232 Public slot to toggle the comment of a block.
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3233
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3234 If the line of the cursor or the selection is not commented, it will
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3235 be commented. If it is commented, the comment block will be removed.
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3236 The later works independent of the current selection.
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3237 """
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3238 if self.lexer_ is None or not self.lexer_.canBlockComment():
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3239 return
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3240
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3241 commentStr = self.lexer_.commentStr()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3242 line, index = self.getCursorPosition()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3243
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3244 # check if line starts with our comment string (i.e. was commented
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3245 # by our comment...() slots
2490
3d011f457ddd Extended the logic of the 'Toggle Comment Block' action to consider the current selection first.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2424
diff changeset
3246 if self.hasSelectedText() and \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3247 self.__isCommentedLine(self.text(self.getSelection()[0]),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3248 commentStr):
2490
3d011f457ddd Extended the logic of the 'Toggle Comment Block' action to consider the current selection first.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2424
diff changeset
3249 self.uncommentLineOrSelection()
2493
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3250 elif not self.__isCommentedLine(self.text(line), commentStr):
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3251 # it doesn't, so comment the line or selection
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3252 self.commentLineOrSelection()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3253 else:
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3254 # determine the start of the comment block
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3255 begline = line
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3256 while begline > 0 and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
3257 self.__isCommentedLine(self.text(begline - 1), commentStr):
1588
dccffd13be8d Did some PEP-8 related corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1566
diff changeset
3258 begline -= 1
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3259 # determine the end of the comment block
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3260 endline = line
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3261 lines = self.lines()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3262 while endline < lines and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
3263 self.__isCommentedLine(self.text(endline + 1), commentStr):
1588
dccffd13be8d Did some PEP-8 related corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1566
diff changeset
3264 endline += 1
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3265
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3266 self.setSelection(begline, 0, endline, self.lineLength(endline))
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3267 self.uncommentLineOrSelection()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3268
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3269 # reset the cursor
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3270 self.setCursorPosition(line, index - len(commentStr))
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3271
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3272 def commentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3273 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3274 Public slot to comment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3275 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3276 if self.lexer_ is None or not self.lexer_.canBlockComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3277 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3278
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3279 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3280 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3281 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3282 self.insertAt(self.lexer_.commentStr(), line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3283 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3284 self.insertAt(self.lexer_.commentStr(), line,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3285 self.indentation(line))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3286 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3287
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3288 def uncommentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3289 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3290 Public slot to uncomment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3291 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3292 if self.lexer_ is None or not self.lexer_.canBlockComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3293 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3294
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3295 commentStr = self.lexer_.commentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3296 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3297
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3298 # check if line starts with our comment string (i.e. was commented
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3299 # by our comment...() slots
2493
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3300 if not self.__isCommentedLine(self.text(line), commentStr):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3301 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3302
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3303 # now remove the comment string
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3304 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3305 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3306 self.setSelection(line, 0, line, len(commentStr))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3307 else:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3308 self.setSelection(line, self.indentation(line),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3309 line, self.indentation(line) + len(commentStr))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3310 self.removeSelectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3311 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3312
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3313 def commentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3314 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3315 Public slot to comment the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3316 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3317 if self.lexer_ is None or not self.lexer_.canBlockComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3318 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3319
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3320 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3321 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3322
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3323 commentStr = self.lexer_.commentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3324
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3325 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3326 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3327 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3328 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3329 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3330 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3331
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3332 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3333 # iterate over the lines
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3334 for line in range(lineFrom, endLine + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3335 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3336 self.insertAt(commentStr, line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3337 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3338 self.insertAt(commentStr, line, self.indentation(line))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3339
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3340 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3341 self.setSelection(lineFrom, 0, endLine + 1, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3342 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3343
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3344 def uncommentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3345 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3346 Public slot to uncomment the current selection.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3347 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3348 if self.lexer_ is None or not self.lexer_.canBlockComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3349 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3350
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3351 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3352 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3353
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3354 commentStr = self.lexer_.commentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3355
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3356 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3357 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3358 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3359 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3360 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3361 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3362
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3363 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3364 # iterate over the lines
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3365 for line in range(lineFrom, endLine + 1):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3366 # check if line starts with our comment string (i.e. was commented
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3367 # by our comment...() slots
2493
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3368 if not self.__isCommentedLine(self.text(line), commentStr):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3369 continue
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3370
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3371 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3372 self.setSelection(line, 0, line, len(commentStr))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3373 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3374 self.setSelection(line,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3375 self.indentation(line),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3376 line,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3377 self.indentation(line) + len(commentStr))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3378 self.removeSelectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3379
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3380 # adjust selection start
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3381 if line == lineFrom:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3382 indexFrom -= len(commentStr)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3383 if indexFrom < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3384 indexFrom = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3385
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3386 # adjust selection end
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3387 if line == lineTo:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3388 indexTo -= len(commentStr)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3389 if indexTo < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3390 indexTo = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3391
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3392 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3393 self.setSelection(lineFrom, indexFrom, lineTo, indexTo)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3394 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3395
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3396 def commentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3397 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3398 Public slot to comment the current line or current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3399 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3400 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3401 self.commentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3402 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3403 self.commentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3404
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3405 def uncommentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3406 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3407 Public slot to uncomment the current line or current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3408 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3409 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3410 self.uncommentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3411 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3412 self.uncommentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3413
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3414 def streamCommentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3415 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3416 Public slot to stream comment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3417 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3418 if self.lexer_ is None or not self.lexer_.canStreamComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3419 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3420
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3421 commentStr = self.lexer_.streamCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3422 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3423
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3424 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3425 self.insertAt(commentStr['end'], line, self.lineLength(line))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3426 self.insertAt(commentStr['start'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3427 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3428
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3429 def streamCommentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3430 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3431 Public slot to comment the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3432 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3433 if self.lexer_ is None or not self.lexer_.canStreamComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3434 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3435
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3436 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3437 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3438
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3439 commentStr = self.lexer_.streamCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3440
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3441 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3442 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3443 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3444 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3445 endIndex = self.lineLength(endLine)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3446 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3447 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3448 endIndex = indexTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3449
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3450 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3451 self.insertAt(commentStr['end'], endLine, endIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3452 self.insertAt(commentStr['start'], lineFrom, indexFrom)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3453
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3454 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3455 if indexTo > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3456 indexTo += len(commentStr['end'])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3457 if lineFrom == endLine:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3458 indexTo += len(commentStr['start'])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3459 self.setSelection(lineFrom, indexFrom, lineTo, indexTo)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3460 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3461
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3462 def streamCommentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3463 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3464 Public slot to stream comment the current line or current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3465 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3466 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3467 self.streamCommentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3468 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3469 self.streamCommentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3470
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3471 def boxCommentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3472 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3473 Public slot to box comment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3474 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3475 if self.lexer_ is None or not self.lexer_.canBoxComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3476 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3477
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3478 commentStr = self.lexer_.boxCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3479 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3480
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3481 eol = self.getLineSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3482 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3483 self.insertAt(eol, line, self.lineLength(line))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3484 self.insertAt(commentStr['end'], line + 1, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3485 self.insertAt(commentStr['middle'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3486 self.insertAt(eol, line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3487 self.insertAt(commentStr['start'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3488 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3489
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3490 def boxCommentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3491 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3492 Public slot to box comment the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3493 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3494 if self.lexer_ is None or not self.lexer_.canBoxComment():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3495 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3496
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3497 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3498 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3499
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3500 commentStr = self.lexer_.boxCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3501
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3502 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3503 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3504 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3505 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3506 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3507 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3508
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3509 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3510 # iterate over the lines
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3511 for line in range(lineFrom, endLine + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3512 self.insertAt(commentStr['middle'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3513
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3514 # now do the comments before and after the selection
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3515 eol = self.getLineSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3516 self.insertAt(eol, endLine, self.lineLength(endLine))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3517 self.insertAt(commentStr['end'], endLine + 1, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3518 self.insertAt(eol, lineFrom, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3519 self.insertAt(commentStr['start'], lineFrom, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3520
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3521 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3522 self.setSelection(lineFrom, 0, endLine + 3, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3523 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3524
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3525 def boxCommentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3526 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3527 Public slot to box comment the current line or current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3528 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3529 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3530 self.boxCommentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3531 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3532 self.boxCommentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3533
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3534 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3535 ## Indentation handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3536 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3537
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3538 def __indentLine(self, indent=True):
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3539 """
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3540 Private method to indent or unindent the current line.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3541
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3542 @param indent flag indicating an indent operation (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3543 <br />If the flag is true, an indent operation is performed.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3544 Otherwise the current line is unindented.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3545 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3546 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3547 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3548 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3549 self.indent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3550 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3551 self.unindent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3552 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3553 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3554 self.setCursorPosition(line, index + self.indentationWidth())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3555 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3556 self.setCursorPosition(line, index - self.indentationWidth())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3557
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3558 def __indentSelection(self, indent=True):
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3559 """
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3560 Private method to indent or unindent the current selection.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3561
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3562 @param indent flag indicating an indent operation (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3563 <br />If the flag is true, an indent operation is performed.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3564 Otherwise the current line is unindented.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3565 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3566 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3567 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3568
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3569 # get the selection
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3570 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3571
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3572 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3573 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3574 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3575 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3576
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3577 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3578 # iterate over the lines
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3579 for line in range(lineFrom, endLine + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3580 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3581 self.indent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3582 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3583 self.unindent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3584 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3585 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3586 if indexTo == 0:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3587 self.setSelection(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3588 lineFrom, indexFrom + self.indentationWidth(),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3589 lineTo, 0)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3590 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3591 self.setSelection(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3592 lineFrom, indexFrom + self.indentationWidth(),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3593 lineTo, indexTo + self.indentationWidth())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3594 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3595 indexStart = indexFrom - self.indentationWidth()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3596 if indexStart < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3597 indexStart = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3598 indexEnd = indexTo - self.indentationWidth()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3599 if indexEnd < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3600 indexEnd = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3601 self.setSelection(lineFrom, indexStart, lineTo, indexEnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3602
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3603 def indentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3604 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
3605 Public slot to indent the current line or current selection.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3606 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3607 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3608 self.__indentSelection(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3609 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3610 self.__indentLine(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3611
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3612 def unindentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3613 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3614 Public slot to unindent the current line or current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3615 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3616 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3617 self.__indentSelection(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3618 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3619 self.__indentLine(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3620
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3621 def smartIndentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3622 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3623 Public slot to indent current line smartly.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3624 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3625 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3626 if self.lexer_ and self.lexer_.hasSmartIndent():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3627 self.lexer_.smartIndentSelection(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3628 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3629 self.__indentSelection(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3630 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3631 if self.lexer_ and self.lexer_.hasSmartIndent():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3632 self.lexer_.smartIndentLine(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3633 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3634 self.__indentLine(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3635
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3636 def gotoLine(self, line, pos=1, firstVisible=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3637 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3638 Public slot to jump to the beginning of a line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3639
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3640 @param line line number to go to (integer)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
3641 @keyparam pos position in line to go to (integer)
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3642 @keyparam firstVisible flag indicating to make the line the first
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3643 visible line (boolean)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
3644 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
3645 self.setCursorPosition(line - 1, pos - 1)
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3646 if firstVisible:
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3647 self.ensureVisibleTop(line)
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3648 else:
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3649 self.ensureVisible(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3650
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
3651 def __textChanged(self):
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
3652 """
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
3653 Private slot to handle a change of the editor 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
3654
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
3655 This slot defers the handling to the next time the event loop
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
3656 is run in order to ensure, that cursor position has been updated
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
3657 by the underlying Scintilla editor.
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
3658 """
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
3659 QTimer.singleShot(0, self.__saveLastEditPosition)
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
3660
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
3661 def __saveLastEditPosition(self):
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
3662 """
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
3663 Private slot to record the last edit position.
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
3664 """
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
3665 self.__lastEditPosition = self.getCursorPosition()
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
3666 self.lastEditPositionAvailable.emit()
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
3667
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
3668 def isLastEditPositionAvailable(self):
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
3669 """
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
3670 Public method to check, if a last edit position is available.
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
3671
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
3672 @return flag indicating availability (boolean)
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
3673 """
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
3674 return self.__lastEditPosition is not 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
3675
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
3676 def gotoLastEditPosition(self):
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
3677 """
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
3678 Public method to move the cursor to the last edit position.
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
3679 """
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
3680 self.setCursorPosition(*self.__lastEditPosition)
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
3681 self.ensureVisible(self.__lastEditPosition[0])
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
3682
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
3683 def gotoMethodClass(self, goUp=False):
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
3684 """
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
3685 Public method to go to the next Python method or class definition.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
3686
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
3687 @param goUp flag indicating the move direction (boolean)
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
3688 """
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
3689 if self.getPyVersion() or self.isRubyFile():
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
3690 lineNo = self.getCursorPosition()[0]
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
3691 line = self.text(lineNo)
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
3692 if line.strip().startswith(("class ", "def ", "module ")):
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
3693 if goUp:
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
3694 lineNo -= 1
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
3695 else:
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
3696 lineNo += 1
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
3697 while True:
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
3698 if goUp and lineNo < 0:
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
3699 self.setCursorPosition(0, 0)
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
3700 self.ensureVisible(0)
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
3701 return
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
3702 elif not goUp and lineNo == self.lines():
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
3703 lineNo = self.lines() - 1
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
3704 self.setCursorPosition(lineNo, self.lineLength(lineNo))
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
3705 self.ensureVisible(lineNo)
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
3706 return
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
3707
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
3708 line = self.text(lineNo)
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
3709 if line.strip().startswith(("class ", "def ", "module ")):
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
3710 # try 'def ' first because it occurs more often
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
3711 first = line.find("def ")
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
3712 if first > -1:
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
3713 first += 4
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
3714 else:
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
3715 first = line.find("class ")
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
3716 if first > -1:
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
3717 first += 6
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
3718 else:
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
3719 first = line.find("module ") + 7
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
3720 match = re.search("[:(]", line)
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
3721 if match:
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
3722 end = match.start()
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
3723 else:
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
3724 end = self.lineLength(lineNo) - 1
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
3725 self.setSelection(lineNo, first, lineNo, end)
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
3726 self.ensureVisible(lineNo)
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
3727 return
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
3728
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
3729 if goUp:
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
3730 lineNo -= 1
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
3731 else:
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
3732 lineNo += 1
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
3733
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3734 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3735 ## Setup methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3736 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3737
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3738 def readSettings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3739 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3740 Public slot to read the settings into our lexer.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3741 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3742 # read the lexer settings and reinit the properties
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3743 if self.lexer_ is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3744 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3745 self.lexer_.initProperties()
1566
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
3746
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
3747 self.lexer_.setDefaultColor(self.lexer_.color(0))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
3748 self.lexer_.setDefaultPaper(self.lexer_.paper(0))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3749
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3750 # read the typing completer settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3751 if self.completer is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3752 self.completer.readSettings()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3753
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3754 # set the margins layout
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3755 if QSCINTILLA_VERSION() >= 0x020301:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3756 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3757
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3758 # set the line marker colours
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3759 self.__setLineMarkerColours()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3760
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3761 # set the text display
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3762 self.__setTextDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3763
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3764 # set margin 0 and 2 configuration
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3765 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3766
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3767 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3768 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3769 self.__setCallTips()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3770
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3771 # set the autosave flags
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3772 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3773
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3774 if Preferences.getEditor("MiniContextMenu") != self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3775 # regenerate context menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3776 self.__initContextMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3777 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3778 # set checked context menu items
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3779 self.menuActs["AutoCompletionEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3780 self.autoCompletionThreshold() != -1)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3781 self.menuActs["MonospacedFont"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3782 self.useMonospaced)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3783 self.menuActs["AutosaveEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3784 self.autosaveEnabled and not self.autosaveManuallyDisabled)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3785
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3786 # regenerate the margins context menu(s)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3787 self.__initContextMenuMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3788
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3789 if Preferences.getEditor("MarkOccurrencesEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3790 self.__markOccurrencesTimer.setInterval(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3791 Preferences.getEditor("MarkOccurrencesTimeout"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3792 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3793 self.__markOccurrencesTimer.stop()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3794 self.clearSearchIndicators()
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
3795
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
3796 if Preferences.getEditor("OnlineSyntaxCheck"):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
3797 self.__onlineSyntaxCheckTimer.setInterval(
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
3798 Preferences.getEditor("OnlineSyntaxCheckInterval") * 1000)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
3799 else:
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
3800 self.__onlineSyntaxCheckTimer.stop()
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
3801
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
3802 if Preferences.getEditor("OnlineChangeTrace"):
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
3803 self.__onlineChangeTraceTimer.setInterval(
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
3804 Preferences.getEditor("OnlineChangeTraceInterval"))
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
3805 else:
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
3806 self.__onlineChangeTraceTimer.stop()
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
3807 self.__deleteAllChangeMarkers()
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
3808 self.markerDefine(self.__createChangeMarkerPixmap(
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
3809 "OnlineChangeTraceMarkerUnsaved"), self.__changeMarkerUnsaved)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
3810 self.markerDefine(self.__createChangeMarkerPixmap(
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
3811 "OnlineChangeTraceMarkerSaved"), self.__changeMarkerSaved)
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
3812
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
3813 # refresh the annotations display
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
3814 self.__refreshAnnotations()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3815
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3816 def __setLineMarkerColours(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3817 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3818 Private method to set the line marker colours.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3819 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3820 self.setMarkerForegroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3821 Preferences.getEditorColour("CurrentMarker"), self.currentline)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3822 self.setMarkerBackgroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3823 Preferences.getEditorColour("CurrentMarker"), self.currentline)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3824 self.setMarkerForegroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3825 Preferences.getEditorColour("ErrorMarker"), self.errorline)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3826 self.setMarkerBackgroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3827 Preferences.getEditorColour("ErrorMarker"), self.errorline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3828
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3829 def __setMarginsDisplay(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3830 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3831 Private method to configure margins 0 and 2.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3832 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3833 # set the settings for all margins
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3834 self.setMarginsFont(Preferences.getEditorOtherFonts("MarginsFont"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3835 self.setMarginsForegroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3836 Preferences.getEditorColour("MarginsForeground"))
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3837 self.setMarginsBackgroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3838 Preferences.getEditorColour("MarginsBackground"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3839
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3840 # reset standard margins settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3841 for margin in range(5):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3842 self.setMarginLineNumbers(margin, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3843 self.setMarginMarkerMask(margin, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3844 self.setMarginWidth(margin, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3845 self.setMarginSensitivity(margin, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3846
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3847 # set marker margin(s) settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3848 if self.__unifiedMargins:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3849 margin1Mask = (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
3850 (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
3851 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3852 (1 << self.tcbreakpoint) | \
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3853 (1 << self.dbreakpoint) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3854 (1 << self.currentline) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3855 (1 << self.errorline) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3856 (1 << self.bookmark) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3857 (1 << self.syntaxerror) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3858 (1 << self.notcovered) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3859 (1 << self.taskmarker) | \
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
3860 (1 << self.warning) | \
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
3861 (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
3862 (1 << self.__changeMarkerSaved)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3863 self.setMarginWidth(1, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3864 self.setMarginSensitivity(1, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3865 self.setMarginMarkerMask(1, margin1Mask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3866
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3867 self.__linenoMargin = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3868 self.__foldMargin = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3869 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3870
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3871 self.__bmMargin = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3872 self.__linenoMargin = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3873 self.__bpMargin = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3874 self.__foldMargin = 3
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3875 self.__indicMargin = 4
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3876
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3877 marginBmMask = (1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3878 self.setMarginWidth(self.__bmMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3879 self.setMarginSensitivity(self.__bmMargin, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3880 self.setMarginMarkerMask(self.__bmMargin, marginBmMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3881
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3882 marginBpMask = (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
3883 (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
3884 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3885 (1 << self.tcbreakpoint) | \
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3886 (1 << self.dbreakpoint) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3887 (1 << self.currentline) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3888 (1 << self.errorline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3889 self.setMarginWidth(self.__bpMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3890 self.setMarginSensitivity(self.__bpMargin, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3891 self.setMarginMarkerMask(self.__bpMargin, marginBpMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3892
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3893 marginIndicMask = (1 << self.syntaxerror) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3894 (1 << self.notcovered) | \
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3895 (1 << self.taskmarker) | \
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
3896 (1 << self.warning) | \
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
3897 (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
3898 (1 << self.__changeMarkerSaved)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3899 self.setMarginWidth(self.__indicMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3900 self.setMarginSensitivity(self.__indicMargin, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3901 self.setMarginMarkerMask(self.__indicMargin, marginIndicMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3902
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3903 # set linenumber margin settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3904 linenoMargin = Preferences.getEditor("LinenoMargin")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3905 self.setMarginLineNumbers(self.__linenoMargin, linenoMargin)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3906 if linenoMargin:
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
3907 self.__resizeLinenoMargin()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3908 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3909 self.setMarginWidth(self.__linenoMargin, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3910
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3911 # set folding margin settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3912 if Preferences.getEditor("FoldingMargin"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3913 self.setMarginWidth(self.__foldMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3914 folding = Preferences.getEditor("FoldingStyle")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3915 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3916 folding = QsciScintilla.FoldStyle(folding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3917 except AttributeError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3918 pass
342
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3919 self.setFolding(folding, self.__foldMargin)
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3920 self.setFoldMarginColors(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3921 Preferences.getEditorColour("FoldmarginBackground"),
342
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3922 Preferences.getEditorColour("FoldmarginBackground"))
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3923 self.setFoldMarkersColors(
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3924 Preferences.getEditorColour("FoldMarkersForeground"),
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3925 Preferences.getEditorColour("FoldMarkersBackground"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3926 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3927 self.setMarginWidth(self.__foldMargin, 0)
342
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
3928 self.setFolding(QsciScintilla.NoFoldStyle, self.__foldMargin)
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
3929
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
3930 def __resizeLinenoMargin(self):
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
3931 """
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
3932 Private slot to resize the line numbers margin.
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
3933 """
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
3934 linenoMargin = Preferences.getEditor("LinenoMargin")
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
3935 if linenoMargin:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3936 self.setMarginWidth(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3937 self.__linenoMargin, '8' * (len(str(self.lines())) + 1))
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
3938
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3939 def __setTextDisplay(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3940 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3941 Private method to configure the text display.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3942 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3943 self.setTabWidth(Preferences.getEditor("TabWidth"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3944 self.setIndentationWidth(Preferences.getEditor("IndentWidth"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3945 if self.lexer_ and self.lexer_.alwaysKeepTabs():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3946 self.setIndentationsUseTabs(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3947 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3948 self.setIndentationsUseTabs(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3949 Preferences.getEditor("TabForIndentation"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3950 self.setTabIndents(Preferences.getEditor("TabIndents"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3951 self.setBackspaceUnindents(Preferences.getEditor("TabIndents"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3952 self.setIndentationGuides(Preferences.getEditor("IndentationGuides"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3953 if Preferences.getEditor("ShowWhitespace"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3954 self.setWhitespaceVisibility(QsciScintilla.WsVisible)
939
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3955 try:
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3956 self.setWhitespaceForegroundColor(
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3957 Preferences.getEditorColour("WhitespaceForeground"))
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3958 self.setWhitespaceBackgroundColor(
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3959 Preferences.getEditorColour("WhitespaceBackground"))
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3960 self.setWhitespaceSize(
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3961 Preferences.getEditor("WhitespaceSize"))
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3962 except AttributeError:
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3963 # QScintilla before 2.5 doesn't support this
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
3964 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3965 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3966 self.setWhitespaceVisibility(QsciScintilla.WsInvisible)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3967 self.setEolVisibility(Preferences.getEditor("ShowEOL"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3968 self.setAutoIndent(Preferences.getEditor("AutoIndentation"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3969 if Preferences.getEditor("BraceHighlighting"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3970 self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3971 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3972 self.setBraceMatching(QsciScintilla.NoBraceMatch)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3973 self.setMatchedBraceForegroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3974 Preferences.getEditorColour("MatchingBrace"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3975 self.setMatchedBraceBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3976 Preferences.getEditorColour("MatchingBraceBack"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3977 self.setUnmatchedBraceForegroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3978 Preferences.getEditorColour("NonmatchingBrace"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3979 self.setUnmatchedBraceBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3980 Preferences.getEditorColour("NonmatchingBraceBack"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3981 if Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3982 self.setSelectionBackgroundColor(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3983 Preferences.getEditorColour("SelectionBackground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3984 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3985 self.setSelectionBackgroundColor(
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
3986 QApplication.palette().color(QPalette.Highlight))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3987 if Preferences.getEditor("ColourizeSelText"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3988 self.resetSelectionForegroundColor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3989 elif Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3990 self.setSelectionForegroundColor(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3991 Preferences.getEditorColour("SelectionForeground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3992 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
3993 self.setSelectionForegroundColor(
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
3994 QApplication.palette().color(QPalette.HighlightedText))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3995 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3996 self.setCaretForegroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3997 Preferences.getEditorColour("CaretForeground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3998 self.setCaretLineBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3999 Preferences.getEditorColour("CaretLineBackground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4000 self.setCaretLineVisible(Preferences.getEditor("CaretLineVisible"))
3067
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
4001 self.setCaretLineAlwaysVisible(
8fd7ae10de2b Implemented support for the new QScintilla feature to always highlight the caret line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3062
diff changeset
4002 Preferences.getEditor("CaretLineAlwaysVisible"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4003 self.caretWidth = Preferences.getEditor("CaretWidth")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4004 self.setCaretWidth(self.caretWidth)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4005 self.useMonospaced = Preferences.getEditor("UseMonospacedFont")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4006 self.setMonospaced(self.useMonospaced)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4007 edgeMode = Preferences.getEditor("EdgeMode")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4008 edge = QsciScintilla.EdgeMode(edgeMode)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4009 self.setEdgeMode(edge)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4010 if edgeMode:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4011 self.setEdgeColumn(Preferences.getEditor("EdgeColumn"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4012 self.setEdgeColor(Preferences.getEditorColour("Edge"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4013
2262
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4014 wrapVisualFlag = Preferences.getEditor("WrapVisualFlag")
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4015 self.setWrapMode(Preferences.getEditor("WrapLongLinesMode"))
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4016 self.setWrapVisualFlags(wrapVisualFlag, wrapVisualFlag)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4017
230
2cde09c26384 Added code to configure the zoom factor a file is opened with.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 206
diff changeset
4018 self.zoomTo(Preferences.getEditor("ZoomFactor"))
2cde09c26384 Added code to configure the zoom factor a file is opened with.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 206
diff changeset
4019
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4020 self.searchIndicator = QsciScintilla.INDIC_CONTAINER
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4021 self.indicatorDefine(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4022 self.searchIndicator, QsciScintilla.INDIC_BOX,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4023 Preferences.getEditorColour("SearchMarkers"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4024 if not Preferences.getEditor("SearchMarkersEnabled") and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4025 not Preferences.getEditor("QuickSearchMarkersEnabled") and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4026 not Preferences.getEditor("MarkOccurrencesEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4027 self.clearAllIndicators(self.searchIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4028
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4029 self.spellingIndicator = QsciScintilla.INDIC_CONTAINER + 1
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4030 self.indicatorDefine(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4031 self.spellingIndicator, QsciScintilla.INDIC_SQUIGGLE,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4032 Preferences.getEditorColour("SpellingMarkers"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4033 self.__setSpelling()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4034
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
4035 self.setCursorFlashTime(QApplication.cursorFlashTime())
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
4036
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4037 try:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4038 if Preferences.getEditor("AnnotationsEnabled"):
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4039 self.setAnnotationDisplay(QsciScintilla.AnnotationBoxed)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4040 else:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4041 self.setAnnotationDisplay(QsciScintilla.AnnotationHidden)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4042 except AttributeError:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4043 pass
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4044 self.__setAnnotationStyles()
1566
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
4045
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
4046 if Preferences.getEditor("OverrideEditAreaColours"):
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
4047 self.setColor(Preferences.getEditorColour("EditAreaForeground"))
0cb791cc631a Fixed the issue where a non matching background was shown in the editor for lines below the end of the text, if a lexer with a non-standard background was set.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
4048 self.setPaper(Preferences.getEditorColour("EditAreaBackground"))
2659
7f46c5a7ed73 Added support for virtual space to the Editor and Mini Editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2643
diff changeset
4049
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4050 self.setVirtualSpaceOptions(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4051 Preferences.getEditor("VirtualSpaceOptions"))
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4052
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4053 def __setEolMode(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4054 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4055 Private method to configure the eol mode of the editor.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4056 """
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4057 if self.fileName and \
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4058 self.project.isOpen() and \
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4059 self.project.isProjectFile(self.fileName):
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4060 self.setEolModeByEolString(self.project.getEolString())
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4061 else:
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4062 eolMode = Preferences.getEditor("EOLMode")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4063 eolMode = QsciScintilla.EolMode(eolMode)
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4064 self.setEolMode(eolMode)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4065 self.__eolChanged()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4066
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4067 def __setAutoCompletion(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4068 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4069 Private method to configure the autocompletion function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4070 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4071 if self.lexer_:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4072 self.setAutoCompletionFillupsEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4073 Preferences.getEditor("AutoCompletionFillups"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4074 self.setAutoCompletionCaseSensitivity(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4075 Preferences.getEditor("AutoCompletionCaseSensitivity"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4076 self.setAutoCompletionReplaceWord(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4077 Preferences.getEditor("AutoCompletionReplaceWord"))
971
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4078 try:
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4079 self.setAutoCompletionUseSingle(
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4080 Preferences.getEditor("AutoCompletionShowSingle"))
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4081 except AttributeError:
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4082 self.setAutoCompletionShowSingle(
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4083 Preferences.getEditor("AutoCompletionShowSingle"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4084 autoCompletionSource = Preferences.getEditor("AutoCompletionSource")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4085 if autoCompletionSource == QsciScintilla.AcsDocument:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4086 self.setAutoCompletionSource(QsciScintilla.AcsDocument)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4087 elif autoCompletionSource == QsciScintilla.AcsAPIs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4088 self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4089 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4090 self.setAutoCompletionSource(QsciScintilla.AcsAll)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4091 if Preferences.getEditor("AutoCompletionEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4092 if self.__acHookFunction is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4093 self.setAutoCompletionThreshold(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4094 Preferences.getEditor("AutoCompletionThreshold"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4095 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4096 self.setAutoCompletionThreshold(0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4097 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4098 self.setAutoCompletionThreshold(-1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4099 self.setAutoCompletionSource(QsciScintilla.AcsNone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4100
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4101 def __setCallTips(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4102 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4103 Private method to configure the calltips function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4104 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4105 if Preferences.getEditor("CallTipsEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4106 self.setCallTipsBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4107 Preferences.getEditorColour("CallTipsBackground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4108 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4109 calltipsStyle = Preferences.getEditor("CallTipsStyle")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4110 if calltipsStyle == QsciScintilla.CallTipsNoContext:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4111 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4112 elif calltipsStyle == \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4113 QsciScintilla.CallTipsNoAutoCompletionContext:
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4114 self.setCallTipsStyle(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4115 QsciScintilla.CallTipsNoAutoCompletionContext)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4116 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4117 self.setCallTipsStyle(QsciScintilla.CallTipsContext)
2262
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4118 try:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4119 self.setCallTipsPosition(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4120 Preferences.getEditor("CallTipsPosition"))
2262
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4121 except AttributeError:
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4122 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4123 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4124 self.setCallTipsStyle(QsciScintilla.CallTipsNone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4125
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4126 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4127 ## Autocompletion handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4128 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4129
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4130 def canAutoCompleteFromAPIs(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4131 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4132 Public method to check for API availablity.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4133
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4134 @return flag indicating autocompletion from APIs is available (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4135 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4136 return self.acAPI
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4137
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4138 def autoCompleteQScintilla(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4139 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4140 Public method to perform an autocompletion using QScintilla methods.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4141 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4142 acs = Preferences.getEditor("AutoCompletionSource")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4143 if acs == QsciScintilla.AcsDocument:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4144 self.autoCompleteFromDocument()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4145 elif acs == QsciScintilla.AcsAPIs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4146 self.autoCompleteFromAPIs()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4147 elif acs == QsciScintilla.AcsAll:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4148 self.autoCompleteFromAll()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4149 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4150 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4151 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4152 self.trUtf8("Autocompletion"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4153 self.trUtf8(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4154 """Autocompletion is not available because"""
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4155 """ there is no autocompletion source set."""))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4156
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4157 def setAutoCompletionEnabled(self, enable):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4158 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4159 Public method to enable/disable autocompletion.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4160
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4161 @param enable flag indicating the desired autocompletion status
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4162 (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4163 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4164 if enable:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4165 self.setAutoCompletionThreshold(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4166 Preferences.getEditor("AutoCompletionThreshold"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4167 autoCompletionSource = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4168 Preferences.getEditor("AutoCompletionSource")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4169 if autoCompletionSource == QsciScintilla.AcsDocument:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4170 self.setAutoCompletionSource(QsciScintilla.AcsDocument)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4171 elif autoCompletionSource == QsciScintilla.AcsAPIs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4172 self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4173 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4174 self.setAutoCompletionSource(QsciScintilla.AcsAll)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4175 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4176 self.setAutoCompletionThreshold(-1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4177 self.setAutoCompletionSource(QsciScintilla.AcsNone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4178
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4179 def __toggleAutoCompletionEnable(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4180 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4181 Private slot to handle the Enable Autocompletion context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4182 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4183 if self.menuActs["AutoCompletionEnable"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4184 self.setAutoCompletionEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4185 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4186 self.setAutoCompletionEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4187
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4188 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4189 ## Support for autocompletion hook methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4190 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4191
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4192 def __charAdded(self, charNumber):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4193 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4194 Public slot called to handle the user entering a character.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4195
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4196 @param charNumber value of the character entered (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4197 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4198 if self.isListActive():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4199 char = chr(charNumber)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4200 if self.__isStartChar(char):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4201 self.cancelList()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4202 self.autoComplete(auto=True, context=True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4203 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4204 elif char == '(':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4205 self.cancelList()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4206
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4207 if self.callTipsStyle() != QsciScintilla.CallTipsNone and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4208 self.lexer_ is not None and chr(charNumber) in '()':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4209 self.callTip()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4210
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4211 if not self.isCallTipActive():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4212 char = chr(charNumber)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4213 if self.__isStartChar(char):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4214 self.autoComplete(auto=True, context=True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4215 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4216
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4217 line, col = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4218 txt = self.getWordLeft(line, col)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4219 if len(txt) >= Preferences.getEditor("AutoCompletionThreshold"):
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4220 self.autoComplete(auto=True, context=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4221 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4222
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4223 def __isStartChar(self, ch):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4224 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4225 Private method to check, if a character is an autocompletion start
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4226 character.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4227
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4228 @param ch character to be checked (one character string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4229 @return flag indicating the result (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4230 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4231 if self.lexer_ is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4232 return False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4233
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4234 wseps = self.lexer_.autoCompletionWordSeparators()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4235 for wsep in wseps:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4236 if wsep.endswith(ch):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4237 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4238
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4239 return False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4240
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4241 def setAutoCompletionHook(self, func):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4242 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4243 Public method to set an autocompletion hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4244
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4245 @param func Function to be set to handle autocompletion. func
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4246 should be a function taking a reference to the editor and
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4247 a boolean indicating to complete a context.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4248 """
1063
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4249 if self.__acHookFunction is not None:
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4250 # there is another provider registered already
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4251 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4252 self,
1063
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4253 self.trUtf8("Activating Auto-Completion Provider"),
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4254 self.trUtf8("""Auto-completion provider cannot be connected"""
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4255 """ because there is already another one active."""
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4256 """ Please check your configuration."""))
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4257 return
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4258
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4259 if self.autoCompletionThreshold() > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4260 self.setAutoCompletionThreshold(0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4261 self.__acHookFunction = func
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4262 self.SCN_CHARADDED.connect(self.__charAdded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4263
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4264 def unsetAutoCompletionHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4265 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4266 Public method to unset a previously installed autocompletion hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4267 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4268 self.SCN_CHARADDED.disconnect(self.__charAdded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4269 self.__acHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4270 if self.autoCompletionThreshold() == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4271 self.setAutoCompletionThreshold(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4272 Preferences.getEditor("AutoCompletionThreshold"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4273
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4274 def autoCompletionHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4275 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4276 Public method to get the autocompletion hook function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4277
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4278 @return function set by setAutoCompletionHook()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4279 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4280 return self.__acHookFunction
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4281
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4282 def autoComplete(self, auto=False, context=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4283 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4284 Public method to start autocompletion.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4285
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4286 @keyparam auto flag indicating a call from the __charAdded method
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4287 (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4288 @keyparam context flag indicating to complete a context (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4289 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4290 if auto and self.autoCompletionThreshold() == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4291 # autocompletion is disabled
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4292 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4293
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4294 if self.__acHookFunction is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4295 self.__acHookFunction(self, context)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4296 elif not auto:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4297 self.autoCompleteQScintilla()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4298 elif self.autoCompletionSource() != QsciScintilla.AcsNone:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4299 self.autoCompleteQScintilla()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4300
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4301 def callTip(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4302 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4303 Public method to show calltips.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4304 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4305 if self.__ctHookFunction is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4306 self.__callTip()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4307 else:
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
4308 super(Editor, self).callTip()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4309
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4310 def __callTip(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4311 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4312 Private method to show call tips provided by a plugin.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4313 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4314 pos = self.currentPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4315
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4316 # move backward to the start of the current calltip working out
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4317 # which argument to highlight
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4318 commas = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4319 found = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4320 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4321 while ch:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4322 if ch == ',':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4323 commas += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4324 elif ch == ')':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4325 depth = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4326
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4327 # ignore everything back to the start of the corresponding
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4328 # parenthesis
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4329 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4330 while ch:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4331 if ch == ')':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4332 depth += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4333 elif ch == '(':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4334 depth -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4335 if depth == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4336 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4337 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4338 elif ch == '(':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4339 found = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4340 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4341
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4342 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4343
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4344 self.SendScintilla(QsciScintilla.SCI_CALLTIPCANCEL)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4345
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4346 if not found:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4347 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4348
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4349 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4350 callTips = self.__ctHookFunction(self, pos, commas)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4351 except TypeError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4352 # for backward compatibility
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4353 callTips = self.__ctHookFunction(self, pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4354 if len(callTips) == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4355 if Preferences.getEditor("CallTipsScintillaOnFail"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4356 # try QScintilla calltips
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
4357 super(Editor, self).callTip()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4358 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4359
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4360 ctshift = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4361 for ct in callTips:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4362 shift = ct.index("(")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4363 if ctshift < shift:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4364 ctshift = shift
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4365
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4366 cv = self.callTipsVisible()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4367 if cv > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4368 # this is just a safe guard
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4369 ct = self._encodeString("\n".join(callTips[:cv]))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4370 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4371 # until here and unindent below
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4372 ct = self._encodeString("\n".join(callTips))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4373
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4374 self.SendScintilla(QsciScintilla.SCI_CALLTIPSHOW,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4375 self.__adjustedCallTipPosition(ctshift, pos), ct)
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4376 if b'\n' in ct:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4377 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4378
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4379 # Highlight the current argument
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4380 if commas == 0:
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4381 astart = ct.find(b'(')
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4382 else:
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4383 astart = ct.find(b',')
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4384 commas -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4385 while astart != -1 and commas > 0:
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4386 astart = ct.find(b',', astart + 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4387 commas -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4388
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4389 if astart == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4390 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4391
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4392 depth = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4393 for aend in range(astart + 1, len(ct)):
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4394 ch = ct[aend:aend + 1]
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4395
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4396 if ch == b',' and depth == 0:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4397 break
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4398 elif ch == b'(':
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4399 depth += 1
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4400 elif ch == b')':
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4401 if depth == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4402 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4403
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4404 depth -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4405
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4406 if astart != aend:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4407 self.SendScintilla(QsciScintilla.SCI_CALLTIPSETHLT,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4408 astart + 1, aend)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4409
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4410 def __adjustedCallTipPosition(self, ctshift, pos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4411 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4412 Private method to calculate an adjusted position for showing calltips.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4413
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4414 @param ctshift amount the calltip shall be shifted (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4415 @param pos position into the text (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4416 @return new position for the calltip (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4417 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4418 ct = pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4419 if ctshift:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4420 ctmin = self.SendScintilla(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4421 QsciScintilla.SCI_POSITIONFROMLINE,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4422 self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, ct))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4423 if ct - ctshift < ctmin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4424 ct = ctmin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4425 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4426 ct = ct - ctshift
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4427 return ct
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4428
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4429 def setCallTipHook(self, func):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4430 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4431 Public method to set a calltip hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4432
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4433 @param func Function to be set to determine calltips. func
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4434 should be a function taking a reference to the editor,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4435 a position into the text and the amount of commas to the
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4436 left of the cursor. It should return the possible
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4437 calltips as a list of strings.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4438 """
1063
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4439 if self.__ctHookFunction is not None:
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4440 # there is another provider registered already
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4441 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4442 self,
1063
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4443 self.trUtf8("Activating Calltip Provider"),
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4444 self.trUtf8("""Calltip provider cannot be connected"""
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4445 """ because there is already another one active."""
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4446 """ Please check your configuration."""))
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4447 return
a0afd409c566 Added code to check, if there is an auto-completion/calltip provider connected already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1002
diff changeset
4448
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4449 self.__ctHookFunction = func
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4450
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4451 def unsetCallTipHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4452 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4453 Public method to unset a calltip hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4454 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4455 self.__ctHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4456
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4457 def callTipHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4458 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4459 Public method to get the calltip hook function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4460
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4461 @return function set by setCallTipHook()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4462 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4463 return self.__ctHookFunction
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4464
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4465 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4466 ## Methods needed by the context menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4467 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4468
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4469 def __marginNumber(self, xPos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4470 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4471 Private method to calculate the margin number based on a x position.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4472
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4473 @param xPos x position (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4474 @return margin number (integer, -1 for no margin)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4475 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4476 width = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4477 for margin in range(5):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4478 width += self.marginWidth(margin)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4479 if xPos <= width:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4480 return margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4481 return -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4482
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4483 def contextMenuEvent(self, evt):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4484 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4485 Private method implementing the context menu event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4486
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4487 @param evt the context menu event (QContextMenuEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4488 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4489 evt.accept()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4490 if self.__marginNumber(evt.x()) == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4491 self.spellingMenuPos = self.positionFromPoint(evt.pos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4492 if self.spellingMenuPos >= 0 and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4493 self.spell is not None and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4494 self.hasIndicator(self.spellingIndicator, self.spellingMenuPos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4495 self.spellingMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4496 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4497 self.menu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4498 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4499 self.line = self.lineAt(evt.pos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4500 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4501 self.marginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4502 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4503 if self.__marginNumber(evt.x()) in [self.__bmMargin,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4504 self.__linenoMargin]:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4505 self.bmMarginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4506 elif self.__marginNumber(evt.x()) == self.__bpMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4507 self.bpMarginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4508 elif self.__marginNumber(evt.x()) == self.__indicMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4509 self.indicMarginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4510
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4511 def __showContextMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4512 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4513 Private slot handling the aboutToShow signal of the context menu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4514 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4515 self.menuActs["Save"].setEnabled(self.isModified())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4516 self.menuActs["Undo"].setEnabled(self.isUndoAvailable())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4517 self.menuActs["Redo"].setEnabled(self.isRedoAvailable())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4518 self.menuActs["Revert"].setEnabled(self.isModified())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4519 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4520 self.menuActs["Cut"].setEnabled(self.hasSelectedText())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4521 self.menuActs["Copy"].setEnabled(self.hasSelectedText())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4522 if not self.isResourcesFile:
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
4523 if self.fileName and self.getPyVersion():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4524 self.menuActs["Show"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4525 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4526 self.menuActs["Show"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4527 if self.fileName and \
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
4528 (self.getPyVersion() or self.isRubyFile()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4529 self.menuActs["Diagrams"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4530 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4531 self.menuActs["Diagrams"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4532 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4533 if self.lexer_ is not None:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4534 self.menuActs["Comment"].setEnabled(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4535 self.lexer_.canBlockComment())
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4536 self.menuActs["Uncomment"].setEnabled(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4537 self.lexer_.canBlockComment())
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4538 self.menuActs["StreamComment"].setEnabled(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4539 self.lexer_.canStreamComment())
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4540 self.menuActs["BoxComment"].setEnabled(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4541 self.lexer_.canBoxComment())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4542 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4543 self.menuActs["Comment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4544 self.menuActs["Uncomment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4545 self.menuActs["StreamComment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4546 self.menuActs["BoxComment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4547
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4548 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
4549 self.completer is not None)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4550 self.menuActs["TypingAidsEnabled"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4551 self.completer is not None and self.completer.isEnabled())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4552
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
4553 from .SpellChecker import SpellChecker
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4554 spellingAvailable = SpellChecker.isAvailable()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4555 self.menuActs["SpellCheck"].setEnabled(spellingAvailable)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4556 self.menuActs["SpellCheckSelection"].setEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4557 spellingAvailable and self.hasSelectedText())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4558 self.menuActs["SpellCheckRemove"].setEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4559 spellingAvailable and self.spellingMenuPos >= 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4560
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
4561 if self.menuActs["OpenRejections"]:
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
4562 if self.fileName:
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
4563 rej = "{0}.rej".format(self.fileName)
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
4564 self.menuActs["OpenRejections"].setEnabled(os.path.exists(rej))
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
4565 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
4566 self.menuActs["OpenRejections"].setEnabled(False)
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
4567
3087
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
4568 self.menuActs["MonospacedFont"].setEnabled(self.lexer_ is None)
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
4569
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
4570 splitOrientation = self.vm.getSplitOrientation()
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
4571 if splitOrientation == Qt.Horizontal:
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
4572 self.menuActs["NewSplit"].setIcon(
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
4573 UI.PixmapCache.getIcon("splitHorizontal.png"))
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
4574 else:
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
4575 self.menuActs["NewSplit"].setIcon(
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
4576 UI.PixmapCache.getIcon("splitVertical.png"))
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
4577
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4578 self.showMenu.emit("Main", self.menu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4579
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4580 def __showContextMenuAutocompletion(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4581 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4582 Private slot called before the autocompletion menu is shown.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4583 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4584 self.menuActs["acDynamic"].setEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4585 self.acAPI or self.__acHookFunction is not None)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4586 self.menuActs["acAPI"].setEnabled(self.acAPI)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4587 self.menuActs["acAPIDocument"].setEnabled(self.acAPI)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4588 self.menuActs["calltip"].setEnabled(self.acAPI)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4589
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4590 self.showMenu.emit("Autocompletion", self.autocompletionMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4591
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4592 def __showContextMenuShow(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4593 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4594 Private slot called before the show menu is shown.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4595 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4596 prEnable = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4597 coEnable = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4598
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4599 # first check if the file belongs to a project
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4600 if self.project.isOpen() and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4601 self.project.isProjectSource(self.fileName):
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
4602 fn = self.project.getMainScript(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4603 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4604 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4605 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4606 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4607 prEnable = prEnable or \
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4608 os.path.isfile("{0}.profile".format(basename)) or \
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4609 os.path.isfile("{0}.profile".format(tbasename))
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4610 coEnable = (
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
4611 coEnable or
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
4612 os.path.isfile("{0}.coverage".format(basename)) or
1491
985c5abc8226 Corrected a few issues related to showing the coverage context menu items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
4613 os.path.isfile("{0}.coverage".format(tbasename))) and \
985c5abc8226 Corrected a few issues related to showing the coverage context menu items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
4614 self.project.isPy3Project()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4615
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4616 # now check ourself
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4617 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4618 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4619 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4620 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4621 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4622 prEnable = prEnable or \
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4623 os.path.isfile("{0}.profile".format(basename)) or \
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4624 os.path.isfile("{0}.profile".format(tbasename))
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4625 coEnable = (
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
4626 coEnable or
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
4627 os.path.isfile("{0}.coverage".format(basename)) or
1491
985c5abc8226 Corrected a few issues related to showing the coverage context menu items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
4628 os.path.isfile("{0}.coverage".format(tbasename))) and \
985c5abc8226 Corrected a few issues related to showing the coverage context menu items.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
4629 self.isPy3File()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4630
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4631 # now check for syntax errors
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4632 if self.hasSyntaxErrors():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4633 coEnable = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4634
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4635 self.profileMenuAct.setEnabled(prEnable)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4636 self.coverageMenuAct.setEnabled(coEnable)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4637 self.coverageShowAnnotationMenuAct.setEnabled(
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
4638 coEnable and len(self.notcoveredMarkers) == 0)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4639 self.coverageHideAnnotationMenuAct.setEnabled(
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
4640 len(self.notcoveredMarkers) > 0)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4641
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4642 self.showMenu.emit("Show", self.menuShow, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4643
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4644 def __showContextMenuGraphics(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4645 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4646 Private slot handling the aboutToShow signal of the diagrams context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4647 menu.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4648 """
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4649 if self.project.isOpen() and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4650 self.project.isProjectSource(self.fileName):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4651 self.applicationDiagramMenuAct.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4652 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4653 self.applicationDiagramMenuAct.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4654
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4655 self.showMenu.emit("Graphics", self.graphicsMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4656
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4657 def __showContextMenuMargin(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4658 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4659 Private slot handling the aboutToShow signal of the margins context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4660 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4661 """
3442
927186c0d409 Updated behavior of the Python version detection.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3412
diff changeset
4662 if self.fileName and (self.getPyVersion() or self.isRubyFile()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4663 self.marginMenuActs["Breakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4664 self.marginMenuActs["TempBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4665 if self.markersAtLine(self.line) & self.breakpointMask:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4666 self.marginMenuActs["EditBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4667 self.marginMenuActs["EnableBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4668 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4669 self.marginMenuActs["EditBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4670 self.marginMenuActs["EnableBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4671 if self.markersAtLine(self.line) & (1 << self.dbreakpoint):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4672 self.marginMenuActs["EnableBreakpoint"].setText(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4673 self.trUtf8('Enable breakpoint'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4674 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4675 self.marginMenuActs["EnableBreakpoint"].setText(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4676 self.trUtf8('Disable breakpoint'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4677 if self.breaks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4678 self.marginMenuActs["NextBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4679 self.marginMenuActs["PreviousBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4680 self.marginMenuActs["ClearBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4681 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4682 self.marginMenuActs["NextBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4683 self.marginMenuActs["PreviousBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4684 self.marginMenuActs["ClearBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4685 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4686 self.marginMenuActs["Breakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4687 self.marginMenuActs["TempBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4688 self.marginMenuActs["EditBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4689 self.marginMenuActs["EnableBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4690 self.marginMenuActs["NextBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4691 self.marginMenuActs["PreviousBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4692 self.marginMenuActs["ClearBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4693
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4694 if self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4695 self.marginMenuActs["NextBookmark"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4696 self.marginMenuActs["PreviousBookmark"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4697 self.marginMenuActs["ClearBookmark"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4698 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4699 self.marginMenuActs["NextBookmark"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4700 self.marginMenuActs["PreviousBookmark"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4701 self.marginMenuActs["ClearBookmark"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4702
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4703 if len(self.syntaxerrors):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4704 self.marginMenuActs["GotoSyntaxError"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4705 self.marginMenuActs["ClearSyntaxError"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4706 if self.markersAtLine(self.line) & (1 << self.syntaxerror):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4707 self.marginMenuActs["ShowSyntaxError"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4708 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4709 self.marginMenuActs["ShowSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4710 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4711 self.marginMenuActs["GotoSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4712 self.marginMenuActs["ClearSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4713 self.marginMenuActs["ShowSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4714
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4715 if len(self.warnings):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4716 self.marginMenuActs["NextWarningMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4717 self.marginMenuActs["PreviousWarningMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4718 self.marginMenuActs["ClearWarnings"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4719 if self.markersAtLine(self.line) & (1 << self.warning):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4720 self.marginMenuActs["ShowWarning"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4721 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4722 self.marginMenuActs["ShowWarning"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4723 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4724 self.marginMenuActs["NextWarningMarker"].setEnabled(False)
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
4725 self.marginMenuActs["PreviousWarningMarker"].setEnabled(False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4726 self.marginMenuActs["ClearWarnings"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4727 self.marginMenuActs["ShowWarning"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4728
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4729 if self.notcoveredMarkers:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4730 self.marginMenuActs["NextCoverageMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4731 self.marginMenuActs["PreviousCoverageMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4732 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4733 self.marginMenuActs["NextCoverageMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4734 self.marginMenuActs["PreviousCoverageMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4735
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4736 if self.__hasTaskMarkers:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4737 self.marginMenuActs["PreviousTaskMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4738 self.marginMenuActs["NextTaskMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4739 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4740 self.marginMenuActs["PreviousTaskMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4741 self.marginMenuActs["NextTaskMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4742
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
4743 if self.__hasChangeMarkers:
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
4744 self.marginMenuActs["PreviousChangeMarker"].setEnabled(True)
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
4745 self.marginMenuActs["NextChangeMarker"].setEnabled(True)
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
4746 else:
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
4747 self.marginMenuActs["PreviousChangeMarker"].setEnabled(False)
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
4748 self.marginMenuActs["NextChangeMarker"].setEnabled(False)
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
4749
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4750 self.showMenu.emit("Margin", self.sender(), self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4751
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4752 def __showContextMenuChecks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4753 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4754 Private slot handling the aboutToShow signal of the checks context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4755 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4756 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4757 self.showMenu.emit("Checks", self.checksMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4758
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4759 def __contextSave(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4760 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4761 Private slot handling the save context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4762 """
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
4763 ok = self.saveFile()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4764 if ok:
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
4765 self.vm.setEditorName(self, self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4766
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4767 def __contextSaveAs(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4768 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4769 Private slot handling the save as context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4770 """
559
ee695ebbd6e0 Fixed an issue introduced by the E5MessageBox job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
4771 ok = self.saveFileAs()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4772 if ok:
559
ee695ebbd6e0 Fixed an issue introduced by the E5MessageBox job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
4773 self.vm.setEditorName(self, self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4774
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4775 def __contextClose(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4776 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4777 Private slot handling the close context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4778 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4779 self.vm.closeEditor(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4780
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
4781 def __contextOpenRejections(self):
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
4782 """
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
4783 Private slot handling the open rejections file context menu entry.
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
4784 """
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
4785 if self.fileName:
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
4786 rej = "{0}.rej".format(self.fileName)
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
4787 if os.path.exists(rej):
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
4788 self.vm.openSourceFile(rej)
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
4789
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4790 def __newView(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4791 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4792 Private slot to create a new view to an open document.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4793 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4794 self.vm.newEditorView(self.fileName, self, self.filetype)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4795
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4796 def __newViewNewSplit(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4797 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4798 Private slot to create a new view to an open document.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4799 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4800 self.vm.addSplit()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4801 self.vm.newEditorView(self.fileName, self, self.filetype)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4802
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4803 def __selectAll(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4804 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4805 Private slot handling the select all context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4806 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4807 self.selectAll(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4808
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4809 def __deselectAll(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4810 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4811 Private slot handling the deselect all context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4812 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4813 self.selectAll(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4814
478
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4815 def joinLines(self):
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4816 """
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4817 Public slot to join the current line with the next one.
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4818 """
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4819 curLine = self.getCursorPosition()[0]
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4820 if curLine == self.lines() - 1:
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4821 return
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4822
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4823 line0Text = self.text(curLine)
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4824 line1Text = self.text(curLine + 1)
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4825 if line1Text in ["", "\r", "\n", "\r\n"]:
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4826 return
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4827
2994
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4828 if line0Text.rstrip("\r\n\\ \t").endswith(("'", '"')) and \
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4829 line1Text.lstrip().startswith(("'", '"')):
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4830 # merging multi line strings
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4831 startChars = "\r\n\\ \t'\""
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4832 endChars = " \t'\""
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4833 else:
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4834 startChars = "\r\n\\ \t"
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4835 endChars = " \t"
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4836
478
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4837 # determine start index
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4838 startIndex = len(line0Text)
2994
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4839 while startIndex > 0 and line0Text[startIndex - 1] in startChars:
478
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4840 startIndex -= 1
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4841 if startIndex == 0:
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4842 return
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4843
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4844 # determine end index
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4845 endIndex = 0
2994
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
4846 while line1Text[endIndex] in endChars:
478
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4847 endIndex += 1
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4848
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4849 self.setSelection(curLine, startIndex, curLine + 1, endIndex)
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4850 self.beginUndoAction()
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4851 self.removeSelectedText()
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4852 self.insertAt(" ", curLine, startIndex)
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4853 self.endUndoAction()
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
4854
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4855 def shortenEmptyLines(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4856 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4857 Public slot to compress lines consisting solely of whitespace
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4858 characters.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4859 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4860 searchRE = r"^[ \t]+$"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4861
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4862 ok = self.findFirstTarget(searchRE, True, False, False, 0, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4863 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4864 while ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4865 self.replaceTarget("")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4866 ok = self.findNextTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4867 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4868
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4869 def __autosaveEnable(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4870 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4871 Private slot handling the autosave enable context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4872 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4873 if self.menuActs["AutosaveEnable"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4874 self.autosaveManuallyDisabled = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4875 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4876 self.autosaveManuallyDisabled = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4877
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4878 def shouldAutosave(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4879 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4880 Public slot to check the autosave flags.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4881
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4882 @return flag indicating this editor should be saved (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4883 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4884 return self.fileName is not None and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
4885 not self.autosaveManuallyDisabled and \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
4886 not self.isReadOnly()
2571
e6bb19eb87ea Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2526
diff changeset
4887
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4888 def __autoSyntaxCheck(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4889 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4890 Private method to perform an automatic syntax check of the file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4891 """
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
4892 if self.filetype not in self.syntaxCheckService.getLanguages():
2571
e6bb19eb87ea Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2526
diff changeset
4893 return
e6bb19eb87ea Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2526
diff changeset
4894
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4895 if Preferences.getEditor("AutoCheckSyntax"):
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
4896 if Preferences.getEditor("OnlineSyntaxCheck"):
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
4897 self.__onlineSyntaxCheckTimer.stop()
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4898
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
4899 self.syntaxCheckService.syntaxCheck(
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
4900 self.filetype, self.fileName or "(Unnamed)", self.text())
2571
e6bb19eb87ea Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2526
diff changeset
4901
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4902 def __processResult(self, fn, problems):
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4903 """
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4904 Slot to report the resulting messages.
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4905
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4906 @param fn filename of the checked file (str)
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4907 @param problems dictionary with the keys 'error' and 'warnings' which
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4908 hold a list containing details about the error/ warnings
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4909 (file name, line number, column, codestring (only at syntax
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4910 errors), the message) (dict)
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4911 """
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4912 # Check if it's the requested file, otherwise ignore signal
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4913 if fn != self.fileName and (
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4914 self.fileName is not None or fn != "(Unnamed)"):
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4915 return
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4916
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4917 self.clearSyntaxError()
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4918 self.clearFlakesWarnings()
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
4919
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4920 error = problems.get('error')
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4921 if error:
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4922 _fn, lineno, col, code, msg = error
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4923 self.toggleSyntaxError(lineno, col, True, msg)
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4924
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4925 warnings = problems.get('warnings', [])
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4926 for _fn, lineno, col, code, msg in warnings:
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4927 self.toggleWarning(lineno, col, True, msg)
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
4928
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4929 def __initOnlineSyntaxCheck(self):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4930 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4931 Private slot to initialize the online syntax check.
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4932 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4933 self.__onlineSyntaxCheckTimer = QTimer(self)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4934 self.__onlineSyntaxCheckTimer.setSingleShot(True)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4935 self.__onlineSyntaxCheckTimer.setInterval(
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4936 Preferences.getEditor("OnlineSyntaxCheckInterval") * 1000)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4937 self.__onlineSyntaxCheckTimer.timeout.connect(self.__autoSyntaxCheck)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4938 self.textChanged.connect(self.__resetOnlineSyntaxCheckTimer)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4939
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4940 def __resetOnlineSyntaxCheckTimer(self):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4941 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4942 Private method to reset the online syntax check timer.
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4943 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4944 if Preferences.getEditor("OnlineSyntaxCheck"):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4945 self.__onlineSyntaxCheckTimer.stop()
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4946 self.__onlineSyntaxCheckTimer.start()
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4947
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4948 def __showCodeMetrics(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4949 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4950 Private method to handle the code metrics context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4951 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4952 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4953 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4954
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
4955 from DataViews.CodeMetricsDialog import CodeMetricsDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4956 self.codemetrics = CodeMetricsDialog()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4957 self.codemetrics.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4958 self.codemetrics.start(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4959
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4960 def __getCodeCoverageFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4961 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4962 Private method to get the filename of the file containing coverage
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4963 info.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4964
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4965 @return filename of the coverage file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4966 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4967 files = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4968
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4969 # first check if the file belongs to a project and there is
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4970 # a project coverage file
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4971 if self.project.isOpen() and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4972 self.project.isProjectSource(self.fileName):
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
4973 fn = self.project.getMainScript(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4974 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4975 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4976 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4977 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4978
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4979 f = "{0}.coverage".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4980 tf = "{0}.coverage".format(tbasename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4981 if os.path.isfile(f):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4982 files.append(f)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4983 if os.path.isfile(tf):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4984 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4985
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4986 # now check, if there are coverage files belonging to ourself
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4987 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4988 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4989 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4990 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4991 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4992
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4993 f = "{0}.coverage".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
4994 tf = "{0}.coverage".format(tbasename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4995 if os.path.isfile(f) and not f in files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4996 files.append(f)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4997 if os.path.isfile(tf) and not tf in files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4998 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4999
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5000 if files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5001 if len(files) > 1:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5002 fn, ok = QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5003 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5004 self.trUtf8("Code Coverage"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5005 self.trUtf8("Please select a coverage file"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5006 files,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5007 0, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5008 if not ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5009 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5010 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5011 fn = files[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5012 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5013 fn = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5014
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5015 return fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5016
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5017 def __showCodeCoverage(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5018 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5019 Private method to handle the code coverage context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5020 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5021 fn = self.__getCodeCoverageFile()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5022 if fn:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
5023 from DataViews.PyCoverageDialog import PyCoverageDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5024 self.codecoverage = PyCoverageDialog()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5025 self.codecoverage.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5026 self.codecoverage.start(fn, self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5027
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
5028 def refreshCoverageAnnotations(self):
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
5029 """
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
5030 Public method to refresh the code coverage annotations.
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
5031 """
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
5032 if self.showingNotcoveredMarkers:
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
5033 self.codeCoverageShowAnnotations(silent=True)
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
5034
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
5035 def codeCoverageShowAnnotations(self, silent=False):
2163
2b02339f52bf Enhanced the code coverage dialog functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2162
diff changeset
5036 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5037 Public method to handle the show code coverage annotations context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5038 menu action.
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
5039
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
5040 @param silent flag indicating to not show any dialog (boolean)
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
5041 """
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
5042 self.__codeCoverageHideAnnotations()
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
5043
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5044 fn = self.__getCodeCoverageFile()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5045 if fn:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
5046 from DebugClients.Python3.coverage import coverage
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5047 cover = coverage(data_file=fn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5048 cover.use_cache(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5049 cover.load()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5050 missing = cover.analysis2(self.fileName)[3]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5051 if missing:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5052 for line in missing:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5053 handle = self.markerAdd(line - 1, self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5054 self.notcoveredMarkers.append(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5055 self.coverageMarkersShown.emit(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5056 else:
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
5057 if not silent:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5058 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5059 self,
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
5060 self.trUtf8("Show Code Coverage Annotations"),
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
5061 self.trUtf8("""All lines have been covered."""))
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
5062 self.showingNotcoveredMarkers = True
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
5063 else:
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
5064 if not silent:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5065 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5066 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5067 self.trUtf8("Show Code Coverage Annotations"),
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
5068 self.trUtf8("""There is no coverage file available."""))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5069
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5070 def __codeCoverageHideAnnotations(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5071 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5072 Private method to handle the hide code coverage annotations context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5073 menu action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5074 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5075 for handle in self.notcoveredMarkers:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5076 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5077 self.notcoveredMarkers = []
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5078 self.coverageMarkersShown.emit(False)
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
5079 self.showingNotcoveredMarkers = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5080
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5081 def hasCoverageMarkers(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5082 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5083 Public method to test, if there are coverage markers.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
5084
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
5085 @return flag indicating the presence of coverage markers (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5086 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5087 return len(self.notcoveredMarkers) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5088
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5089 def nextUncovered(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5090 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5091 Public slot to handle the 'Next uncovered' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5092 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5093 line, index = self.getCursorPosition()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5094 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5095 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5096 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5097 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5098 ucline = self.markerFindNext(line, 1 << self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5099 if ucline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5100 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5101 ucline = self.markerFindNext(0, 1 << self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5102 if ucline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5103 self.setCursorPosition(ucline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5104 self.ensureLineVisible(ucline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5105
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5106 def previousUncovered(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5107 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5108 Public slot to handle the 'Previous uncovered' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5109 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5110 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5111 if line == 0:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5112 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5113 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5114 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5115 ucline = self.markerFindPrevious(line, 1 << self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5116 if ucline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5117 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5118 ucline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5119 self.lines() - 1, 1 << self.notcovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5120 if ucline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5121 self.setCursorPosition(ucline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5122 self.ensureLineVisible(ucline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5123
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5124 def __showProfileData(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5125 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5126 Private method to handle the show profile data context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5127 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5128 files = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5129
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5130 # first check if the file belongs to a project and there is
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5131 # a project profile file
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5132 if self.project.isOpen() and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5133 self.project.isProjectSource(self.fileName):
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
5134 fn = self.project.getMainScript(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5135 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5136 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5137 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5138 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5139
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5140 f = "{0}.profile".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5141 tf = "{0}.profile".format(tbasename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5142 if os.path.isfile(f):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5143 files.append(f)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5144 if os.path.isfile(tf):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5145 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5146
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5147 # now check, if there are profile files belonging to ourself
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5148 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5149 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5150 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5151 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5152 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5153
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5154 f = "{0}.profile".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5155 tf = "{0}.profile".format(tbasename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5156 if os.path.isfile(f) and not f in files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5157 files.append(f)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5158 if os.path.isfile(tf) and not tf in files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5159 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5160
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5161 if files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5162 if len(files) > 1:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5163 fn, ok = QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5164 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5165 self.trUtf8("Profile Data"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5166 self.trUtf8("Please select a profile file"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5167 files,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5168 0, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5169 if not ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5170 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5171 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5172 fn = files[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5173 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5174 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5175
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
5176 from DataViews.PyProfileDialog import PyProfileDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5177 self.profiledata = PyProfileDialog()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5178 self.profiledata.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5179 self.profiledata.start(fn, self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5180
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5181 def __lmBbookmarks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5182 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5183 Private method to handle the 'LMB toggles bookmark' context menu
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5184 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5185 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5186 self.marginMenuActs["LMBbookmarks"].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5187 self.marginMenuActs["LMBbreakpoints"].setChecked(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5188
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5189 def __lmBbreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5190 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5191 Private method to handle the 'LMB toggles breakpoint' context menu
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5192 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5193 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5194 self.marginMenuActs["LMBbookmarks"].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5195 self.marginMenuActs["LMBbreakpoints"].setChecked(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5196
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5197 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5198 ## Syntax error handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5199 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5200
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5201 def toggleSyntaxError(self, line, index, error, msg="", show=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5202 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5203 Public method to toggle a syntax error indicator.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5204
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5205 @param line line number of the syntax error (integer)
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5206 @param index index number of the syntax error (integer)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5207 @param error flag indicating if the error marker should be
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5208 set or deleted (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5209 @param msg error message (string)
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5210 @keyparam show flag indicating to set the cursor to the error position
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5211 (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5212 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5213 if line == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5214 line = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5215 # hack to show a syntax error marker, if line is reported to be 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5216 if error:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5217 # set a new syntax error marker
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5218 markers = self.markersAtLine(line - 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5219 if not (markers & (1 << self.syntaxerror)):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5220 handle = self.markerAdd(line - 1, self.syntaxerror)
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5221 index += self.indentation(line - 1)
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5222 self.syntaxerrors[handle] = [(msg, index)]
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5223 self.syntaxerrorToggled.emit(self)
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5224 else:
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5225 for handle in list(self.syntaxerrors.keys()):
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5226 if self.markerLine(handle) == line - 1 and \
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5227 (msg, index) not in self.syntaxerrors[handle]:
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5228 self.syntaxerrors[handle].append((msg, index))
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5229 if show:
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5230 self.setCursorPosition(line - 1, index)
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5231 self.ensureLineVisible(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5232 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5233 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5234 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5235 del self.syntaxerrors[handle]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5236 self.markerDeleteHandle(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5237 self.syntaxerrorToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5238
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5239 self.__setAnnotation(line - 1)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5240
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5241 def getSyntaxErrors(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5242 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5243 Public method to retrieve the syntax error markers.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5244
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5245 @return sorted list of all lines containing a syntax error
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5246 (list of integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5247 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5248 selist = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5249 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5250 selist.append(self.markerLine(handle) + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5251
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5252 selist.sort()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5253 return selist
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5254
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5255 def hasSyntaxErrors(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5256 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5257 Public method to check for the presence of syntax errors.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5258
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5259 @return flag indicating the presence of syntax errors (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5260 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5261 return len(self.syntaxerrors) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5262
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5263 def gotoSyntaxError(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5264 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5265 Public slot to handle the 'Goto syntax error' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5266 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5267 seline = self.markerFindNext(0, 1 << self.syntaxerror)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5268 if seline >= 0:
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5269 index = 0
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5270 for handle in self.syntaxerrors.keys():
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5271 if self.markerLine(handle) == seline:
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5272 index = self.syntaxerrors[handle][0][1]
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5273 self.setCursorPosition(seline, index)
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5274 self.ensureLineVisible(seline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5275
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5276 def clearSyntaxError(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5277 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5278 Public slot to handle the 'Clear all syntax error' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5279 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5280 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5281 line = self.markerLine(handle) + 1
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5282 self.toggleSyntaxError(line, 0, False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5283
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5284 def __showSyntaxError(self, line=-1):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5285 """
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5286 Private slot to handle the 'Show syntax error message'
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5287 context menu action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5288
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5289 @param line line number to show the syntax error for (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5290 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5291 if line == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5292 line = self.line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5293
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5294 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5295 if self.markerLine(handle) == line:
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5296 errors = [e[0] for e in self.syntaxerrors[handle]]
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5297 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5298 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5299 self.trUtf8("Syntax Error"),
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5300 "\n".join(errors))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5301 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5302 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5303 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5304 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5305 self.trUtf8("Syntax Error"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5306 self.trUtf8("No syntax error message available."))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5307
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5308 ###########################################################################
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5309 ## Warning handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5310 ###########################################################################
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5311
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
5312 def toggleWarning(
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
5313 self, line, col, warning, msg="", warningType=WarningCode):
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5314 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5315 Public method to toggle a warning indicator.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5316
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5317 Note: This method is used to set pyflakes and code style warnings.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5318
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5319 @param line line number of the warning
3412
9364dab2d472 Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3241
diff changeset
5320 @param col column of the warning
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
5321 @param warning flag indicating if the warning marker should be
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5322 set or deleted (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5323 @param msg warning message (string)
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5324 @keyparam warningType type of warning message (integer)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5325 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5326 if line == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5327 line = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5328 # hack to show a warning marker, if line is reported to be 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5329 if warning:
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5330 # set/amend a new warning marker
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5331 warn = (msg, warningType)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5332 markers = self.markersAtLine(line - 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5333 if not (markers & (1 << self.warning)):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5334 handle = self.markerAdd(line - 1, self.warning)
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5335 self.warnings[handle] = [warn]
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5336 self.syntaxerrorToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5337 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5338 for handle in list(self.warnings.keys()):
95
261bc03812fd Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 92
diff changeset
5339 if self.markerLine(handle) == line - 1 and \
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5340 warn not in self.warnings[handle]:
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5341 self.warnings[handle].append(warn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5342 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5343 for handle in list(self.warnings.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5344 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5345 del self.warnings[handle]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5346 self.markerDeleteHandle(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5347 self.syntaxerrorToggled.emit(self)
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5348
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5349 self.__setAnnotation(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5350
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5351 def getWarnings(self):
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5352 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5353 Public method to retrieve the warning markers.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5354
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5355 @return sorted list of all lines containing a warning
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5356 (list of integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5357 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5358 fwlist = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5359 for handle in list(self.warnings.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5360 fwlist.append(self.markerLine(handle) + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5361
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5362 fwlist.sort()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5363 return fwlist
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5364
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5365 def hasWarnings(self):
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5366 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5367 Public method to check for the presence of warnings.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5368
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5369 @return flag indicating the presence of warnings (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5370 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5371 return len(self.warnings) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5372
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5373 def nextWarning(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5374 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5375 Public slot to handle the 'Next warning' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5376 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5377 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5378 if line == self.lines() - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5379 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5380 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5381 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5382 fwline = self.markerFindNext(line, 1 << self.warning)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5383 if fwline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5384 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5385 fwline = self.markerFindNext(0, 1 << self.warning)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5386 if fwline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5387 self.setCursorPosition(fwline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5388 self.ensureLineVisible(fwline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5389
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5390 def previousWarning(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5391 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5392 Public slot to handle the 'Previous warning' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5393 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5394 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5395 if line == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5396 line = self.lines() - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5397 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5398 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5399 fwline = self.markerFindPrevious(line, 1 << self.warning)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5400 if fwline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5401 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5402 fwline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5403 self.lines() - 1, 1 << self.warning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5404 if fwline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5405 self.setCursorPosition(fwline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5406 self.ensureLineVisible(fwline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5407
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5408 def clearFlakesWarnings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5409 """
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5410 Public slot to clear all pyflakes warnings.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5411 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5412 self.__clearTypedWarning(Editor.WarningCode)
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5413
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5414 def clearStyleWarnings(self):
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5415 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5416 Public slot to clear all style warnings.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5417 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5418 self.__clearTypedWarning(Editor.WarningStyle)
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5419
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5420 def __clearTypedWarning(self, warningKind):
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5421 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5422 Public method to clear warnings of a specific kind.
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5423
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5424 @param warningKind kind of warning to clear (Editor.WarningCode,
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5425 Editor.WarningStyle)
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5426 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5427 assert warningKind in [Editor.WarningCode, Editor.WarningStyle]
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5428
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5429 for handle in list(self.warnings.keys()):
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5430 warnings = []
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5431 for msg, warningType in self.warnings[handle]:
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5432 if warningType == warningKind:
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5433 continue
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5434
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5435 warnings.append((msg, warningType))
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5436
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5437 if warnings:
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5438 self.warnings[handle] = warnings
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5439 self.__setAnnotation(self.markerLine(handle))
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5440 else:
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5441 del self.warnings[handle]
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5442 self.__setAnnotation(self.markerLine(handle))
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5443 self.markerDeleteHandle(handle)
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5444 self.syntaxerrorToggled.emit(self)
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5445
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5446 def clearWarnings(self):
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5447 """
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5448 Public slot to clear all warnings.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5449 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5450 for handle in self.warnings:
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5451 self.warnings[handle] = []
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5452 self.__setAnnotation(self.markerLine(handle))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5453 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5454 self.warnings = {}
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5455 self.syntaxerrorToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5456
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5457 def __showWarning(self, line=-1):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5458 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5459 Private slot to handle the 'Show warning' context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5460
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5461 @param line line number to show the warning for (integer)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5462 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5463 if line == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5464 line = self.line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5465
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5466 for handle in list(self.warnings.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5467 if self.markerLine(handle) == line:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5468 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5469 self,
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5470 self.trUtf8("Warning"),
2955
e9aeafe80329 Fixed an issue in the editor showing warning messages via the margin.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2926
diff changeset
5471 '\n'.join([w[0] for w in self.warnings[handle]]))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5472 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5473 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5474 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5475 self,
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5476 self.trUtf8("Warning"),
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5477 self.trUtf8("No warning messages available."))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5478
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5479 ###########################################################################
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5480 ## Annotation handling methods below
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5481 ###########################################################################
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5482
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5483 def __setAnnotationStyles(self):
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5484 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5485 Private slot to define the style used by inline annotations.
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5486 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5487 if hasattr(QsciScintilla, "annotate"):
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5488 self.annotationWarningStyle = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5489 QsciScintilla.STYLE_LASTPREDEFINED + 1
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5490 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5491 QsciScintilla.SCI_STYLESETFORE,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5492 self.annotationWarningStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5493 Preferences.getEditorColour("AnnotationsWarningForeground"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5494 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5495 QsciScintilla.SCI_STYLESETBACK,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5496 self.annotationWarningStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5497 Preferences.getEditorColour("AnnotationsWarningBackground"))
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5498
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5499 self.annotationErrorStyle = self.annotationWarningStyle + 1
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5500 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5501 QsciScintilla.SCI_STYLESETFORE,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5502 self.annotationErrorStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5503 Preferences.getEditorColour("AnnotationsErrorForeground"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5504 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5505 QsciScintilla.SCI_STYLESETBACK,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5506 self.annotationErrorStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5507 Preferences.getEditorColour("AnnotationsErrorBackground"))
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5508
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5509 self.annotationStyleStyle = self.annotationErrorStyle + 1
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5510 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5511 QsciScintilla.SCI_STYLESETFORE,
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5512 self.annotationStyleStyle,
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5513 Preferences.getEditorColour("AnnotationsStyleForeground"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5514 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5515 QsciScintilla.SCI_STYLESETBACK,
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5516 self.annotationStyleStyle,
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5517 Preferences.getEditorColour("AnnotationsStyleBackground"))
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5518
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5519 def __setAnnotation(self, line):
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5520 """
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5521 Private method to set the annotations for the given line.
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5522
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5523 @param line number of the line that needs annotation (integer)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5524 """
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5525 if hasattr(QsciScintilla, "annotate"):
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5526 warningAnnotations = []
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5527 errorAnnotations = []
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5528 styleAnnotations = []
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5529
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5530 # step 1: do warnings
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5531 for handle in self.warnings.keys():
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5532 if self.markerLine(handle) == line:
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5533 for msg, warningType in self.warnings[handle]:
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5534 if warningType == self.WarningStyle:
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5535 styleAnnotations.append(
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5536 self.trUtf8("Style: {0}").format(msg))
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5537 else:
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5538 warningAnnotations.append(
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5539 self.trUtf8("Warning: {0}").format(msg))
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5540
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5541 # step 2: do syntax errors
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
5542 for handle in self.syntaxerrors.keys():
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5543 if self.markerLine(handle) == line:
2904
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5544 for msg, _ in self.syntaxerrors[handle]:
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5545 errorAnnotations.append(
1da821da961e Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2900
diff changeset
5546 self.trUtf8("Error: {0}").format(msg))
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5547
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5548 annotations = []
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5549 if styleAnnotations:
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5550 annotationStyleTxt = "\n".join(styleAnnotations)
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5551 if warningAnnotations or errorAnnotations:
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5552 annotationStyleTxt += "\n"
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
5553 annotations.append(QsciStyledText(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
5554 annotationStyleTxt, self.annotationStyleStyle))
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
5555
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5556 if warningAnnotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5557 annotationWarningTxt = "\n".join(warningAnnotations)
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5558 if errorAnnotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5559 annotationWarningTxt += "\n"
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
5560 annotations.append(QsciStyledText(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
5561 annotationWarningTxt, self.annotationWarningStyle))
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5562
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5563 if errorAnnotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5564 annotationErrorTxt = "\n".join(errorAnnotations)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
5565 annotations.append(QsciStyledText(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
5566 annotationErrorTxt, self.annotationErrorStyle))
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5567
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5568 if annotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5569 self.annotate(line, annotations)
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5570 else:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5571 self.clearAnnotations(line)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5572
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5573 def __refreshAnnotations(self):
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5574 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5575 Private method to refresh the annotations.
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5576 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5577 if hasattr(QsciScintilla, "annotate"):
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5578 self.clearAnnotations()
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5579 for handle in list(self.warnings.keys()) + \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5580 list(self.syntaxerrors.keys()):
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5581 line = self.markerLine(handle)
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5582 self.__setAnnotation(line)
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
5583
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5584 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5585 ## Macro handling methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5586 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5587
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5588 def __getMacroName(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5589 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5590 Private method to select a macro name from the list of macros.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5591
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5592 @return Tuple of macro name and a flag, indicating, if the user
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5593 pressed ok or canceled the operation. (string, boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5594 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5595 qs = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5596 for s in list(self.macros.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5597 qs.append(s)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5598 qs.sort()
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5599 return QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5600 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5601 self.trUtf8("Macro Name"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5602 self.trUtf8("Select a macro name:"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5603 qs,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5604 0, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5605
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5606 def macroRun(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5607 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5608 Public method to execute a macro.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5609 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5610 name, ok = self.__getMacroName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5611 if ok and name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5612 self.macros[name].play()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5613
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5614 def macroDelete(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5615 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5616 Public method to delete a macro.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5617 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5618 name, ok = self.__getMacroName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5619 if ok and name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5620 del self.macros[name]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5621
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5622 def macroLoad(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5623 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5624 Public method to load a macro from a file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5625 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5626 configDir = Utilities.getConfigDir()
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
5627 fname = E5FileDialog.getOpenFileName(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5628 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5629 self.trUtf8("Load macro file"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5630 configDir,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
5631 self.trUtf8("Macro files (*.macro)"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5632
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5633 if not fname:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5634 return # user aborted
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5635
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5636 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5637 f = open(fname, "r", encoding="utf-8")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5638 lines = f.readlines()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5639 f.close()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5640 except IOError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5641 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5642 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5643 self.trUtf8("Error loading macro"),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5644 self.trUtf8(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5645 "<p>The macro file <b>{0}</b> could not be read.</p>")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
5646 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5647 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5648
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5649 if len(lines) != 2:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5650 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5651 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5652 self.trUtf8("Error loading macro"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5653 self.trUtf8("<p>The macro file <b>{0}</b> is corrupt.</p>")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
5654 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5655 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5656
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5657 macro = QsciMacro(lines[1], self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5658 self.macros[lines[0].strip()] = macro
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5659
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5660 def macroSave(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5661 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5662 Public method to save a macro to a file.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5663 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5664 configDir = Utilities.getConfigDir()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5665
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5666 name, ok = self.__getMacroName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5667 if not ok or not name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5668 return # user abort
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5669
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
5670 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5671 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5672 self.trUtf8("Save macro file"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5673 configDir,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5674 self.trUtf8("Macro files (*.macro)"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5675 "",
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
5676 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5677
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5678 if not fname:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5679 return # user aborted
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5680
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5681 ext = QFileInfo(fname).suffix()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5682 if not ext:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5683 ex = selectedFilter.split("(*")[1].split(")")[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5684 if ex:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5685 fname += ex
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5686 if QFileInfo(fname).exists():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5687 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5688 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5689 self.trUtf8("Save macro"),
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
5690 self.trUtf8("<p>The macro file <b>{0}</b> already exists."
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
5691 " Overwrite it?</p>").format(fname),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5692 icon=E5MessageBox.Warning)
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
5693 if not res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5694 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5695 fname = Utilities.toNativeSeparators(fname)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5696
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5697 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5698 f = open(fname, "w", encoding="utf-8")
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5699 f.write("{0}{1}".format(name, "\n"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5700 f.write(self.macros[name].save())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5701 f.close()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5702 except IOError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5703 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5704 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5705 self.trUtf8("Error saving macro"),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5706 self.trUtf8(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5707 "<p>The macro file <b>{0}</b> could not be written.</p>")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
5708 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5709 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5710
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5711 def macroRecordingStart(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5712 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5713 Public method to start macro recording.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5714 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5715 if self.recording:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5716 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5717 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5718 self.trUtf8("Start Macro Recording"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5719 self.trUtf8("Macro recording is already active. Start new?"),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5720 icon=E5MessageBox.Warning,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5721 yesDefault=True)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
5722 if res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5723 self.macroRecordingStop()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5724 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5725 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5726 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5727 self.recording = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5728
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5729 self.curMacro = QsciMacro(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5730 self.curMacro.startRecording()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5731
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5732 def macroRecordingStop(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5733 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5734 Public method to stop macro recording.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5735 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5736 if not self.recording:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5737 return # we are not recording
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5738
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5739 self.curMacro.endRecording()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5740 self.recording = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5741
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5742 name, ok = QInputDialog.getText(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5743 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5744 self.trUtf8("Macro Recording"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5745 self.trUtf8("Enter name of the macro:"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5746 QLineEdit.Normal)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5747
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5748 if ok and name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5749 self.macros[name] = self.curMacro
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5750
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5751 self.curMacro = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5752
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5753 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5754 ## Overwritten methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5755 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5756
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5757 def undo(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5758 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5759 Public method to undo the last recorded change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5760 """
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
5761 super(Editor, self).undo()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5762 self.undoAvailable.emit(self.isUndoAvailable())
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5763 self.redoAvailable.emit(self.isRedoAvailable())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5764
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5765 def redo(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5766 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5767 Public method to redo the last recorded change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5768 """
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
5769 super(Editor, self).redo()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5770 self.undoAvailable.emit(self.isUndoAvailable())
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5771 self.redoAvailable.emit(self.isRedoAvailable())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5772
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5773 def close(self, alsoDelete=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5774 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5775 Public method called when the window gets closed.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5776
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5777 This overwritten method redirects the action to our
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5778 ViewManager.closeEditor, which in turn calls our closeIt
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5779 method.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5780
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5781 @param alsoDelete ignored
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
5782 @return flag indicating a successful close of the editor (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5783 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5784 return self.vm.closeEditor(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5785
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5786 def closeIt(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5787 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5788 Public method called by the viewmanager to finally get rid of us.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5789 """
1930
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
5790 if Preferences.getEditor("ClearBreaksOnClose") and not self.__clones:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5791 self.__menuClearBreakpoints()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5792
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5793 for clone in self.__clones[:]:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5794 self.removeClone(clone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5795 clone.removeClone(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5796
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
5797 self.breakpointModel.rowsAboutToBeRemoved.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5798 self.__deleteBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
5799 self.breakpointModel.dataAboutToBeChanged.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5800 self.__breakPointDataAboutToBeChanged)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
5801 self.breakpointModel.dataChanged.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5802 self.__changeBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
5803 self.breakpointModel.rowsInserted.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5804 self.__addBreakPoints)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5805
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
5806 self.syntaxCheckService.syntaxChecked.disconnect(self.__processResult)
3173
1fb284abe46e Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3145
diff changeset
5807
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5808 if self.spell:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5809 self.spell.stopIncrementalCheck()
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
5810
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
5811 try:
507
23652b3a0533 Fixed an issue with not connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 502
diff changeset
5812 self.project.projectPropertiesChanged.disconnect(
23652b3a0533 Fixed an issue with not connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 502
diff changeset
5813 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
5814 except TypeError:
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
5815 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5816
1406
e2f1634cceed Fixed an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1373
diff changeset
5817 if self.fileName:
e2f1634cceed Fixed an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1373
diff changeset
5818 self.taskViewer.clearFileTasks(self.fileName, True)
1373
b3b3c99dba01 Made tasks manager forget about global file tasks when file is closed (configurable via configuration dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1353
diff changeset
5819
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
5820 super(Editor, self).close()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5821
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5822 def keyPressEvent(self, ev):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5823 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5824 Re-implemented to handle the user input a key at a time.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5825
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5826 @param ev key event (QKeyEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5827 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5828 txt = ev.text()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5829
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5830 # See it is text to insert.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5831 if len(txt) and txt >= " ":
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
5832 super(Editor, self).keyPressEvent(ev)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5833 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5834 ev.ignore()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5835
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5836 def focusInEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5837 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5838 Protected method called when the editor receives focus.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5839
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5840 This method checks for modifications of the current file and
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5841 rereads it upon request. The cursor is placed at the current position
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5842 assuming, that it is in the vicinity of the old position after the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5843 reread.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5844
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5845 @param event the event object (QFocusEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5846 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5847 self.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5848 self.vm.editActGrp.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5849 self.vm.editorActGrp.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5850 self.vm.copyActGrp.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5851 self.vm.viewActGrp.setEnabled(True)
128
13e96bd0f5a5 Fixed an issue with handling the focus and (de-)activation of actions as it changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 115
diff changeset
5852 self.vm.searchActGrp.setEnabled(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5853 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5854 self.setCaretWidth(self.caretWidth)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5855 except AttributeError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5856 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5857 self.__updateReadOnly(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5858 if self.vm.editorsCheckFocusInEnabled() and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5859 not self.inReopenPrompt and self.fileName and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5860 QFileInfo(self.fileName).lastModified().toString() != \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5861 self.lastModified.toString():
1831
2dd263d670ca Fixed an issue in the editor that can lead to an endless loop.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
5862 self.inReopenPrompt = True
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5863 if Preferences.getEditor("AutoReopen") and not self.isModified():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5864 self.refresh()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5865 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5866 msg = self.trUtf8(
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5867 """<p>The file <b>{0}</b> has been changed while it"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5868 """ was opened in eric5. Reread it?</p>""")\
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5869 .format(self.fileName)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
5870 yesDefault = True
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5871 if self.isModified():
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5872 msg += self.trUtf8(
929
ed471c1f23b8 Fixed a typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
5873 """<br><b>Warning:</b> You will lose"""
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5874 """ your changes upon reopening it.""")
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
5875 yesDefault = False
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5876 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5877 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5878 self.trUtf8("File changed"), msg,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5879 icon=E5MessageBox.Warning,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5880 yesDefault=yesDefault)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
5881 if res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5882 self.refresh()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5883 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5884 # do not prompt for this change again...
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5885 self.lastModified = QFileInfo(self.fileName).lastModified()
1831
2dd263d670ca Fixed an issue in the editor that can lead to an endless loop.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
5886 self.inReopenPrompt = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5887
404
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
5888 self.setCursorFlashTime(QApplication.cursorFlashTime())
44a541bea034 Added code to adjust the cursor flash time of the editor to the global settings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 342
diff changeset
5889
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
5890 super(Editor, self).focusInEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5891
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5892 def focusOutEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5893 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5894 Public method called when the editor loses focus.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5895
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5896 @param event the event object (QFocusEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5897 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5898 self.vm.editorActGrp.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5899 self.setCaretWidth(0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5900
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
5901 super(Editor, self).focusOutEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5902
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5903 def changeEvent(self, evt):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5904 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5905 Protected method called to process an event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5906
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5907 This implements special handling for the events showMaximized,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5908 showMinimized and showNormal. The windows caption is shortened
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5909 for the minimized mode and reset to the full filename for the
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5910 other modes. This is to make the editor windows work nicer
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5911 with the QWorkspace.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5912
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5913 @param evt the event, that was generated (QEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5914 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5915 if evt.type() == QEvent.WindowStateChange and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5916 self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5917 if self.windowState() == Qt.WindowStates(Qt.WindowMinimized):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5918 cap = os.path.basename(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5919 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5920 cap = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5921 if self.isReadOnly():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5922 cap = self.trUtf8("{0} (ro)").format(cap)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5923 self.setWindowTitle(cap)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5924
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
5925 super(Editor, self).changeEvent(evt)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5926
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5927 def mousePressEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5928 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5929 Protected method to handle the mouse press event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5930
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5931 @param event the mouse press event (QMouseEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5932 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5933 self.vm.eventFilter(self, event)
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
5934 super(Editor, self).mousePressEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5935
1507
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5936 def wheelEvent(self, evt):
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5937 """
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5938 Protected method to handle wheel events.
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5939
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5940 @param evt reference to the wheel event (QWheelEvent)
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5941 """
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5942 if evt.modifiers() & Qt.ControlModifier:
1588
dccffd13be8d Did some PEP-8 related corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1566
diff changeset
5943 if evt.delta() < 0:
1507
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5944 self.zoomOut()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5945 else:
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5946 self.zoomIn()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5947 evt.accept()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5948 return
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5949
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5950 if evt.modifiers() & Qt.ShiftModifier:
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5951 if evt.delta() < 0:
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5952 self.gotoMethodClass(False)
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5953 else:
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5954 self.gotoMethodClass(True)
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5955 evt.accept()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5956 return
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5957
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
5958 super(Editor, self).wheelEvent(evt)
1507
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
5959
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
5960 def event(self, evt):
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
5961 """
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
5962 Protected method handling events.
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
5963
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
5964 @param evt reference to the event (QEvent)
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
5965 @return flag indicating, if the event was handled (boolean)
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
5966 """
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
5967 if evt.type() == QEvent.Gesture:
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
5968 self.gestureEvent(evt)
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
5969 return True
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
5970
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
5971 return super(Editor, self).event(evt)
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
5972
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
5973 def gestureEvent(self, evt):
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
5974 """
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
5975 Protected method handling gesture events.
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
5976
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
5977 @param evt reference to the gesture event (QGestureEvent
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
5978 """
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
5979 pinch = evt.gesture(Qt.PinchGesture)
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
5980 if pinch:
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
5981 if pinch.state() == Qt.GestureStarted:
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
5982 zoom = (self.getZoom() + 10) / 10.0
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
5983 pinch.setScaleFactor(zoom)
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
5984 else:
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
5985 zoom = int(pinch.scaleFactor() * 10) - 10
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
5986 if zoom <= -9:
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
5987 zoom = -9
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
5988 pinch.setScaleFactor(0.1)
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
5989 elif zoom >= 20:
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
5990 zoom = 20
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
5991 pinch.setScaleFactor(3.0)
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
5992 self.zoomTo(zoom)
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
5993 evt.accept()
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
5994
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5995 def __updateReadOnly(self, bForce=True):
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5996 """
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5997 Private method to update the readOnly information for this editor.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5998
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5999 If bForce is True, then updates everything regardless if
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6000 the attributes have actually changed, such as during
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6001 initialization time. A signal is emitted after the
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6002 caption change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6003
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6004 @param bForce True to force change, False to only update and emit
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6005 signal if there was an attribute change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6006 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6007 if self.fileName is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6008 return
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6009 readOnly = not QFileInfo(self.fileName).isWritable() or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6010 self.isReadOnly()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6011 if not bForce and (readOnly == self.isReadOnly()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6012 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6013 cap = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6014 if readOnly:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6015 cap = self.trUtf8("{0} (ro)".format(cap))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6016 self.setReadOnly(readOnly)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6017 self.setWindowTitle(cap)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6018 self.captionChanged.emit(cap, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6019
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6020 def refresh(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6021 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6022 Public slot to refresh the editor contents.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6023 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6024 # save cursor position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6025 cline, cindex = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6026
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6027 # save bookmarks and breakpoints and clear them
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6028 bmlist = self.getBookmarks()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6029 self.clearBookmarks()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6030
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6031 # clear syntax error markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6032 self.clearSyntaxError()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6033
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6034 # clear flakes warning markers
3062
9de9373da5bb Extended the editor warning messages handling and refactored the names of warning handling methods to reflect their more general use.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3059
diff changeset
6035 self.clearWarnings()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6036
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6037 # clear breakpoint markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6038 for handle in list(self.breaks.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6039 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6040 self.breaks = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6041
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6042 # reread the file
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6043 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6044 self.readFile(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6045 except IOError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6046 # do not prompt for this change again...
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6047 self.lastModified = QDateTime.currentDateTime()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6048 self.setModified(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6049
2189
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
6050 # re-initialize the online change tracer
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
6051 self.__reinitOnlineChangeTrace()
5149cec53130 Fixed an issue in the editor related to not re-initializing the online change tracer after a file has been refreshed (reread after an external change).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2165
diff changeset
6052
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6053 # reset cursor position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6054 self.setCursorPosition(cline, cindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6055 self.ensureCursorVisible()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6056
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6057 # reset bookmarks and breakpoints to their old position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6058 if bmlist:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6059 for bm in bmlist:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6060 self.toggleBookmark(bm)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6061 self.__restoreBreakpoints()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6062
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6063 self.editorSaved.emit(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6064 self.__autoSyntaxCheck()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6065
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
6066 self.refreshed.emit()
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
6067
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6068 def setMonospaced(self, on):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6069 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6070 Public method to set/reset a monospaced font.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6071
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6072 @param on flag to indicate usage of a monospace font (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6073 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6074 if on:
3087
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
6075 if not self.lexer_:
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
6076 f = Preferences.getEditorOtherFonts("MonospacedFont")
fdbce259929f Changed the handling of the monospace font usage in the editor, mini editor and shell.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
6077 self.monospacedStyles(f)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6078 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6079 if not self.lexer_:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6080 self.clearStyles()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6081 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6082 self.setFont(Preferences.getEditorOtherFonts("DefaultFont"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6083
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6084 self.useMonospaced = on
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6085
3095
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6086 def clearStyles(self):
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6087 """
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6088 Public method to set the styles according the selected Qt style
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6089 or the selected editor colours.
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6090 """
3142
55030c09e142 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3080 3100
diff changeset
6091 super(Editor, self).clearStyles()
3095
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6092 if Preferences.getEditor("OverrideEditAreaColours"):
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6093 self.setColor(Preferences.getEditorColour("EditAreaForeground"))
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6094 self.setPaper(Preferences.getEditorColour("EditAreaBackground"))
72938a6d5047 Fixed a bug preventing overriding the editor foreground and background colors, when a lexer was set to None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3087
diff changeset
6095
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6096 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6097 ## Drag and Drop Support
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6098 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6099
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6100 def dragEnterEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6101 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6102 Protected method to handle the drag enter event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6103
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6104 @param event the drag enter event (QDragEnterEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6105 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6106 self.inDragDrop = event.mimeData().hasUrls()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6107 if self.inDragDrop:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6108 event.acceptProposedAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6109 else:
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
6110 super(Editor, self).dragEnterEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6111
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6112 def dragMoveEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6113 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6114 Protected method to handle the drag move event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6115
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6116 @param event the drag move event (QDragMoveEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6117 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6118 if self.inDragDrop:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6119 event.accept()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6120 else:
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
6121 super(Editor, self).dragMoveEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6122
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6123 def dragLeaveEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6124 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6125 Protected method to handle the drag leave event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6126
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6127 @param event the drag leave event (QDragLeaveEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6128 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6129 if self.inDragDrop:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6130 self.inDragDrop = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6131 event.accept()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6132 else:
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
6133 super(Editor, self).dragLeaveEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6134
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6135 def dropEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6136 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6137 Protected method to handle the drop event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6138
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6139 @param event the drop event (QDropEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6140 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6141 if event.mimeData().hasUrls():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6142 for url in event.mimeData().urls():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6143 fname = url.toLocalFile()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6144 if fname:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6145 if not QFileInfo(fname).isDir():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6146 self.vm.openSourceFile(fname)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6147 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6148 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6149 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6150 self.trUtf8("Drop Error"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6151 self.trUtf8("""<p><b>{0}</b> is not a file.</p>""")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
6152 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6153 event.acceptProposedAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6154 else:
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
6155 super(Editor, self).dropEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6156
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6157 self.inDragDrop = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6158
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6159 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6160 ## Support for Qt resources files
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6161 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6162
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6163 def __initContextMenuResources(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6164 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6165 Private method used to setup the Resources 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
6166
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
6167 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6168 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6169 menu = QMenu(self.trUtf8('Resources'))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6170
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6171 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6172 self.trUtf8('Add file...'), self.__addFileResource)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6173 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6174 self.trUtf8('Add files...'), self.__addFileResources)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6175 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6176 self.trUtf8('Add aliased file...'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6177 self.__addFileAliasResource)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6178 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6179 self.trUtf8('Add localized resource...'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6180 self.__addLocalizedResource)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6181 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6182 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6183 self.trUtf8('Add resource frame'), self.__addResourceFrame)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6184
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
6185 menu.aboutToShow.connect(self.__showContextMenuResources)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6186
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6187 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6188
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6189 def __showContextMenuResources(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6190 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6191 Private slot handling the aboutToShow signal of the resources context
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6192 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6193 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6194 self.showMenu.emit("Resources", self.resourcesMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6195
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6196 def __addFileResource(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6197 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6198 Private method to handle the Add file context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6199 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6200 dirStr = os.path.dirname(self.fileName)
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6201 file = E5FileDialog.getOpenFileName(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6202 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6203 self.trUtf8("Add file resource"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6204 dirStr,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6205 "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6206 if file:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6207 relFile = QDir(dirStr).relativeFilePath(file)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6208 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6209 self.insert(" <file>{0}</file>\n".format(relFile))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6210 self.setCursorPosition(line + 1, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6211
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6212 def __addFileResources(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6213 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6214 Private method to handle the Add files context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6215 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6216 dirStr = os.path.dirname(self.fileName)
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6217 files = E5FileDialog.getOpenFileNames(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6218 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6219 self.trUtf8("Add file resources"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6220 dirStr,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6221 "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6222 if files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6223 myDir = QDir(dirStr)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6224 filesText = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6225 for file in files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6226 relFile = myDir.relativeFilePath(file)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6227 filesText += " <file>{0}</file>\n".format(relFile)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6228 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6229 self.insert(filesText)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6230 self.setCursorPosition(line + len(files), index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6231
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6232 def __addFileAliasResource(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6233 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6234 Private method to handle the Add aliased file context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6235 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6236 dirStr = os.path.dirname(self.fileName)
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6237 file = E5FileDialog.getOpenFileName(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6238 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6239 self.trUtf8("Add aliased file resource"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6240 dirStr,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6241 "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6242 if file:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6243 relFile = QDir(dirStr).relativeFilePath(file)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
6244 alias, ok = QInputDialog.getText(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6245 self,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6246 self.trUtf8("Add aliased file resource"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6247 self.trUtf8("Alias for file <b>{0}</b>:").format(relFile),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6248 QLineEdit.Normal,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6249 relFile)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6250 if ok and alias:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6251 line, index = self.getCursorPosition()
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
6252 self.insert(' <file alias="{1}">{0}</file>\n'
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6253 .format(relFile, alias))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6254 self.setCursorPosition(line + 1, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6255
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6256 def __addLocalizedResource(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6257 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6258 Private method to handle the Add localized resource context menu
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6259 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6260 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6261 from Project.AddLanguageDialog import AddLanguageDialog
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6262 dlg = AddLanguageDialog(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6263 if dlg.exec_() == QDialog.Accepted:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6264 lang = dlg.getSelectedLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6265 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6266 self.insert('<qresource lang="{0}">\n</qresource>\n'.format(lang))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6267 self.setCursorPosition(line + 2, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6268
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6269 def __addResourceFrame(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6270 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6271 Private method to handle the Add resource frame context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6272 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6273 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6274 self.insert('<!DOCTYPE RCC>\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6275 '<RCC version="1.0">\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6276 '<qresource>\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6277 '</qresource>\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6278 '</RCC>\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6279 self.setCursorPosition(line + 5, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6280
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6281 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6282 ## Support for diagrams below
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6283 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6284
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6285 def __showClassDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6286 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6287 Private method to handle the Class Diagram context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6288 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6289 from Graphics.UMLDialog import UMLDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6290 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6291 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6292
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6293 self.classDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6294 UMLDialog.ClassDiagram, self.project, self.fileName,
2025
8bb085c59cd2 Changed the diagrams to show a better diagram title when printed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1978
diff changeset
6295 self, noAttrs=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6296 self.classDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6297
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6298 def __showPackageDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6299 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6300 Private method to handle the Package Diagram context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6301 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6302 from Graphics.UMLDialog import UMLDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6303 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6304 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6305
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6306 package = os.path.isdir(self.fileName) and \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6307 self.fileName or os.path.dirname(self.fileName)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6308 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6309 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6310 self.trUtf8("Package Diagram"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6311 self.trUtf8("""Include class attributes?"""),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6312 yesDefault=True)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6313 self.packageDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6314 UMLDialog.PackageDiagram, self.project, package,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6315 self, noAttrs=not res)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6316 self.packageDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6317
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6318 def __showImportsDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6319 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6320 Private method to handle the Imports Diagram context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6321 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6322 from Graphics.UMLDialog import UMLDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6323 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6324 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6325
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6326 package = os.path.isdir(self.fileName) and self.fileName \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6327 or os.path.dirname(self.fileName)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6328 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6329 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6330 self.trUtf8("Imports Diagram"),
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
6331 self.trUtf8("""Include imports from external modules?"""))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6332 self.importsDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6333 UMLDialog.ImportsDiagram, self.project, package,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6334 self, showExternalImports=res)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6335 self.importsDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6336
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6337 def __showApplicationDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6338 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6339 Private method to handle the Imports Diagram context menu action.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6340 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6341 from Graphics.UMLDialog import UMLDialog
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6342 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6343 self,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6344 self.trUtf8("Application Diagram"),
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6345 self.trUtf8("""Include module names?"""),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6346 yesDefault=True)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6347 self.applicationDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6348 UMLDialog.ApplicationDiagram, self.project,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6349 self, noModules=not res)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6350 self.applicationDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6351
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6352 def __loadDiagram(self):
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6353 """
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6354 Private slot to load a diagram from file.
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6355 """
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6356 from Graphics.UMLDialog import UMLDialog
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6357 self.loadedDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6358 UMLDialog.NoDiagram, self.project, parent=self)
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6359 if self.loadedDiagram.load():
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6360 self.loadedDiagram.show(fromFile=True)
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6361 else:
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6362 self.loadedDiagram = None
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6363
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6364 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6365 ## Typing aids related methods below
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6366 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6367
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6368 def __toggleTypingAids(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6369 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6370 Private slot to toggle the typing aids.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6371 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6372 if self.menuActs["TypingAidsEnabled"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6373 self.completer.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6374 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6375 self.completer.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6376
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6377 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6378 ## Autocompleting templates
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6379 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6380
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6381 def editorCommand(self, cmd):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6382 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6383 Public method to perform a simple editor command.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6384
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6385 @param cmd the scintilla command to be performed
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6386 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6387 if cmd == QsciScintilla.SCI_TAB:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6388 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6389 tmplName = self.getWordLeft(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6390 if tmplName:
1002
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6391 if e5App().getObject("TemplateViewer").hasTemplate(
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6392 tmplName, self.getLanguage()):
1723
6e690a8f5971 Fixed an issue in the editor applying templates.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
6393 self.__applyTemplate(tmplName, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6394 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6395 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6396 templateNames = \
1002
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6397 e5App().getObject("TemplateViewer").getTemplateNames(
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6398 tmplName, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6399 if len(templateNames) == 1:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6400 self.__applyTemplate(templateNames[0],
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6401 self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6402 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6403 elif len(templateNames) > 1:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6404 self.showUserList(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6405 TemplateCompletionListID,
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
6406 ["{0}?{1:d}".format(t, self.TemplateImageID)
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
6407 for t in templateNames])
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6408 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6409
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
6410 super(Editor, self).editorCommand(cmd)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6411
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6412 def __completionListSelected(self, id, txt):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6413 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6414 Private slot to handle the selection from the completion list.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6415
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6416 @param id the ID of the user list (should be 1) (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6417 @param txt the selected text (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6418 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6419 if id == TemplateCompletionListID:
1002
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6420 self.__applyTemplate(txt, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6421
1002
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6422 def __applyTemplate(self, templateName, language):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6423 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6424 Private method to apply a template by name.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6425
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6426 @param templateName name of the template to apply (string)
1002
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6427 @param language name of the language (group) to get the template
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6428 from (string)
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6429 """
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6430 if e5App().getObject("TemplateViewer").hasTemplate(
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6431 templateName, self.getLanguage()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6432 self.extendSelectionWordLeft()
1002
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6433 e5App().getObject("TemplateViewer").applyNamedTemplate(
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
6434 templateName, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6435
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6436 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6437 ## Project related methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6438 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6439
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6440 def __projectPropertiesChanged(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6441 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6442 Private slot to handle changes of the project properties.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6443 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6444 if self.spell:
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
6445 pwl, pel = self.project.getProjectDictionaries()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6446 self.__setSpellingLanguage(self.project.getProjectSpellLanguage(),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6447 pwl=pwl, pel=pel)
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
6448
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
6449 self.setEolModeByEolString(self.project.getEolString())
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
6450 self.convertEols(self.eolMode())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6451
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6452 def addedToProject(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6453 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6454 Public method to signal, that this editor has been added to a project.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6455 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6456 if self.spell:
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
6457 pwl, pel = self.project.getProjectDictionaries()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6458 self.__setSpellingLanguage(self.project.getProjectSpellLanguage(),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6459 pwl=pwl, pel=pel)
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
6460
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6461 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
6462 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
6463
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6464 def projectOpened(self):
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6465 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6466 Public slot to handle the opening of a project.
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6467 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6468 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
6469 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
6470 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
6471 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
6472 self.setSpellingForProject()
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6473
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6474 def projectClosed(self):
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6475 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6476 Public slot to handle the closing of a project.
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6477 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6478 try:
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6479 self.project.projectPropertiesChanged.disconnect(
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6480 self.__projectPropertiesChanged)
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6481 except TypeError:
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6482 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6483
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6484 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6485 ## Spellchecking related methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6486 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6487
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6488 def __setSpellingLanguage(self, language, pwl="", pel=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6489 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6490 Private slot to set the spell checking language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6491
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6492 @param language spell checking language to be set (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6493 @keyparam pwl name of the personal/project word list (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6494 @keyparam pel name of the personal/project exclude list (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6495 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6496 if self.spell and self.spell.getLanguage() != language:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6497 self.spell.setLanguage(language, pwl=pwl, pel=pel)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6498 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6499
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6500 def __setSpelling(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6501 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6502 Private method to initialize the spell checking functionality.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6503 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6504 if Preferences.getEditor("SpellCheckingEnabled"):
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6505 self.__spellCheckStringsOnly = Preferences.getEditor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6506 "SpellCheckStringsOnly")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6507 if self.spell is None:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
6508 from .SpellChecker import SpellChecker
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6509 self.spell = SpellChecker(self, self.spellingIndicator,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6510 checkRegion=self.isSpellCheckRegion)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6511 self.setSpellingForProject()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6512 self.spell.setMinimumWordSize(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6513 Preferences.getEditor("SpellCheckingMinWordSize"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6514
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6515 self.setAutoSpellChecking()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6516 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6517 self.spell = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6518 self.clearAllIndicators(self.spellingIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6519
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6520 def setSpellingForProject(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6521 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6522 Public method to set the spell checking options for files belonging
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6523 to the current project.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6524 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6525 if self.fileName and \
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
6526 self.project.isOpen() and \
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
6527 self.project.isProjectSource(self.fileName):
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
6528 pwl, pel = self.project.getProjectDictionaries()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6529 self.__setSpellingLanguage(self.project.getProjectSpellLanguage(),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6530 pwl=pwl, pel=pel)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6531
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6532 def setAutoSpellChecking(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6533 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6534 Public method to set the automatic spell checking.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6535 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6536 if Preferences.getEditor("AutoSpellCheckingEnabled"):
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
6537 try:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6538 self.SCN_CHARADDED.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6539 self.__spellCharAdded, Qt.UniqueConnection)
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
6540 except TypeError:
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
6541 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6542 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6543 else:
542
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
6544 try:
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
6545 self.SCN_CHARADDED.disconnect(self.__spellCharAdded)
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
6546 except TypeError:
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
6547 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6548 self.clearAllIndicators(self.spellingIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6549
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6550 def isSpellCheckRegion(self, pos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6551 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6552 Public method to check, if the given position is within a region, that
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6553 should be spell checked.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6554
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6555 @param pos position to be checked (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6556 @return flag indicating pos is in a spell check region (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6557 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6558 if self.__spellCheckStringsOnly:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6559 style = self.styleAt(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6560 if self.lexer_ is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6561 return self.lexer_.isCommentStyle(style) or \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
6562 self.lexer_.isStringStyle(style)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6563 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6564
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
6565 @pyqtSlot(int)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6566 def __spellCharAdded(self, charNumber):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6567 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6568 Public slot called to handle the user entering a character.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6569
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6570 @param charNumber value of the character entered (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6571 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6572 if self.spell:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6573 if not chr(charNumber).isalnum():
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6574 self.spell.checkWord(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6575 self.positionBefore(self.currentPosition()), True)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6576 elif self.hasIndicator(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6577 self.spellingIndicator, self.currentPosition()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6578 self.spell.checkWord(self.currentPosition())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6579
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6580 def checkSpelling(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6581 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6582 Public slot to perform an interactive spell check of the document.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6583 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6584 if self.spell:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6585 cline, cindex = self.getCursorPosition()
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
6586 from .SpellCheckingDialog import SpellCheckingDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6587 dlg = SpellCheckingDialog(self.spell, 0, self.length(), self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6588 dlg.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6589 self.setCursorPosition(cline, cindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6590 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6591 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6592
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6593 def __checkSpellingSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6594 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6595 Private slot to spell check the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6596 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
6597 from .SpellCheckingDialog import SpellCheckingDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6598 sline, sindex, eline, eindex = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6599 startPos = self.positionFromLineIndex(sline, sindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6600 endPos = self.positionFromLineIndex(eline, eindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6601 dlg = SpellCheckingDialog(self.spell, startPos, endPos, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6602 dlg.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6603
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6604 def __checkSpellingWord(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6605 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6606 Private slot to check the word below the spelling context menu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6607 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
6608 from .SpellCheckingDialog import SpellCheckingDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6609 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6610 wordStart, wordEnd = self.getWordBoundaries(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6611 wordStartPos = self.positionFromLineIndex(line, wordStart)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6612 wordEndPos = self.positionFromLineIndex(line, wordEnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6613 dlg = SpellCheckingDialog(self.spell, wordStartPos, wordEndPos, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6614 dlg.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6615
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6616 def __showContextMenuSpelling(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6617 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6618 Private slot to set up the spelling menu before it is shown.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6619 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6620 self.spellingMenu.clear()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6621 self.spellingSuggActs = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6622 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6623 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6624 suggestions = self.spell.getSuggestions(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6625 for suggestion in suggestions[:5]:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6626 self.spellingSuggActs.append(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6627 self.spellingMenu.addAction(suggestion))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6628 if suggestions:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6629 self.spellingMenu.addSeparator()
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6630 self.spellingMenu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6631 UI.PixmapCache.getIcon("spellchecking.png"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6632 self.trUtf8("Check spelling..."), self.__checkSpellingWord)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6633 self.spellingMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6634 self.trUtf8("Add to dictionary"), self.__addToSpellingDictionary)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6635 self.spellingMenu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6636 self.trUtf8("Ignore All"), self.__ignoreSpellingAlways)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6637
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6638 self.showMenu.emit("Spelling", self.spellingMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6639
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6640 def __contextMenuSpellingTriggered(self, action):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6641 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6642 Private slot to handle the selection of a suggestion of the spelling
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6643 context menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6644
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6645 @param action reference to the action that was selected (QAction)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6646 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6647 if action in self.spellingSuggActs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6648 replacement = action.text()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6649 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6650 wordStart, wordEnd = self.getWordBoundaries(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6651 self.setSelection(line, wordStart, line, wordEnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6652 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6653 self.removeSelectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6654 self.insert(replacement)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6655 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6656
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6657 def __addToSpellingDictionary(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6658 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6659 Private slot to add the word below the spelling context menu to the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6660 dictionary.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6661 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6662 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6663 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6664 self.spell.add(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6665
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6666 wordStart, wordEnd = self.getWordBoundaries(line, index)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6667 self.clearIndicator(self.spellingIndicator, line, wordStart,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6668 line, wordEnd)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6669 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6670 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6671
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6672 def __removeFromSpellingDictionary(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6673 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6674 Private slot to remove the word below the context menu to the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6675 dictionary.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6676 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6677 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6678 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6679 self.spell.remove(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6680
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6681 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6682 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6683
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6684 def __ignoreSpellingAlways(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6685 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6686 Private to always ignore the word below the spelling context menu.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6687 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6688 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6689 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6690 self.spell.ignoreAlways(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6691 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6692 self.spell.checkDocumentIncrementally()
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6693
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6694 #######################################################################
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6695 ## Cooperation related methods
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6696 #######################################################################
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6697
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6698 def getSharingStatus(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6699 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6700 Public method to get some share status info.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6701
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6702 @return tuple indicating, if the editor is sharable, the sharing
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6703 status, if it is inside a locally initiated shared edit session
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6704 and if it is inside a remotely initiated shared edit session
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6705 (boolean, boolean, boolean, boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6706 """
162
28f235c426c4 Added functionality to cut/copy/... the chat and to interactively accept/reject connections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 158
diff changeset
6707 return self.fileName is not None and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
6708 self.project.isOpen() and \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
6709 self.project.isProjectFile(self.fileName), \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
6710 self.__isShared, self.__inSharedEdit, self.__inRemoteSharedEdit
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6711
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6712 def shareConnected(self, connected):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6713 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6714 Public slot to handle a change of the connected state.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6715
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6716 @param connected flag indicating the connected state (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6717 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6718 if not connected:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6719 self.__inRemoteSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6720 self.setReadOnly(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6721 self.__updateReadOnly()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6722 self.cancelSharedEdit(send=False)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6723 self.__isSyncing = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6724 self.__receivedWhileSyncing = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6725
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6726 def shareEditor(self, share):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6727 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6728 Public slot to set the shared status of the editor.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6729
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6730 @param share flag indicating the share status (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6731 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6732 self.__isShared = share
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6733 if not share:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6734 self.shareConnected(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6735
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6736 def startSharedEdit(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6737 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6738 Public slot to start a shared edit session for the editor.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6739 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6740 self.__inSharedEdit = True
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6741 self.__savedText = self.text()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6742 hash = str(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6743 QCryptographicHash.hash(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6744 Utilities.encode(self.__savedText, self.encoding)[0],
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6745 QCryptographicHash.Sha1).toHex(),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6746 encoding="utf-8")
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6747 self.__send(Editor.StartEditToken, hash)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6748
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6749 def sendSharedEdit(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6750 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6751 Public slot to end a shared edit session for the editor and
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6752 send the changes.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6753 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6754 commands = self.__calculateChanges(self.__savedText, self.text())
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6755 self.__send(Editor.EndEditToken, commands)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6756 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6757 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6758
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6759 def cancelSharedEdit(self, send=True):
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6760 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6761 Public slot to cancel a shared edit session for the editor.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6762
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6763 @keyparam send flag indicating to send the CancelEdit command (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6764 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6765 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6766 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6767 if send:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6768 self.__send(Editor.CancelEditToken)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6769
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6770 def __send(self, token, args=None):
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6771 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6772 Private method to send an editor command to remote editors.
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6773
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6774 @param token command token (string)
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6775 @param args arguments for the command (string)
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6776 """
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6777 if self.vm.isConnected():
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6778 msg = ""
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6779 if token in (Editor.StartEditToken,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6780 Editor.EndEditToken,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6781 Editor.RequestSyncToken,
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6782 Editor.SyncToken):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6783 msg = "{0}{1}{2}".format(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6784 token,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6785 Editor.Separator,
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6786 args
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6787 )
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6788 elif token == Editor.CancelEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6789 msg = "{0}{1}c".format(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6790 token,
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6791 Editor.Separator
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6792 )
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6793
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6794 self.vm.send(self.fileName, msg)
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6795
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6796 def receive(self, command):
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6797 """
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6798 Public slot to handle received editor commands.
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6799
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6800 @param command command string (string)
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6801 """
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6802 if self.__isShared:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6803 if self.__isSyncing and \
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6804 not command.startswith(Editor.SyncToken + Editor.Separator):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6805 self.__receivedWhileSyncing.append(command)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6806 else:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6807 self.__dispatchCommand(command)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6808
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6809 def __dispatchCommand(self, command):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6810 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6811 Private method to dispatch received commands.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6812
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6813 @param command command to be processed (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6814 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6815 token, argsString = command.split(Editor.Separator, 1)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6816 if token == Editor.StartEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6817 self.__processStartEditCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6818 elif token == Editor.CancelEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6819 self.shareConnected(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6820 elif token == Editor.EndEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6821 self.__processEndEditCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6822 elif token == Editor.RequestSyncToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6823 self.__processRequestSyncCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6824 elif token == Editor.SyncToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6825 self.__processSyncCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6826
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6827 def __processStartEditCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6828 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
6829 Private slot to process a remote StartEdit command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6830
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6831 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6832 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6833 if not self.__inSharedEdit and not self.__inRemoteSharedEdit:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6834 self.__inRemoteSharedEdit = True
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6835 self.setReadOnly(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6836 self.__updateReadOnly()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6837 hash = str(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6838 QCryptographicHash.hash(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6839 Utilities.encode(self.text(), self.encoding)[0],
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6840 QCryptographicHash.Sha1).toHex(),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6841 encoding="utf-8")
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6842 if hash != argsString:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6843 # text is different to the remote site, request to sync it
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6844 self.__isSyncing = True
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6845 self.__send(Editor.RequestSyncToken, argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6846
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6847 def __calculateChanges(self, old, new):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6848 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6849 Private method to determine change commands to convert old text into
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6850 new text.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6851
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6852 @param old old text (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6853 @param new new text (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6854 @return commands to change old into new (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6855 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6856 oldL = old.splitlines()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6857 newL = new.splitlines()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6858 matcher = difflib.SequenceMatcher(None, oldL, newL)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6859
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6860 formatStr = "@@{0} {1} {2} {3}"
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6861 commands = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6862 for token, i1, i2, j1, j2 in matcher.get_opcodes():
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6863 if token == "insert":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6864 commands.append(formatStr.format("i", j1, j2 - j1, -1))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6865 commands.extend(newL[j1:j2])
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6866 elif token == "delete":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6867 commands.append(formatStr.format("d", j1, i2 - i1, -1))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6868 elif token == "replace":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6869 commands.append(formatStr.format("r", j1, i2 - i1, j2 - j1))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6870 commands.extend(newL[j1:j2])
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6871
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6872 return "\n".join(commands) + "\n"
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6873
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6874 def __processEndEditCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6875 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
6876 Private slot to process a remote EndEdit command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6877
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6878 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6879 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6880 commands = argsString.splitlines()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6881 sep = self.getLineSeparator()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6882 cur = self.getCursorPosition()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6883
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6884 self.setReadOnly(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6885 self.beginUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6886 while commands:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6887 commandLine = commands.pop(0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6888 if not commandLine.startswith("@@"):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6889 continue
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6890
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
6891 args = commandLine.split()
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
6892 command = args.pop(0)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6893 pos, l1, l2 = [int(arg) for arg in args]
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6894 if command == "@@i":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6895 txt = sep.join(commands[0:l1]) + sep
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6896 self.insertAt(txt, pos, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6897 del commands[0:l1]
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6898 elif command == "@@d":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6899 self.setSelection(pos, 0, pos + l1, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6900 self.removeSelectedText()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6901 elif command == "@@r":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6902 self.setSelection(pos, 0, pos + l1, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6903 self.removeSelectedText()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6904 txt = sep.join(commands[0:l2]) + sep
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6905 self.insertAt(txt, pos, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6906 del commands[0:l2]
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6907 self.endUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6908 self.__updateReadOnly()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6909 self.__inRemoteSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6910
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6911 self.setCursorPosition(*cur)
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
6912
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6913 def __processRequestSyncCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6914 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
6915 Private slot to process a remote RequestSync command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6916
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6917 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6918 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6919 if self.__inSharedEdit:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6920 hash = str(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6921 QCryptographicHash.hash(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6922 Utilities.encode(self.__savedText, self.encoding)[0],
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6923 QCryptographicHash.Sha1).toHex(),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6924 encoding="utf-8")
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6925
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6926 if hash == argsString:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6927 self.__send(Editor.SyncToken, self.__savedText)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6928
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6929 def __processSyncCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6930 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
6931 Private slot to process a remote Sync command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6932
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6933 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6934 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6935 if self.__isSyncing:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6936 cur = self.getCursorPosition()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6937
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6938 self.setReadOnly(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6939 self.beginUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6940 self.selectAll()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6941 self.removeSelectedText()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6942 self.insertAt(argsString, 0, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6943 self.endUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6944 self.setReadOnly(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6945
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6946 self.setCursorPosition(*cur)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6947
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6948 while self.__receivedWhileSyncing:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6949 command = self.__receivedWhileSyncing.pop(0)
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 825
diff changeset
6950 self.__dispatchCommand(command)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
6951
718
979d6e242404 Fixed an issue in the editor saving files without extension on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
6952 self.__isSyncing = False
2213
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6953
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6954 #######################################################################
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6955 ## Special search related methods
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6956 #######################################################################
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6957
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6958 def searchCurrentWordForward(self):
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6959 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6960 Public slot to search the current word forward.
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6961 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6962 self.__searchCurrentWord(forward=True)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6963
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6964 def searchCurrentWordBackward(self):
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6965 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6966 Public slot to search the current word backward.
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6967 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6968 self.__searchCurrentWord(forward=False)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6969
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6970 def __searchCurrentWord(self, forward=True):
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6971 """
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6972 Public slot to search the next occurrence of the current word.
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6973
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6974 @param forward flag indicating the search direction (boolean)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6975 """
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
6976 self.hideFindIndicator()
2213
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6977 line, index = self.getCursorPosition()
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6978 word = self.getCurrentWord()
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6979 wordStart, wordEnd = self.getCurrentWordBoundaries()
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6980 wordStartPos = self.positionFromLineIndex(line, wordStart)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6981 wordEndPos = self.positionFromLineIndex(line, wordEnd)
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6982
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6983 regExp = re.compile(r"\b{0}\b".format(word))
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6984 if forward:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6985 startPos = wordEndPos
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6986 else:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6987 startPos = wordStartPos
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6988
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6989 matches = [m for m in regExp.finditer(self.text())]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6990 if matches:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6991 if forward:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6992 matchesAfter = [m for m in matches if m.start() >= startPos]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6993 if matchesAfter:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6994 match = matchesAfter[0]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6995 else:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6996 # wrap around
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6997 match = matches[0]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6998 else:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
6999 matchesBefore = [m for m in matches if m.start() < startPos]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7000 if matchesBefore:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7001 match = matchesBefore[-1]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7002 else:
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7003 # wrap around
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7004 match = matches[-1]
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7005 line, index = self.lineIndexFromPosition(match.start())
022f4ad3ed19 Added actions to search for the next/previous occurence of the current word (default shortcuts Ctrl+. and Ctrl+,).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2189
diff changeset
7006 self.setSelection(line, index + len(match.group(0)), line, index)
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
7007 self.showFindIndicator(line, index,
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
7008 line, index + len(match.group(0)))
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7009
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7010 #######################################################################
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7011 ## Sort related methods
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7012 #######################################################################
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7013
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7014 def sortLines(self):
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7015 """
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7016 Public slot to sort the lines spanned by a rectangular selection.
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7017 """
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7018 if not self.selectionIsRectangle():
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7019 return
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7020
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7021 from .SortOptionsDialog import SortOptionsDialog
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7022 dlg = SortOptionsDialog()
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7023 if dlg.exec_() == QDialog.Accepted:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7024 ascending, alnum, caseSensitive = dlg.getData()
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7025 origStartLine, origStartIndex, origEndLine, origEndIndex = \
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7026 self.getRectangularSelection()
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7027 # convert to upper-left to lower-right
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7028 startLine = min(origStartLine, origEndLine)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7029 startIndex = min(origStartIndex, origEndIndex)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7030 endLine = max(origStartLine, origEndLine)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7031 endIndex = max(origStartIndex, origEndIndex)
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7032
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7033 # step 1: extract the text of the rectangular selection and
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7034 # the lines
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7035 selText = {}
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7036 txtLines = {}
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7037 for line in range(startLine, endLine + 1):
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7038 txtLines[line] = self.text(line)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7039 txt = txtLines[line][startIndex:endIndex].strip()
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7040 if not alnum:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7041 try:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7042 txt = float(txt)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7043 except ValueError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
7044 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
7045 self,
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7046 self.trUtf8("Sort Lines"),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7047 self.trUtf8(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7048 """The selection contains illegal data for a"""
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7049 """ numerical sort."""))
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7050 return
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7051
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7052 if txt in selText:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7053 selText[txt].append(line)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7054 else:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7055 selText[txt] = [line]
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7056
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7057 # step 2: calculate the sort parameters
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7058 reverse = not ascending
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7059 if alnum and not caseSensitive:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7060 keyFun = str.lower
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7061 else:
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7062 keyFun = None
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7063
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7064 # step 3: sort the lines
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7065 eol = self.getLineSeparator()
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7066 lastWithEol = True
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7067 newLines = []
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7068 for txt in sorted(selText.keys(), key=keyFun, reverse=reverse):
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7069 for line in selText[txt]:
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7070 txt = txtLines[line]
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7071 if not txt.endswith(eol):
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7072 lastWithEol = False
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7073 txt += eol
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7074 newLines.append(txt)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7075 if not lastWithEol:
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7076 newLines[-1] = newLines[-1][:-len(eol)]
2589
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7077
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7078 # step 4: replace the lines by the sorted ones
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7079 self.setSelection(startLine, 0, endLine + 1, 0)
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7080 self.beginUndoAction()
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7081 self.replaceSelectedText("".join(newLines))
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7082 self.endUndoAction()
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7083
a51b0c113ed7 Added the capability to sort lines spanned by a rectangular selection based on the selected text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2517
diff changeset
7084 # step 5: reset the rectangular selection
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7085 self.setRectangularSelection(origStartLine, origStartIndex,
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7086 origEndLine, origEndIndex)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7087 self.selectionChanged.emit()

eric ide

mercurial