QScintilla/Editor.py

Thu, 22 Oct 2015 19:48:40 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 22 Oct 2015 19:48:40 +0200
changeset 4503
d68dcbe1deb3
parent 4498
1eeb430df3a2
child 4631
5c1a96925da4
permissions
-rw-r--r--

Improved the syntax checker, code style checker and indentation checker interfaces.

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
4021
195a471c327b Updated copyright for 2015.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3972
diff changeset
3 # Copyright (c) 2002 - 2015 Detlev Offenbach <detlev@die-offenbachs.de>
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4 #
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
7 Module implementing the editor component of the eric6 IDE.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
8 """
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
9 from __future__ import unicode_literals
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
10 try:
3177
5af61402d74d Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
11 str = unicode
5af61402d74d Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
12 chr = unichr
5af61402d74d Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3173
diff changeset
13 except NameError:
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
14 pass
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2517
diff changeset
15
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
16 import os
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
17 import re
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
18 import difflib
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
19
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
20 from PyQt5.QtCore import QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, \
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
21 pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt, qVersion
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
22 from PyQt5.QtGui import QCursor, QPalette, QFont, QPixmap, QPainter
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
23 from PyQt5.QtWidgets import QLineEdit, QActionGroup, QDialog, QInputDialog, \
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
24 QApplication, QMenu
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
25 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
26 from PyQt5.Qsci import QsciScintilla, QsciMacro, QsciStyledText
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
27
2084
d3f083dd0222 Made the fiveth set of Qt5 compatibility changes (some of the previous changes are backed out due to changes in PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2077
diff changeset
28 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
29 from E5Gui import E5FileDialog, E5MessageBox
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
30
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
31 from .QsciScintillaCompat import QsciScintillaCompat, QSCINTILLA_VERSION
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
32 from .EditorMarkerMap import EditorMarkerMap
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
33
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
34 import Preferences
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
35 import Utilities
4290
5d4f4230a5ed Moved the code to create a display string for a modifier and mouse button combination to a separate file because it will be needed in other places than just the editor as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4288
diff changeset
36 from Utilities import MouseUtilities
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
37
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
38 import UI.PixmapCache
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
39
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
40 EditorAutoCompletionListID = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
41 TemplateCompletionListID = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
42
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
43
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
44 class Editor(QsciScintillaCompat):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
45 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
46 Class implementing the editor component of the eric6 IDE.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
47
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
48 @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
49 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
50 @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
51 @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
52 @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
53 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
54 @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
55 @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
56 @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
57 @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
58 (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
59 @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
60 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
61 @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
62 is toggled
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
63 @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
64 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
65 @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
66 was discovered
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
67 @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
68 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
69 @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
70 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
71 @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
72 markers were updated
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
73 @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
74 markers were updated
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
75 @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
76 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
77 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
78 @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
79 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
80 @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
81 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
82 @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
83 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
84 @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
85 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
86 @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
87 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
88 modificationStatusChanged = pyqtSignal(bool, QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
89 undoAvailable = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
90 redoAvailable = pyqtSignal(bool)
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
91 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
92 cursorLineChanged = pyqtSignal(int)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
93 editorAboutToBeSaved = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
94 editorSaved = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
95 editorRenamed = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
96 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
97 breakpointToggled = pyqtSignal(QsciScintillaCompat)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
98 bookmarkToggled = pyqtSignal(QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
99 syntaxerrorToggled = pyqtSignal(QsciScintillaCompat)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
100 autoCompletionAPIsAvailable = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
101 coverageMarkersShown = pyqtSignal(bool)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
102 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
103 changeMarkersUpdated = pyqtSignal(QsciScintillaCompat)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
104 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
105 languageChanged = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
106 eolChanged = pyqtSignal(str)
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
107 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
108 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
109 refreshed = pyqtSignal()
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
110
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
111 WarningCode = 1
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
112 WarningStyle = 2
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
113
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
114 # 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
115 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
116 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
117 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
118 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
119 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
120 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
121 AttributeID = 7
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
122 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
123 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
124 EnumID = 10
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
125
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
126 FromDocumentID = 99
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
127
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
128 TemplateImageID = 100
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
129
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
130 # Cooperation related definitions
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
131 Separator = "@@@"
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
132
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
133 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
134 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
135 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
136 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
137 SyncToken = "SYNC"
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
138
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
139 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
140 filetype="", editor=None, tv=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
141 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
142 Constructor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
143
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
144 @param dbs reference to the debug server object
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
145 @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
146 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
147 @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
148 (ViewManager.ViewManager)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
149 @param filetype type of the source file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
150 @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
151 @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
152 @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
153 """
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
154 super(Editor, self).__init__()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
155 self.setAttribute(Qt.WA_KeyCompression)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
156 self.setUtf8(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
157
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
158 self.dbs = dbs
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
159 self.taskViewer = tv
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
160 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
161 self.vm = vm
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
162 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
163 self.filetypeByFlag = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
164 self.noName = ""
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
165 self.project = e5App().getObject("Project")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
166
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
167 # 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
168 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
169 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
170 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
171
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
172 self.breaks = {}
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
173 # key: marker handle,
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
174 # value: (lineno, condition, temporary,
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
175 # enabled, ignorecount)
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
176 self.bookmarks = []
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
177 # bookmarks are just a list of handles to the
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
178 # bookmark markers
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
179 self.syntaxerrors = {}
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
180 # key: marker handle
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
181 # value: list of (error message, error index)
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
182 self.warnings = {}
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
183 # key: marker handle
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
184 # 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
185 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
186 self.showingNotcoveredMarkers = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
187
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
188 self.condHistory = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
189 self.lexer_ = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
190 self.__lexerReset = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
191 self.completer = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
192 self.encoding = Preferences.getEditor("DefaultEncoding")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
193 self.apiLanguage = ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
194 self.lastModified = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
195 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
196 self.inReopenPrompt = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
197 # 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
198 self.inFileRenamed = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
199 # true if we are propagating a rename action
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
200 self.inLanguageChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
201 # true if we are propagating a language change
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
202 self.inEolChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
203 # true if we are propagating an eol change
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
204 self.inEncodingChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
205 # true if we are propagating an encoding change
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
206 self.inDragDrop = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
207 # true if we are in drop mode
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
208 self.inLinesChanged = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
209 # true if we are propagating a lines changed event
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
210 self.__hasTaskMarkers = False
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
211 # no task markers present
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
212
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
213 self.macros = {} # list of defined macros
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
214 self.curMacro = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
215 self.recording = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
216
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
217 self.acAPI = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
218
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
219 self.__lastEditPosition = None
3863
472eb955ff9c Corrected the annotations scrollbar fix because it caused seg faults for short files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3861
diff changeset
220 self.__annotationLines = 0
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
221
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
222 # list of clones
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
223 self.__clones = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
224
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
225 # clear QScintilla defined keyboard commands
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
226 # 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
227 self.clearAlternateKeys()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
228 self.clearKeys()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
229
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
230 # initialize the mark occurrences timer
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
231 self.__markOccurrencesTimer = QTimer(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
232 self.__markOccurrencesTimer.setSingleShot(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
233 self.__markOccurrencesTimer.setInterval(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
234 Preferences.getEditor("MarkOccurrencesTimeout"))
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
235 self.__markOccurrencesTimer.timeout.connect(self.__markOccurrences)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
236 self.__markedText = ""
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
237 self.__searchIndicatorLines = []
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
238
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
239 # initialize some spellchecking stuff
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
240 self.spell = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
241 self.lastLine = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
242 self.lastIndex = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
243
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
244 # initialize some cooperation stuff
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
245 self.__isSyncing = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
246 self.__receivedWhileSyncing = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
247 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
248 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
249 self.__isShared = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
250 self.__inRemoteSharedEdit = False
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
251
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
252 # 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
253 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
254 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
255 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
256 self.userListActivated.connect(self.__completionListSelected)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
257
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
258 # margins layout
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
259 if QSCINTILLA_VERSION() >= 0x020301:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
260 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
261 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
262 self.__unifiedMargins = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
263
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
264 # 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
265 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
266 self.__createChangeMarkerPixmap(
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
267 "OnlineChangeTraceMarkerSaved"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
268 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
269 self.__createChangeMarkerPixmap(
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
270 "OnlineChangeTraceMarkerUnsaved"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
271 self.breakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
272 self.markerDefine(UI.PixmapCache.getPixmap("break.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
273 self.cbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
274 self.markerDefine(UI.PixmapCache.getPixmap("cBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
275 self.tbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
276 self.markerDefine(UI.PixmapCache.getPixmap("tBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
277 self.tcbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
278 self.markerDefine(UI.PixmapCache.getPixmap("tCBreak.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
279 self.dbreakpoint = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
280 self.markerDefine(UI.PixmapCache.getPixmap("breakDisabled.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
281 self.bookmark = \
1106
3e57cd52e0f6 Added icons to the Mercurial extensions menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1063
diff changeset
282 self.markerDefine(UI.PixmapCache.getPixmap("bookmark16.png"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
283 self.syntaxerror = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
284 self.markerDefine(UI.PixmapCache.getPixmap("syntaxError.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
285 self.notcovered = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
286 self.markerDefine(UI.PixmapCache.getPixmap("notcovered.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
287 self.taskmarker = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
288 self.markerDefine(UI.PixmapCache.getPixmap("task.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
289 self.warning = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
290 self.markerDefine(UI.PixmapCache.getPixmap("warning.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
291
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
292 # define the line markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
293 self.currentline = self.markerDefine(QsciScintilla.Background)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
294 self.errorline = self.markerDefine(QsciScintilla.Background)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
295 self.__setLineMarkerColours()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
296
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
297 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
298 (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
299 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
300 (1 << self.tcbreakpoint) | \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
301 (1 << self.dbreakpoint)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
302
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
303 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
304 (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
305
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
306 self.__markerMap = EditorMarkerMap(self)
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
307
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
308 # configure the margins
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
309 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
310 self.linesChanged.connect(self.__resizeLinenoMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
311
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
312 self.marginClicked.connect(self.__marginClicked)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
313
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
314 # set the eol mode
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
315 self.__setEolMode()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
316
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
317 # set the text display
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
318 self.__setTextDisplay()
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
319
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
320 # initialize the online syntax check timer
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
321 try:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
322 self.syntaxCheckService = e5App().getObject('SyntaxCheckService')
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
323 self.syntaxCheckService.syntaxChecked.connect(
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
324 self.__processSyntaxCheckResult)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
325 self.syntaxCheckService.error.connect(
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
326 self.__processSyntaxCheckError)
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
327 self.__initOnlineSyntaxCheck()
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
328 except KeyError:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
329 self.syntaxCheckService = None
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
330
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
331 self.isResourcesFile = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
332 if editor is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
333 if self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
334 if (QFileInfo(self.fileName).size() // 1024) > \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
335 Preferences.getEditor("WarnFilesize"):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
336 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
337 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
338 self.tr("Open File"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
339 self.tr("""<p>The size of the file <b>{0}</b>"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
340 """ is <b>{1} KB</b>."""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
341 """ 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
342 .format(self.fileName,
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
343 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
344 icon=E5MessageBox.Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
345 if not res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
346 raise IOError()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
347 self.readFile(self.fileName, True)
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
348 self.__bindLexer(self.fileName)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
349 self.__bindCompleter(self.fileName)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
350 self.checkSyntax()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
351 self.isResourcesFile = self.fileName.endswith(".qrc")
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.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
354 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
355 # clone the given editor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
356 self.setDocument(editor.document())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
357 self.breaks = editor.breaks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
358 self.bookmarks = editor.bookmarks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
359 self.syntaxerrors = editor.syntaxerrors
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
360 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
361 self.showingNotcoveredMarkers = editor.showingNotcoveredMarkers
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
362 self.isResourcesFile = editor.isResourcesFile
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
363 self.lastModified = editor.lastModified
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
364
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
365 self.addClone(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
366 editor.addClone(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
367
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
368 self.gotoLine(1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
369
741
137cc6344b48 Fixed an issue in the Editor class introduced by the annotation job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 730
diff changeset
370 # 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
371 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
372
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
373 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
374 self.__acHookFunction = None
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
375 self.__completionListHookFunctions = {}
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
376 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
377 self.__ctHookFunction = None
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
378 self.__ctHookFunctions = {}
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
379 self.__setCallTips()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
380
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
381 # set the mouse click handlers (fired on mouse release)
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
382 self.__mouseClickHandlers = {}
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
383 # dictionary with tuple of keyboard modifier and mouse button as key
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
384 # and tuple of plug-in name and function as value
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
385
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
386 sh = self.sizeHint()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
387 if sh.height() < 300:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
388 sh.setHeight(300)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
389 self.resize(sh)
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 # Make sure tabbing through a QWorkspace works.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
392 self.setFocusPolicy(Qt.StrongFocus)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
393
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
394 self.__updateReadOnly(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
395
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
396 self.setWhatsThis(self.tr(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
397 """<b>A Source Editor Window</b>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
398 """<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
399 """ 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
400 """ 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
401 """<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
402 """ 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
403 """ 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
404 """<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
405 """ 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
406 """<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
407 """<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
408 """ about this error.</p>"""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
409 ))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
410
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
411 # 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
412 if self.vm is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
413 req = self.size()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
414 bnd = req.boundedTo(self.vm.size())
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 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
417 self.resize(bnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
418
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
419 # set the autosave flag
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
420 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
421 self.autosaveManuallyDisabled = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
422
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
423 self.__initContextMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
424 self.__initContextMenuMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
425
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
426 self.__checkEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
427 if editor is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
428 self.__checkLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
429 self.__checkEncoding()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
430 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
431 # 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
432 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
433 self.__encodingChanged(editor.encoding, propagate=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
434
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
435 self.setAcceptDrops(True)
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 # breakpoint handling
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
438 self.breakpointModel = self.dbs.getBreakPointModel()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
439 self.__restoreBreakpoints()
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
440 self.breakpointModel.rowsAboutToBeRemoved.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
441 self.__deleteBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
442 self.breakpointModel.dataAboutToBeChanged.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
443 self.__breakPointDataAboutToBeChanged)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
444 self.breakpointModel.dataChanged.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
445 self.__changeBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
446 self.breakpointModel.rowsInserted.connect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
447 self.__addBreakPoints)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
448 self.SCN_MODIFIED.connect(self.__modified)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
449
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
450 # establish connection to some ViewManager action groups
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
451 self.addActions(self.vm.editorActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
452 self.addActions(self.vm.editActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
453 self.addActions(self.vm.copyActGrp.actions())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
454 self.addActions(self.vm.viewActGrp.actions())
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 # register images to be shown in autocompletion lists
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
457 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
458
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
459 # 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
460 self.textChanged.connect(self.__textChanged)
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
461
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
462 # 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
463 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
464
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
465 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
466 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
467 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
468 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
469 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
470
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
471 self.grabGesture(Qt.PinchGesture)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
472
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
473 self.SCN_ZOOM.connect(self.__markerMap.update)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
474 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
475
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
476 def __registerImages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
477 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
478 Private method to register images for autocompletion lists.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
479 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
480 self.registerImage(self.ClassID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
481 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
482 self.registerImage(self.ClassProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
483 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
484 self.registerImage(self.ClassPrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
485 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
486 self.registerImage(self.MethodID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
487 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
488 self.registerImage(self.MethodProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
489 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
490 self.registerImage(self.MethodPrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
491 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
492 self.registerImage(self.AttributeID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
493 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
494 self.registerImage(self.AttributeProtectedID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
495 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
496 self.registerImage(self.AttributePrivateID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
497 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
498 self.registerImage(self.EnumID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
499 UI.PixmapCache.getPixmap("enum.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
500
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
501 self.registerImage(self.FromDocumentID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
502 UI.PixmapCache.getPixmap("editor.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
503
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
504 self.registerImage(self.TemplateImageID,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
505 UI.PixmapCache.getPixmap("templateViewer.png"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
506
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
507 def addClone(self, editor):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
508 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
509 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
510
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
511 @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
512 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
513 self.__clones.append(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
514
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
515 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
516 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
517 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
518 editor.encodingChanged.connect(self.__encodingChanged)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
519
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
520 def removeClone(self, editor):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
521 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
522 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
523
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
524 @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
525 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
526 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
527 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
528 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
529 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
530 editor.encodingChanged.disconnect(self.__encodingChanged)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
531 self.__clones.remove(editor)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
532
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
533 def __bindName(self, line0):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
534 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
535 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
536
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
537 @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
538 (string)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
539 @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
540 """
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
541 bindName = ""
2221
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
542 line0 = line0.lower()
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
543
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
544 # 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
545 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
546 bindName = "dummy.html"
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
547 elif line0.startswith(("<?xml", "<!doctype")):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
548 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
549 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
550 bindName = "dummy.diff"
f72f8b0478cb Extended the first line checks to determine the file type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2219
diff changeset
551 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
552 bindName = "dummy.tex"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
553
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
554 # 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
555 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
556 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
557 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
558 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
559 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
560 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
561 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
562 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
563 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
564 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
565 bindName = "dummy.ini"
3438
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
566 elif self.filetype == "JavaScript":
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
567 bindName = "dummy.js"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
568
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
569 # #! 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
570 if not bindName and line0.startswith("#!"):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
571 if "python3" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
572 bindName = "dummy.py"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
573 self.filetype = "Python3"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
574 elif "python2" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
575 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
576 self.filetype = "Python2"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
577 elif "python" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
578 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
579 self.filetype = "Python2"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
580 elif ("/bash" in line0 or "/sh" in line0):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
581 bindName = "dummy.sh"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
582 elif "ruby" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
583 bindName = "dummy.rb"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
584 self.filetype = "Ruby"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
585 elif "perl" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
586 bindName = "dummy.pl"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
587 elif "lua" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
588 bindName = "dummy.lua"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
589 elif "dmd" in line0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
590 bindName = "dummy.d"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
591 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
592
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
593 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
594 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
595
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
596 return bindName
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 def getMenu(self, menuName):
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 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
601
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
602 @param menuName name of the menu (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
603 @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
604 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
605 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
606 return self.__menus[menuName]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
607 except KeyError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
608 return None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
609
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
610 def hasMiniMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
611 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
612 Public method to check the miniMenu flag.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
613
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
614 @return flag indicating a minimized context menu (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
615 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
616 return self.miniMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
617
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
618 def __initContextMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
619 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
620 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
621 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
622 self.miniMenu = Preferences.getEditor("MiniContextMenu")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
623
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
624 self.menuActs = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
625 self.menu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
626 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
627 "Main": self.menu,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
628 }
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
629
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
630 self.languagesMenu = self.__initContextMenuLanguages()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
631 self.__menus["Languages"] = self.languagesMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
632 if self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
633 self.resourcesMenu = self.__initContextMenuResources()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
634 self.__menus["Resources"] = self.resourcesMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
635 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
636 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
637 self.menuShow = self.__initContextMenuShow()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
638 self.graphicsMenu = self.__initContextMenuGraphics()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
639 self.autocompletionMenu = self.__initContextMenuAutocompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
640 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
641 self.__menus["Show"] = self.menuShow
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
642 self.__menus["Graphics"] = self.graphicsMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
643 self.__menus["Autocompletion"] = self.autocompletionMenu
3583
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
644 self.toolsMenu = self.__initContextMenuTools()
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
645 self.__menus["Tools"] = self.toolsMenu
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
646 self.exportersMenu = self.__initContextMenuExporters()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
647 self.__menus["Exporters"] = self.exportersMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
648 self.eolMenu = self.__initContextMenuEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
649 self.__menus["Eol"] = self.eolMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
650 self.encodingsMenu = self.__initContextMenuEncodings()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
651 self.__menus["Encodings"] = self.encodingsMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
652
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
653 self.menuActs["Undo"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
654 UI.PixmapCache.getIcon("editUndo.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
655 self.tr('Undo'), self.undo)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
656 self.menuActs["Redo"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
657 UI.PixmapCache.getIcon("editRedo.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
658 self.tr('Redo'), self.redo)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
659 self.menuActs["Revert"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
660 self.tr("Revert to last saved state"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
661 self.revertToUnmodified)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
662 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
663 self.menuActs["Cut"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
664 UI.PixmapCache.getIcon("editCut.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
665 self.tr('Cut'), self.cut)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
666 self.menuActs["Copy"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
667 UI.PixmapCache.getIcon("editCopy.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
668 self.tr('Copy'), self.copy)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
669 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
670 UI.PixmapCache.getIcon("editPaste.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
671 self.tr('Paste'), self.paste)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
672 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
673 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
674 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
675 UI.PixmapCache.getIcon("editIndent.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
676 self.tr('Indent'), self.indentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
677 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
678 UI.PixmapCache.getIcon("editUnindent.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
679 self.tr('Unindent'), self.unindentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
680 self.menuActs["Comment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
681 UI.PixmapCache.getIcon("editComment.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
682 self.tr('Comment'), self.commentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
683 self.menuActs["Uncomment"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
684 UI.PixmapCache.getIcon("editUncomment.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
685 self.tr('Uncomment'), self.uncommentLineOrSelection)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
686 self.menuActs["StreamComment"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
687 self.tr('Stream Comment'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
688 self.streamCommentLineOrSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
689 self.menuActs["BoxComment"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
690 self.tr('Box Comment'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
691 self.boxCommentLineOrSelection)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
692 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
693 self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
694 self.tr('Select to brace'), self.selectToMatchingBrace)
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
695 self.menu.addAction(self.tr('Select all'), self.__selectAll)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
696 self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
697 self.tr('Deselect all'), self.__deselectAll)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
698 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
699 self.menuActs["SpellCheck"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
700 UI.PixmapCache.getIcon("spellchecking.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
701 self.tr('Check spelling...'), self.checkSpelling)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
702 self.menuActs["SpellCheckSelection"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
703 UI.PixmapCache.getIcon("spellchecking.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
704 self.tr('Check spelling of selection...'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
705 self.__checkSpellingSelection)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
706 self.menuActs["SpellCheckRemove"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
707 self.tr("Remove from dictionary"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
708 self.__removeFromSpellingDictionary)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
709 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
710 self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
711 self.tr('Shorten empty lines'), self.shortenEmptyLines)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
712 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
713 self.menuActs["Languages"] = self.menu.addMenu(self.languagesMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
714 self.menuActs["Encodings"] = self.menu.addMenu(self.encodingsMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
715 self.menuActs["Eol"] = self.menu.addMenu(self.eolMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
716 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
717 self.menuActs["MonospacedFont"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
718 self.tr("Use Monospaced Font"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
719 self.handleMonospacedEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
720 self.menuActs["MonospacedFont"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
721 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
722 self.menuActs["AutosaveEnable"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
723 self.tr("Autosave enabled"), self.__autosaveEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
724 self.menuActs["AutosaveEnable"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
725 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
726 self.menuActs["TypingAidsEnabled"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
727 self.tr("Typing aids enabled"), self.__toggleTypingAids)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
728 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
729 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
730 self.completer is not None)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
731 self.menuActs["TypingAidsEnabled"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
732 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
733 self.menuActs["AutoCompletionEnable"] = self.menu.addAction(
4153
95b18307079f Corrected some auto-completion related terms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4142
diff changeset
734 self.tr("Automatic Completion enabled"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
735 self.__toggleAutoCompletionEnable)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
736 self.menuActs["AutoCompletionEnable"].setCheckable(True)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
737 self.menuActs["AutoCompletionEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
738 self.autoCompletionThreshold() != -1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
739 if not self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
740 self.menu.addMenu(self.autocompletionMenu)
4153
95b18307079f Corrected some auto-completion related terms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4142
diff changeset
741 self.menuActs["calltip"] = self.menu.addAction(
95b18307079f Corrected some auto-completion related terms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4142
diff changeset
742 self.tr('Calltip'), self.callTip)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
743 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
744 if self.isResourcesFile:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
745 self.menu.addMenu(self.resourcesMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
746 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
747 self.menuActs["Check"] = self.menu.addMenu(self.checksMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
748 self.menu.addSeparator()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
749 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
750 self.menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
751 self.menuActs["Diagrams"] = self.menu.addMenu(self.graphicsMenu)
3583
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
752 self.menu.addSeparator()
3e8e0346d639 Re-fixed the recent editor issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3581
diff changeset
753 self.menuActs["Tools"] = self.menu.addMenu(self.toolsMenu)
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
754 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
755 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
756 UI.PixmapCache.getIcon("documentNewView.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
757 self.tr('New Document View'), self.__newView)
3100
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
758 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
759 UI.PixmapCache.getIcon("splitVertical.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
760 self.tr('New Document View (with new split)'),
3100
1c86bf655433 Added icons to the editor context menu 'New View' entries and gave them better titles.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3095
diff changeset
761 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
762 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
763 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
764 UI.PixmapCache.getIcon("close.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
765 self.tr('Close'), self.__contextClose)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
766 self.menu.addSeparator()
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
767 self.reopenEncodingMenu = self.__initContextMenuReopenWithEncoding()
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
768 self.menuActs["Reopen"] = self.menu.addMenu(self.reopenEncodingMenu)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
769 self.menuActs["Save"] = self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
770 UI.PixmapCache.getIcon("fileSave.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
771 self.tr('Save'), self.__contextSave)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
772 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
773 UI.PixmapCache.getIcon("fileSaveAs.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
774 self.tr('Save As...'), self.__contextSaveAs)
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
775 self.menu.addAction(
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
776 UI.PixmapCache.getIcon("fileSaveCopy.png"),
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
777 self.tr('Save Copy...'), self.__contextSaveCopy)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
778 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
779 self.menu.addMenu(self.exportersMenu)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
780 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
781 self.menuActs["OpenRejections"] = self.menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
782 self.tr("Open 'rejection' file"),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
783 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
784 self.menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
785 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
786 UI.PixmapCache.getIcon("printPreview.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
787 self.tr("Print Preview"), self.printPreviewFile)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
788 self.menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
789 UI.PixmapCache.getIcon("print.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
790 self.tr('Print'), self.printFile)
1299
fd5d21389d2b Added an action to the editor context menu and to the tabview and listview view managers to open an associated 'rejections' file (i.e. same file name with '.rej' appended).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1295
diff changeset
791 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
792 self.menuActs["OpenRejections"] = None
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
793
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
794 self.menu.aboutToShow.connect(self.__showContextMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
795
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
796 self.spellingMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
797 self.__menus["Spelling"] = self.spellingMenu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
798
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
799 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
800 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
801 self.__contextMenuSpellingTriggered)
92
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 __initContextMenuAutocompletion(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 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
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 """
4153
95b18307079f Corrected some auto-completion related terms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4142
diff changeset
809 menu = QMenu(self.tr('Complete'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
810
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
811 self.menuActs["acDynamic"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
812 self.tr('dynamic'), self.autoComplete)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
813 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
814 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
815 self.tr('from Document'), self.autoCompleteFromDocument)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
816 self.menuActs["acAPI"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
817 self.tr('from APIs'), self.autoCompleteFromAPIs)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
818 self.menuActs["acAPIDocument"] = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
819 self.tr('from Document and APIs'), self.autoCompleteFromAll)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
820
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
821 menu.aboutToShow.connect(self.__showContextMenuAutocompletion)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
822
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
823 return menu
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 def __initContextMenuChecks(self):
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 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
828
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
829 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
830 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
831 menu = QMenu(self.tr('Check'))
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
832 menu.aboutToShow.connect(self.__showContextMenuChecks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
833 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
834
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
835 def __initContextMenuTools(self):
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
836 """
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
837 Private method used to setup the Tools context sub menu.
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
838
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
839 @return reference to the generated menu (QMenu)
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
840 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
841 menu = QMenu(self.tr('Tools'))
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
842 menu.aboutToShow.connect(self.__showContextMenuTools)
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
843 return menu
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
844
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
845 def __initContextMenuShow(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
846 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
847 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
848
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
849 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
850 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
851 menu = QMenu(self.tr('Show'))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
852
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
853 menu.addAction(self.tr('Code metrics...'), self.__showCodeMetrics)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
854 self.coverageMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
855 self.tr('Code coverage...'), self.__showCodeCoverage)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
856 self.coverageShowAnnotationMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
857 self.tr('Show code coverage annotations'),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
858 self.codeCoverageShowAnnotations)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
859 self.coverageHideAnnotationMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
860 self.tr('Hide code coverage annotations'),
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
861 self.__codeCoverageHideAnnotations)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
862 self.profileMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
863 self.tr('Profile data...'), self.__showProfileData)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
864
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
865 menu.aboutToShow.connect(self.__showContextMenuShow)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
866
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
867 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
868
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
869 def __initContextMenuGraphics(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
870 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
871 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
872
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
873 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
874 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
875 menu = QMenu(self.tr('Diagrams'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
876
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
877 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
878 self.tr('Class Diagram...'), self.__showClassDiagram)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
879 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
880 self.tr('Package Diagram...'), self.__showPackageDiagram)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
881 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
882 self.tr('Imports Diagram...'), self.__showImportsDiagram)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
883 self.applicationDiagramMenuAct = menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
884 self.tr('Application Diagram...'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
885 self.__showApplicationDiagram)
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
886 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
887 menu.addAction(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
888 UI.PixmapCache.getIcon("open.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
889 self.tr("Load Diagram..."), self.__loadDiagram)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
890
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
891 menu.aboutToShow.connect(self.__showContextMenuGraphics)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
892
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
893 return menu
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 def __initContextMenuLanguages(self):
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 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
898
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
899 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
900 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
901 menu = QMenu(self.tr("Languages"))
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.languagesActGrp = QActionGroup(self)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
904 self.noLanguageAct = menu.addAction(self.tr("No Language"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
905 self.noLanguageAct.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
906 self.noLanguageAct.setData("None")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
907 self.languagesActGrp.addAction(self.noLanguageAct)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
908 menu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
909
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
910 from . import Lexers
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
911 self.supportedLanguages = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
912 supportedLanguages = Lexers.getSupportedLanguages()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
913 languages = sorted(list(supportedLanguages.keys()))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
914 for language in languages:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
915 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
916 self.supportedLanguages[language] = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
917 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
918 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
919 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
920 self.supportedLanguages[language][0])
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
921 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
922 act.setData(language)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
923 self.supportedLanguages[language].append(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
924 self.languagesActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
925
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
926 menu.addSeparator()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
927 self.pygmentsAct = menu.addAction(self.tr("Guessed"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
928 self.pygmentsAct.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
929 self.pygmentsAct.setData("Guessed")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
930 self.languagesActGrp.addAction(self.pygmentsAct)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
931 self.pygmentsSelAct = menu.addAction(self.tr("Alternatives"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
932 self.pygmentsSelAct.setData("Alternatives")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
933
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
934 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
935 menu.aboutToShow.connect(self.__showContextMenuLanguages)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
936
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
937 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
938
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
939 def __initContextMenuEncodings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
940 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
941 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
942
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
943 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
944 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
945 self.supportedEncodings = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
946
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
947 menu = QMenu(self.tr("Encodings"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
948
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
949 self.encodingsActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
950
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
951 for encoding in sorted(Utilities.supportedCodecs):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
952 act = menu.addAction(encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
953 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
954 act.setData(encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
955 self.supportedEncodings[encoding] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
956 self.encodingsActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
957
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
958 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
959 menu.aboutToShow.connect(self.__showContextMenuEncodings)
92
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 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
962
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
963 def __initContextMenuReopenWithEncoding(self):
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
964 """
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
965 Private method used to setup the Reopen With Encoding context sub menu.
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
966
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
967 @return reference to the generated menu (QMenu)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
968 """
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
969 menu = QMenu(self.tr("Re-Open With Encoding"))
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
970 menu.setIcon(UI.PixmapCache.getIcon("open.png"))
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
971
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
972 for encoding in sorted(Utilities.supportedCodecs):
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
973 act = menu.addAction(encoding)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
974 act.setData(encoding)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
975
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
976 menu.triggered.connect(self.__reopenWithEncodingMenuTriggered)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
977
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
978 return menu
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
979
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
980 def __initContextMenuEol(self):
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 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
983
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
984 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
985 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
986 self.supportedEols = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
987
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
988 menu = QMenu(self.tr("End-of-Line Type"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
989
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
990 self.eolActGrp = QActionGroup(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
991
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
992 act = menu.addAction(UI.PixmapCache.getIcon("eolLinux.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
993 self.tr("Unix"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
994 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
995 act.setData('\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
996 self.supportedEols['\n'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
997 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
998
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
999 act = menu.addAction(UI.PixmapCache.getIcon("eolWindows.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1000 self.tr("Windows"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1001 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1002 act.setData('\r\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1003 self.supportedEols['\r\n'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1004 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1005
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
1006 act = menu.addAction(UI.PixmapCache.getIcon("eolMac.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1007 self.tr("Macintosh"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1008 act.setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1009 act.setData('\r')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1010 self.supportedEols['\r'] = act
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1011 self.eolActGrp.addAction(act)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1012
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1013 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
1014 menu.aboutToShow.connect(self.__showContextMenuEol)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1015
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1016 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1017
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1018 def __initContextMenuExporters(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1019 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1020 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
1021
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1022 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1023 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1024 menu = QMenu(self.tr("Export as"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1025
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1026 from . import Exporters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1027 supportedExporters = Exporters.getSupportedFormats()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1028 exporters = sorted(list(supportedExporters.keys()))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1029 for exporter in exporters:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1030 act = menu.addAction(supportedExporters[exporter])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1031 act.setData(exporter)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1032
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1033 menu.triggered.connect(self.__exportMenuTriggered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1034
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1035 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1036
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1037 def __initContextMenuMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1038 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1039 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
1040 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1041 self.marginMenuActs = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1042
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1043 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1044 self.__initContextMenuUnifiedMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1045 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1046 self.__initContextMenuSeparateMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1047
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1048 def __initContextMenuSeparateMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1049 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1050 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
1051 margins.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1052 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1053 # bookmark margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1054 self.bmMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1055
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1056 self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1057 self.tr('Toggle bookmark'), self.menuToggleBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1058 self.marginMenuActs["NextBookmark"] = self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1059 self.tr('Next bookmark'), self.nextBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1060 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1061 self.tr('Previous bookmark'), self.previousBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1062 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1063 self.tr('Clear all bookmarks'), self.clearBookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1064
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1065 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1066
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1067 # breakpoint margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1068 self.bpMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1069
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1070 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1071 self.tr('Toggle breakpoint'), self.menuToggleBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1072 self.marginMenuActs["TempBreakpoint"] = self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1073 self.tr('Toggle temporary breakpoint'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1074 self.__menuToggleTemporaryBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1075 self.marginMenuActs["EditBreakpoint"] = self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1076 self.tr('Edit breakpoint...'), self.menuEditBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1077 self.marginMenuActs["EnableBreakpoint"] = self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1078 self.tr('Enable breakpoint'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1079 self.__menuToggleBreakpointEnabled)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1080 self.marginMenuActs["NextBreakpoint"] = self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1081 self.tr('Next breakpoint'), self.menuNextBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1082 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
1083 self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1084 self.tr('Previous breakpoint'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1085 self.menuPreviousBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1086 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1087 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1088
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1089 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1090
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1091 # indicator margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1092 self.indicMarginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1093
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1094 self.marginMenuActs["GotoSyntaxError"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1095 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1096 self.tr('Goto syntax error'), self.gotoSyntaxError)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1097 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
1098 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1099 self.tr('Show syntax error message'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1100 self.__showSyntaxError)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1101 self.marginMenuActs["ClearSyntaxError"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1102 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1103 self.tr('Clear syntax error'), self.clearSyntaxError)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1104 self.indicMarginMenu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1105 self.marginMenuActs["NextWarningMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1106 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1107 self.tr("Next warning"), self.nextWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1108 self.marginMenuActs["PreviousWarningMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1109 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1110 self.tr("Previous warning"), self.previousWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1111 self.marginMenuActs["ShowWarning"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1112 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1113 self.tr('Show warning message'), self.__showWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1114 self.marginMenuActs["ClearWarnings"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1115 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1116 self.tr('Clear warnings'), self.clearWarnings)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1117 self.indicMarginMenu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1118 self.marginMenuActs["NextCoverageMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1119 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1120 self.tr('Next uncovered line'), self.nextUncovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1121 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
1122 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1123 self.tr('Previous uncovered line'), self.previousUncovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1124 self.indicMarginMenu.addSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1125 self.marginMenuActs["NextTaskMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1126 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1127 self.tr('Next task'), self.nextTask)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1128 self.marginMenuActs["PreviousTaskMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1129 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1130 self.tr('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
1131 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
1132 self.marginMenuActs["NextChangeMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1133 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1134 self.tr('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
1135 self.marginMenuActs["PreviousChangeMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1136 self.indicMarginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1137 self.tr('Previous change'), self.previousChange)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1138
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1139 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1140
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1141 def __initContextMenuUnifiedMargins(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1142 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1143 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
1144 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1145 self.marginMenu = QMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1146
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1147 self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1148 self.tr('Toggle bookmark'), self.menuToggleBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1149 self.marginMenuActs["NextBookmark"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1150 self.tr('Next bookmark'), self.nextBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1151 self.marginMenuActs["PreviousBookmark"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1152 self.tr('Previous bookmark'), self.previousBookmark)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1153 self.marginMenuActs["ClearBookmark"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1154 self.tr('Clear all bookmarks'), self.clearBookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1155 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1156 self.marginMenuActs["GotoSyntaxError"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1157 self.tr('Goto syntax error'), self.gotoSyntaxError)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1158 self.marginMenuActs["ShowSyntaxError"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1159 self.tr('Show syntax error message'), self.__showSyntaxError)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1160 self.marginMenuActs["ClearSyntaxError"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1161 self.tr('Clear syntax error'), self.clearSyntaxError)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1162 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1163 self.marginMenuActs["NextWarningMarker"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1164 self.tr("Next warning"), self.nextWarning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1165 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
1166 self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1167 self.tr("Previous warning"), self.previousWarning)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1168 self.marginMenuActs["ShowWarning"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1169 self.tr('Show warning message'), self.__showWarning)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1170 self.marginMenuActs["ClearWarnings"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1171 self.tr('Clear warnings'), self.clearWarnings)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1172 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1173 self.marginMenuActs["Breakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1174 self.tr('Toggle breakpoint'), self.menuToggleBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1175 self.marginMenuActs["TempBreakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1176 self.tr('Toggle temporary breakpoint'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1177 self.__menuToggleTemporaryBreakpoint)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1178 self.marginMenuActs["EditBreakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1179 self.tr('Edit breakpoint...'), self.menuEditBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1180 self.marginMenuActs["EnableBreakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1181 self.tr('Enable breakpoint'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1182 self.__menuToggleBreakpointEnabled)
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1183 self.marginMenuActs["NextBreakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1184 self.tr('Next breakpoint'), self.menuNextBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1185 self.marginMenuActs["PreviousBreakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1186 self.tr('Previous breakpoint'), self.menuPreviousBreakpoint)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1187 self.marginMenuActs["ClearBreakpoint"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1188 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1189 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1190 self.marginMenuActs["NextCoverageMarker"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1191 self.tr('Next uncovered line'), self.nextUncovered)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1192 self.marginMenuActs["PreviousCoverageMarker"] = \
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1193 self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1194 self.tr('Previous uncovered line'), self.previousUncovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1195 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1196 self.marginMenuActs["NextTaskMarker"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1197 self.tr('Next task'), self.nextTask)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1198 self.marginMenuActs["PreviousTaskMarker"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1199 self.tr('Previous task'), self.previousTask)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1200 self.marginMenu.addSeparator()
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1201 self.marginMenuActs["NextChangeMarker"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1202 self.tr('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
1203 self.marginMenuActs["PreviousChangeMarker"] = \
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1204 self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1205 self.tr('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
1206 self.marginMenu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1207 self.marginMenuActs["LMBbookmarks"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1208 self.tr('LMB toggles bookmarks'), self.__lmBbookmarks)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1209 self.marginMenuActs["LMBbookmarks"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1210 self.marginMenuActs["LMBbookmarks"].setChecked(False)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1211 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1212 self.tr('LMB toggles breakpoints'), self.__lmBbreakpoints)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1213 self.marginMenuActs["LMBbreakpoints"].setCheckable(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1214 self.marginMenuActs["LMBbreakpoints"].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1215
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
1216 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1217
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1218 def __exportMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1219 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1220 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
1221
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1222 @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
1223 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1224 exporterFormat = act.data()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1225 self.exportFile(exporterFormat)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1226
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1227 def exportFile(self, exporterFormat):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1228 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1229 Public method to export the file.
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 @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
1232 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1233 if exporterFormat:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1234 from . import Exporters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1235 exporter = Exporters.getExporter(exporterFormat, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1236 if exporter:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1237 exporter.exportSource()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1238 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1239 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1240 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1241 self.tr("Export source"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1242 self.tr(
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1243 """<p>No exporter available for the """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
1244 """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
1245 .format(exporterFormat))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1246 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1247 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1248 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1249 self.tr("Export source"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1250 self.tr("""No export format given. Aborting..."""))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1251
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1252 def __showContextMenuLanguages(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1253 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1254 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
1255 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1256 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1257 if self.apiLanguage.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1258 self.pygmentsSelAct.setText(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1259 self.tr("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
1260 self.getLanguage(normalized=False)))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1261 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1262 self.pygmentsSelAct.setText(self.tr("Alternatives"))
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
1263 self.showMenu.emit("Languages", self.languagesMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1264
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1265 def __selectPygmentsLexer(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1266 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1267 Private method to select a specific pygments lexer.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1268
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1269 @return name of the selected pygments lexer (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1270 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1271 from pygments.lexers import get_all_lexers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1272 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
1273 try:
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1274 lexerSel = lexerList.index(
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1275 self.getLanguage(normalized=False, forPygments=True))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1276 except ValueError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1277 lexerSel = 0
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
1278 lexerName, ok = QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1279 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1280 self.tr("Pygments Lexer"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1281 self.tr("Select the Pygments lexer to apply."),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1282 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
1283 lexerSel,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1284 False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1285 if ok and lexerName:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1286 return lexerName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1287 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1288 return ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1289
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1290 def __languageMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1291 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1292 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
1293
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1294 @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
1295 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1296 if act == self.noLanguageAct:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1297 self.__resetLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1298 elif act == self.pygmentsAct:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1299 self.setLanguage("dummy.pygments")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1300 elif act == self.pygmentsSelAct:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1301 language = self.__selectPygmentsLexer()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1302 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
1303 self.setLanguage("dummy.pygments", pyname=language)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1304 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1305 language = act.data()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1306 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
1307 self.filetype = language
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1308 self.setLanguage(self.supportedLanguages[language][1])
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
1309 self.checkSyntax()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1310
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1311 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
1312 """
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1313 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
1314
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1315 @param language language to be set (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1316 @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
1317 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1318 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
1319 self.__resetLanguage(propagate=propagate)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1320 elif language == "Guessed":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1321 self.setLanguage("dummy.pygments")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1322 elif language.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1323 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
1324 self.setLanguage("dummy.pygments", pyname=pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1325 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
1326 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
1327 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
1328 propagate=propagate)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
1329 self.checkSyntax()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1330
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1331 def __resetLanguage(self, propagate=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1332 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1333 Private method used to reset the language selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1334
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1335 @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
1336 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1337 if self.lexer_ is not None and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1338 (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
1339 self.SCN_STYLENEEDED.disconnect(self.__styleNeeded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1340
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1341 self.apiLanguage = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1342 self.lexer_ = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1343 self.__lexerReset = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1344 self.setLexer()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1345 if self.completer is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1346 self.completer.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1347 self.completer = None
3059
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1348 useMonospaced = self.useMonospaced
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1349 self.__setTextDisplay()
3059
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1350 self.setMonospaced(useMonospaced)
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1351 self.menuActs["MonospacedFont"].setChecked(self.useMonospaced)
92
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 if not self.inLanguageChanged and propagate:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1354 self.inLanguageChanged = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1355 self.languageChanged.emit(self.apiLanguage)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1356 self.inLanguageChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1357
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1358 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
1359 pyname=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1360 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1361 Public method to set a lexer language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1362
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1363 @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
1364 language (string)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1365 @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
1366 display is required as well (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1367 @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
1368 @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
1369 """
3059
16c93928cfc5 A little fix to the editor context menu handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1370 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
1371
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1372 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
1373 self.__bindLexer(filename, pyname=pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1374 self.__bindCompleter(filename)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1375 self.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1376 self.__checkLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1377
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1378 # set the text display
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1379 if initTextDisplay:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1380 self.__setTextDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1381
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1382 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1383 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1384 self.__setCallTips()
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 if not self.inLanguageChanged and propagate:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1387 self.inLanguageChanged = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1388 self.languageChanged.emit(self.apiLanguage)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1389 self.inLanguageChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1390
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1391 def __checkLanguage(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1392 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1393 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
1394 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1395 if self.apiLanguage == "":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1396 self.noLanguageAct.setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1397 elif self.apiLanguage == "Guessed":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1398 self.pygmentsAct.setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1399 elif self.apiLanguage.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1400 act = self.languagesActGrp.checkedAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1401 if act:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1402 act.setChecked(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1403 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1404 self.supportedLanguages[self.apiLanguage][2].setChecked(True)
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 def projectLexerAssociationsChanged(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1407 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1408 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
1409 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1410 self.setLanguage(self.fileName)
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 def __showContextMenuEncodings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1413 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1414 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
1415 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1416 """
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
1417 self.showMenu.emit("Encodings", self.encodingsMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1418
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1419 def __encodingsMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1420 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1421 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
1422
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1423 @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
1424 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1425 encoding = act.data()
3393
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1426 self.setModified(True)
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
1427 self.__encodingChanged("{0}-selected".format(encoding))
92
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 __checkEncoding(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 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
1432 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1433 try:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1434 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
1435 .setChecked(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1436 except (AttributeError, KeyError):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1437 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1438
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1439 def __encodingChanged(self, encoding, propagate=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1440 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1441 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
1442
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1443 @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
1444 @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
1445 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1446 self.encoding = encoding
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1447 self.__checkEncoding()
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 not self.inEncodingChanged and propagate:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1450 self.inEncodingChanged = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1451 self.encodingChanged.emit(self.encoding)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1452 self.inEncodingChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1453
3393
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1454 def __normalizedEncoding(self, encoding=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1455 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1456 Private method to calculate the normalized encoding string.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1457
3393
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1458 @param encoding encoding to be normalized (string)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1459 @return normalized encoding (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1460 """
3393
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1461 if not encoding:
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1462 encoding = self.encoding
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1463 return encoding.replace("-default", "")\
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1464 .replace("-guessed", "")\
080ace4829b4 Extended QsciScintillaCompat to allow to set the modified status and made the selection of an encoding in the editor change the modified state.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3341
diff changeset
1465 .replace("-selected", "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1466
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1467 def __showContextMenuEol(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1468 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1469 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
1470 """
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
1471 self.showMenu.emit("Eol", self.eolMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1472
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1473 def __eolMenuTriggered(self, act):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1474 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1475 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
1476
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1477 @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
1478 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1479 eol = act.data()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1480 self.setEolModeByEolString(eol)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1481 self.convertEols(self.eolMode())
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 def __checkEol(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1484 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1485 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
1486 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1487 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1488 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
1489 except (AttributeError, TypeError):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1490 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1491
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1492 def __eolChanged(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1493 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1494 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
1495 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1496 self.__checkEol()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1497
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1498 if not self.inEolChanged:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1499 self.inEolChanged = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1500 eol = self.getLineSeparator()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1501 self.eolChanged.emit(eol)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1502 self.inEolChanged = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1503
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1504 def __bindLexer(self, filename, pyname=""):
92
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 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
1507
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1508 @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
1509 language (string)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1510 @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
1511 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1512 if self.lexer_ is not None and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1513 (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
1514 self.SCN_STYLENEEDED.disconnect(self.__styleNeeded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1515
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1516 language = ""
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1517 if not self.filetype:
4227
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1518 if filename:
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1519 basename = os.path.basename(filename)
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1520 if self.project.isOpen() and \
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1521 self.project.isProjectFile(filename):
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1522 language = self.project.getEditorLexerAssoc(basename)
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1523 if not language:
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
1524 language = Preferences.getEditorLexerAssoc(basename)
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1525 if not language:
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1526 bindName = self.__bindName(self.text(0))
4170
8bc578136279 Fixed an issue in the editor causing a traceback when setting a language for an empty editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4153
diff changeset
1527 if bindName:
8bc578136279 Fixed an issue in the editor causing a traceback when setting a language for an empty editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4153
diff changeset
1528 language = Preferences.getEditorLexerAssoc(bindName)
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1529 if language == "Python":
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1530 # correction for Python
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1531 pyVer = Utilities.determinePythonVersion(
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1532 filename, self.text(0), self)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1533 language = "Python{0}".format(pyVer)
3525
66f4b8646622 Reintegrated the js syntax checker and therefore improved the background service a little.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3496
diff changeset
1534 if language in ['Python2', 'Python3', 'Ruby', 'JavaScript']:
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1535 self.filetype = language
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
1536 else:
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1537 self.filetype = ""
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1538 else:
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1539 language = self.filetype
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1540
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1541 if language.startswith("Pygments|"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1542 pyname = language.split("|", 1)[1]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1543 language = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1544
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1545 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
1546 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
1547 if self.lexer_ is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1548 self.setLexer()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1549 self.apiLanguage = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1550 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1551
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1552 if pyname:
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
1553 self.apiLanguage = "Pygments|{0}".format(pyname)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1554 else:
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3525
diff changeset
1555 # Change API language for lexer where QScintilla reports
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3525
diff changeset
1556 # an abbreviated name.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1557 self.apiLanguage = self.lexer_.language()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1558 if self.apiLanguage == "POV":
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1559 self.apiLanguage = "Povray"
3557
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3525
diff changeset
1560 elif self.apiLanguage == "PO":
3ea8ba471d96 Added support for the QScintilla Gettext lexer (QsciLexerPO) as of QScintilla 2.8.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3525
diff changeset
1561 self.apiLanguage = "Gettext"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1562 self.setLexer(self.lexer_)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1563 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1564 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
1565 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
1566 self.SCN_STYLENEEDED.connect(self.__styleNeeded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1567
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1568 # 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
1569 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
1570 fdesc = Preferences.Prefs.settings.value(key)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1571 if fdesc is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1572 font = QFont(fdesc[0], int(fdesc[1]))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1573 self.lexer_.setDefaultFont(font)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1574 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla")
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 # now set the lexer properties
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1577 self.lexer_.initProperties()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1578
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1579 # initialize the lexer APIs settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1580 api = self.vm.getAPIsManager().getAPIs(self.apiLanguage)
4133
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
1581 if api is not None and not api.isEmpty():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1582 self.lexer_.setAPIs(api.getQsciAPIs())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1583 self.acAPI = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1584 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1585 self.acAPI = False
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1586 self.autoCompletionAPIsAvailable.emit(self.acAPI)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1587
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
1588 self.__setAnnotationStyles()
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
1589
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
1590 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
1591 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
1592
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1593 def __styleNeeded(self, position):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1594 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1595 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
1596
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1597 @param position end position, that needs styling (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1598 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1599 self.lexer_.styleText(self.getEndStyled(), position)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1600
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1601 def getLexer(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 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
1604
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1605 @return the lexer object (Lexer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1606 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1607 return self.lexer_
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1608
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1609 def getLanguage(self, normalized=True, forPygments=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1610 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1611 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
1612
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1613 @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
1614 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
1615 @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
1616 names for Pygments (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1617 @return language of the editor (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1618 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1619 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
1620 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
1621 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
1622 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
1623 # 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
1624 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
1625 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
1626 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
1627 lang = "Python3"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1628 else:
1295
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1629 lang = self.apiLanguage
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1630 if forPygments:
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1631 # 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
1632 if lang == "Python2":
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1633 lang = "Python"
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1634 elif lang == "Python3":
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1635 lang = "Python 3"
b3db3070d104 Fixed an issue in the editor setting the correct language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1196
diff changeset
1636 return lang
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1637
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1638 def __bindCompleter(self, filename):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1639 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1640 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
1641
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1642 @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
1643 completer language (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1644 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1645 if self.completer is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1646 self.completer.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1647 self.completer = None
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 filename = os.path.basename(filename)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1650 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
1651 if apiLanguage == "":
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1652 pyVer = self.__getPyVersion()
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1653 if pyVer:
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1654 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
1655 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
1656 apiLanguage = "Ruby"
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1657
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
1658 from . import TypingCompleters
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1659 self.completer = TypingCompleters.getCompleter(apiLanguage, self)
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 def getCompleter(self):
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 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
1664
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1665 @return the completer object (CompleterBase)
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 return self.completer
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 def __modificationChanged(self, m):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1670 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1671 Private slot to handle the modificationChanged signal.
92
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 It emits the signal modificationStatusChanged with parameters
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1674 m and self.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1675
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1676 @param m modification status
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1677 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1678 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
1679 self.lastModified = QFileInfo(self.fileName).lastModified()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
1680 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
1681 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
1682 self.redoAvailable.emit(self.isRedoAvailable())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1683
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1684 def __cursorPositionChanged(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1685 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1686 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
1687
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1688 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
1689 line and pos.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1690
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1691 @param line line number of the cursor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1692 @param index position in line of the cursor
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1693 """
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 478
diff changeset
1694 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
1695
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1696 if Preferences.getEditor("MarkOccurrencesEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1697 self.__markOccurrencesTimer.stop()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1698 self.__markOccurrencesTimer.start()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1699
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
1700 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
1701 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
1702
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1703 if self.spell is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1704 # do spell checking
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1705 doSpelling = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1706 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
1707 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
1708 line, index, useWordChars=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1709 if start <= self.lastIndex and self.lastIndex <= end:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1710 doSpelling = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1711 if doSpelling:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1712 pos = self.positionFromLineIndex(self.lastLine, self.lastIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1713 self.spell.checkWord(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1714
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
1715 if self.lastLine != line:
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
1716 self.__markerMap.update()
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
1717
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1718 self.lastLine = line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1719 self.lastIndex = index
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1720
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1721 def __modificationReadOnly(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1722 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1723 Private slot to handle the modificationAttempted signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1724 """
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1725 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
1726 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1727 self.tr("Modification of Read Only file"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1728 self.tr("""You are attempting to change a read only file. """
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
1729 """Please save to a different file first."""))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1730
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1731 def setNoName(self, noName):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1732 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1733 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
1734
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1735 @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
1736 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1737 self.noName = noName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1738
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1739 def getNoName(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1740 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1741 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
1742
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1743 @return display string for this unnamed editor (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1744 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1745 return self.noName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1746
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1747 def getFileName(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1748 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1749 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
1750
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1751 @return filename of the displayed file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1752 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1753 return self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1754
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1755 def getFileType(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1756 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1757 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
1758
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1759 @return type of the displayed file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1760 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1761 return self.filetype
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1762
795
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1763 def getFileTypeByFlag(self):
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1764 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1765 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
1766 eflag: marker.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1767
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1768 @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
1769 empty string (string)
795
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1770 """
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1771 if self.filetypeByFlag:
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1772 return self.filetype
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1773 else:
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1774 return ""
917f1945355c Added a syntax checker function for Python 2 files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1775
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
1776 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
1777 """
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
1778 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
1779
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
1780 @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
1781 """
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
1782 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
1783 if not ftype:
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1784 pyVer = self.__getPyVersion()
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1785 if pyVer:
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1786 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
1787 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
1788 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
1789 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
1790 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
1791
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
1792 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
1793
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1794 def getEncoding(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1795 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1796 Public method to return the current encoding.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1797
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1798 @return current encoding (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1799 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1800 return self.encoding
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1801
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1802 def __getPyVersion(self):
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1803 """
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1804 Private method to return the Python main version (2 or 3) or 0 if it's
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1805 not a Python file at all.
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1806
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1807 @return Python version (2 or 3) or 0 if it's not a Python file (int)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1808 """
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1809 return Utilities.determinePythonVersion(
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1810 self.fileName, self.text(0), self)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1811
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1812 def isPyFile(self):
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1813 """
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1814 Public method to return a flag indicating a Python (2 or 3) file.
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1815
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1816 @return flag indicating a Python (2 or 3) file (boolean)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1817 """
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1818 return self.__getPyVersion() in [2, 3]
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1819
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
1820 def isPy2File(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1821 """
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1822 Public method to return a flag indicating a Python2 file.
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1823
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1824 @return flag indicating a Python2 file (boolean)
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1825 """
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1826 return self.__getPyVersion() == 2
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1827
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1828 def isPy3File(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1829 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1830 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
1831
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1832 @return flag indicating a Python3 file (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1833 """
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
1834 return self.__getPyVersion() == 3
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1835
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1836 def isRubyFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1837 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1838 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
1839
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1840 @return flag indicating a Ruby file (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1841 """
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
1842 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
1843 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
1844
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
1845 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
1846 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
1847 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
1848 "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
1849 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
1850 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
1851
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
1852 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
1853 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
1854 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
1855 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
1856 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
1857
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
1858 return False
3438
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1859
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1860 def isJavascriptFile(self):
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1861 """
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1862 Public method to return a flag indicating a Javascript file.
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1863
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1864 @return flag indicating a Javascript file (boolean)
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1865 """
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1866 if self.filetype == "JavaScript":
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1867 return True
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1868
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1869 if self.filetype == "":
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1870 if self.fileName is not None and \
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1871 os.path.splitext(self.fileName)[1] == ".js":
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1872 self.filetype = "JavaScript"
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1873 return True
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1874
29717a5e8b97 Started improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3395
diff changeset
1875 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
1876
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1877 def highlightVisible(self):
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 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
1880 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1881 if self.lastHighlight is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1882 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
1883 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
1884
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
1885 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
1886 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1887 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
1888
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1889 @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
1890 @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
1891 used (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1892 @param syntaxError flag indicating a syntax error (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1893 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1894 if line is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1895 self.lastHighlight = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1896 if self.lastErrorMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1897 self.markerDeleteHandle(self.lastErrorMarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1898 self.lastErrorMarker = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1899 if self.lastCurrMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1900 self.markerDeleteHandle(self.lastCurrMarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1901 self.lastCurrMarker = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1902 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1903 if error:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1904 if self.lastErrorMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1905 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
1906 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
1907 self.lastHighlight = self.lastErrorMarker
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1908 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1909 if self.lastCurrMarker is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1910 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
1911 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
1912 self.currentline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1913 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
1914 self.setCursorPosition(line - 1, 0)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1915
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1916 def getHighlightPosition(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1917 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1918 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
1919
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1920 @return line number of the highlight bar (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1921 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1922 if self.lastHighlight is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1923 return self.markerLine(self.lastHighlight)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1924 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1925 return 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1926
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1927 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1928 ## 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
1929 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1930
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1931 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
1932 foldPrev, token, annotationLinesAdded):
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1933 """
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1934 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
1935
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1936 @param pos start position of change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1937 @param mtype flags identifying the change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1938 @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
1939 @param length length of the change (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1940 @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
1941 @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
1942 @param foldNow new fold level (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1943 @param foldPrev previous fold level (integer)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1944 @param token ???
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1945 @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
1946 (integer)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1947 """
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1948 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
1949 linesAdded != 0:
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1950 if self.breaks:
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1951 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
1952 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
1953 self.breaks.items():
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1954 line = self.markerLine(handle) + 1
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1955 if ln != line:
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1956 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
1957 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
1958 ignorecount)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1959 self.inLinesChanged = True
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1960 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
1961 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
1962 self.fileName, ln)
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1963 index2 = self.breakpointModel.index(index1.row(), 1)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1964 self.breakpointModel.setData(index2, line)
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
1965 self.inLinesChanged = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1966
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1967 def __restoreBreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1968 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1969 Private method to restore the breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1970 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1971 for handle in list(self.breaks.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1972 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
1973 self.__addBreakPoints(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
1974 QModelIndex(), 0, self.breakpointModel.rowCount() - 1)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
1975 self.__markerMap.update()
92
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 def __deleteBreakPoints(self, parentIndex, start, end):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1978 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1979 Private slot to delete breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1980
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1981 @param parentIndex index of parent item (QModelIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1982 @param start start row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1983 @param end end row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1984 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1985 for row in range(start, end + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1986 index = self.breakpointModel.index(row, 0, parentIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1987 fn, lineno = self.breakpointModel.getBreakPointByIndex(index)[0:2]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1988 if fn == self.fileName:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1989 self.clearBreakpoint(lineno)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1990
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1991 def __changeBreakPoints(self, startIndex, endIndex):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1992 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1993 Private slot to set changed breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1994
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1995 @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
1996 (QModelIndex)
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
1997 @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
1998 (QModelIndex)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
1999 """
1928
adde55ed4ce5 Fixed the breakpoint performance issue properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
2000 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
2001 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
2002 endIndex.row())
92
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 def __breakPointDataAboutToBeChanged(self, startIndex, endIndex):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2005 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
2006 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
2007 breakpoint model.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2008
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2009 @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
2010 @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
2011 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2012 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
2013 endIndex.row())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2014
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2015 def __addBreakPoints(self, parentIndex, start, end):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2016 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2017 Private slot to add breakpoints.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2018
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2019 @param parentIndex index of parent item (QModelIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2020 @param start start row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2021 @param end end row (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2022 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2023 for row in range(start, end + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2024 index = self.breakpointModel.index(row, 0, parentIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2025 fn, line, cond, temp, enabled, ignorecount = \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2026 self.breakpointModel.getBreakPointByIndex(index)[:6]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2027 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
2028 self.newBreakpointWithProperties(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2029 line, (cond, temp, enabled, ignorecount))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2030
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2031 def clearBreakpoint(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2032 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2033 Public method to clear a breakpoint.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2034
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2035 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
2036 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
2037
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2038 @param line linenumber of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2039 """
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
2040 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
2041 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
2042
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2043 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
2044 if self.markerLine(handle) == line - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2045 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2046 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2047 # not found, simply ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2048 return
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 del self.breaks[handle]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2051 self.markerDeleteHandle(handle)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2052 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2053
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2054 def newBreakpointWithProperties(self, line, properties):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2055 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
2056 Public method to set a new breakpoint and its properties.
92
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 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2059 @param properties properties for the breakpoint (tuple)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2060 (condition, temporary flag, enabled flag, ignore count)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2061 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2062 if not properties[2]:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2063 marker = self.dbreakpoint
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2064 elif properties[0]:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2065 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
2066 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2067 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
2068
1930
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
2069 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
2070 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
2071 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
2072 self.breakpointToggled.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2073 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2074
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2075 def __toggleBreakpoint(self, line, temporary=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2076 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2077 Private method to toggle a breakpoint.
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 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2080 @param temporary flag indicating a temporary breakpoint (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2081 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2082 for handle, (ln, _, _, _, _) in list(self.breaks.items()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2083 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2084 # 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
2085 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
2086 self.fileName, line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2087 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
2088 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
2089 index):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2090 self.breakpointModel.deleteBreakPointByIndex(index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2091 self.__addBreakPoint(line, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2092 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2093 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
2094 self.breakpointToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2095 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2096 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2097 self.__addBreakPoint(line, temporary)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2098
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2099 def __addBreakPoint(self, line, temporary):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2100 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2101 Private method to add a new breakpoint.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2102
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2103 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2104 @param temporary flag indicating a temporary breakpoint (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2105 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2106 if self.fileName and \
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
2107 (self.isPyFile() or self.isRubyFile()):
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2108 self.breakpointModel.addBreakPoint(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2109 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
2110 self.breakpointToggled.emit(self)
92
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 __toggleBreakpointEnabled(self, line):
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 Private method to toggle a breakpoints enabled status.
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 @param line line number of the breakpoint (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2117 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2118 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
2119 self.breaks.items():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2120 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2121 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2122 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2123 # no breakpoint found on that line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2124 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2125
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2126 index = self.breakpointModel.getBreakPointIndex(self.fileName, line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2127 self.breakpointModel.setBreakPointEnabledByIndex(index, not enabled)
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 curLineHasBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2130 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2131 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
2132 line.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2133
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2134 @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
2135 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2136 line, _ = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2137 return self.markersAtLine(line) & self.breakpointMask != 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2138
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2139 def getBreakpointLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2140 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2141 Public method to get the lines containing a breakpoint.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2142
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2143 @return list of lines containing a breakpoint (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2144 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2145 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2146 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2147 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2148 line = self.markerFindNext(line + 1, self.breakpointMask)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2149 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2150 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2151 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2152 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2153 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2154
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2155 def hasBreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2156 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2157 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
2158
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2159 @return flag indicating the presence of breakpoints (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2160 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2161 return len(self.breaks) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2162
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2163 def __menuToggleTemporaryBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2164 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2165 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
2166 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2167 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2168 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2169 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2170 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2171 self.__toggleBreakpoint(self.line, 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2172 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2173
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2174 def menuToggleBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2175 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2176 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
2177 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2178 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2179 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2180 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2181 self.__toggleBreakpoint(self.line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2182 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2183
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2184 def __menuToggleBreakpointEnabled(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2185 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2186 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
2187 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2188 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2189 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2190 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2191 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2192 self.__toggleBreakpointEnabled(self.line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2193 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2194
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2195 def menuEditBreakpoint(self, line=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2196 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2197 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
2198
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2199 @param line linenumber of the breakpoint to edit
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2200 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2201 if line is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2202 self.line = line - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2203 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2204 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2205 found = False
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2206 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
2207 self.breaks.items():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2208 if self.markerLine(handle) == self.line:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2209 found = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2210 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2211
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2212 if found:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2213 index = self.breakpointModel.getBreakPointIndex(self.fileName, ln)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2214 if not index.isValid():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2215 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2216
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2217 from Debugger.EditBreakpointDialog import EditBreakpointDialog
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2218 dlg = EditBreakpointDialog(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2219 (self.fileName, ln),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2220 (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
2221 self.condHistory, self, modal=True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2222 if dlg.exec_() == QDialog.Accepted:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2223 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
2224 self.breakpointModel.setBreakPointByIndex(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2225 index, self.fileName, ln,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
2226 (cond, temp, enabled, ignorecount))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2227
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2228 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2229
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2230 def menuNextBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2231 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2232 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
2233 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2234 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
2235 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2236 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2237 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2238 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2239 bpline = self.markerFindNext(line, self.breakpointMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2240 if bpline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2241 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2242 bpline = self.markerFindNext(0, self.breakpointMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2243 if bpline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2244 self.setCursorPosition(bpline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2245 self.ensureLineVisible(bpline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2246
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2247 def menuPreviousBreakpoint(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2248 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2249 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
2250 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2251 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2252 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
2253 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2254 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2255 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2256 bpline = self.markerFindPrevious(line, self.breakpointMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2257 if bpline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2258 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2259 bpline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2260 self.lines() - 1, self.breakpointMask)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2261 if bpline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2262 self.setCursorPosition(bpline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2263 self.ensureLineVisible(bpline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2264
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2265 def __menuClearBreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2266 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2267 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
2268 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2269 self.__clearBreakpoints(self.fileName)
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 __clearBreakpoints(self, fileName):
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 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
2274
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
2275 @param fileName name of the file (string)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2276 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2277 idxList = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2278 for handle, (ln, _, _, _, _) in list(self.breaks.items()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2279 index = self.breakpointModel.getBreakPointIndex(fileName, ln)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2280 if index.isValid():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2281 idxList.append(index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2282 if idxList:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2283 self.breakpointModel.deleteBreakPoints(idxList)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2284
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2285 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2286 ## 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
2287 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2288
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2289 def toggleBookmark(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2290 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2291 Public method to toggle a bookmark.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2292
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2293 @param line line number of the bookmark (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2294 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2295 for handle in self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2296 if self.markerLine(handle) == line - 1:
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2297 self.bookmarks.remove(handle)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2298 self.markerDeleteHandle(handle)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2299 break
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 # set a new bookmark
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2302 handle = self.markerAdd(line - 1, self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2303 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
2304 self.bookmarkToggled.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2305 self.__markerMap.update()
92
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 getBookmarks(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 method to retrieve the bookmarks.
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 @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
2312 (list of integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2313 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2314 bmlist = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2315 for handle in self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2316 bmlist.append(self.markerLine(handle) + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2317
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2318 bmlist.sort()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2319 return bmlist
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2320
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2321 def getBookmarkLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2322 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2323 Public method to get the lines containing a bookmark.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2324
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2325 @return list of lines containing a bookmark (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2326 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2327 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2328 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2329 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2330 line = self.markerFindNext(line + 1, 1 << self.bookmark)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2331 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2332 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2333 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2334 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2335 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2336
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2337 def hasBookmarks(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 check for the presence of bookmarks.
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 bookmarks (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 len(self.bookmarks) > 0
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 menuToggleBookmark(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 'Toggle bookmark' 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 if self.line < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2350 self.line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2351 self.line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2352 self.toggleBookmark(self.line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2353 self.line = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2354
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2355 def nextBookmark(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2356 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2357 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
2358 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2359 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
2360 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2361 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2362 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2363 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2364 bmline = self.markerFindNext(line, 1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2365 if bmline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2366 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2367 bmline = self.markerFindNext(0, 1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2368 if bmline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2369 self.setCursorPosition(bmline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2370 self.ensureLineVisible(bmline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2371
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2372 def previousBookmark(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2373 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2374 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
2375 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2376 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2377 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
2378 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2379 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2380 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2381 bmline = self.markerFindPrevious(line, 1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2382 if bmline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2383 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2384 bmline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2385 self.lines() - 1, 1 << self.bookmark)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2386 if bmline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2387 self.setCursorPosition(bmline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2388 self.ensureLineVisible(bmline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2389
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2390 def clearBookmarks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2391 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2392 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
2393 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2394 for handle in self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2395 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2396 self.bookmarks = []
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2397 self.bookmarkToggled.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2398 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2399
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2400 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2401 ## 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
2402 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2403
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2404 def printFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2405 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2406 Public slot to print the text.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2407 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2408 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
2409 printer = Printer(mode=QPrinter.HighResolution)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2410 sb = e5App().getObject("UserInterface").statusBar()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2411 printDialog = QPrintDialog(printer, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2412 if self.hasSelectedText():
4074
95c24977f68f Fixed an issue in the editor and minieditor caused by using an obsolete method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4029
diff changeset
2413 printDialog.setOption(QAbstractPrintDialog.PrintSelection, True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2414 if printDialog.exec_() == QDialog.Accepted:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2415 sb.showMessage(self.tr('Printing...'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2416 QApplication.processEvents()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2417 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2418 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2419 printer.setDocName(os.path.basename(fn))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2420 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2421 printer.setDocName(self.noName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2422 if printDialog.printRange() == QAbstractPrintDialog.Selection:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2423 # get the selection
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2424 fromLine, fromIndex, toLine, toIndex = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2425 if toIndex == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2426 toLine -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2427 # 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
2428 res = printer.printRange(self, fromLine, toLine - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2429 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2430 res = printer.printRange(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2431 if res:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2432 sb.showMessage(self.tr('Printing completed'), 2000)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2433 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2434 sb.showMessage(self.tr('Error while printing'), 2000)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2435 QApplication.processEvents()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2436 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2437 sb.showMessage(self.tr('Printing aborted'), 2000)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2438 QApplication.processEvents()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2439
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2440 def printPreviewFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2441 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2442 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
2443 """
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
2444 from PyQt5.QtPrintSupport import QPrintPreviewDialog
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2445 from .Printer import Printer
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2446
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
2447 printer = Printer(mode=QPrinter.HighResolution)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2448 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2449 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2450 printer.setDocName(os.path.basename(fn))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2451 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2452 printer.setDocName(self.noName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2453 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
2454 preview.paintRequested.connect(self.__printPreview)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2455 preview.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2456
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2457 def __printPreview(self, printer):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2458 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2459 Private slot to generate a print preview.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2460
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2461 @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
2462 (QScintilla.Printer.Printer)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2463 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2464 printer.printRange(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2465
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2466 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2467 ## 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
2468 ###########################################################################
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2469
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2470 def getTaskLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2471 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2472 Public method to get the lines containing a task.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2473
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2474 @return list of lines containing a task (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2475 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2476 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2477 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2478 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2479 line = self.markerFindNext(line + 1, 1 << self.taskmarker)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2480 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2481 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2482 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2483 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2484 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2485
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2486 def hasTaskMarkers(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2487 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2488 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
2489
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2490 @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
2491 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2492 return self.__hasTaskMarkers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2493
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2494 def nextTask(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2495 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2496 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
2497 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2498 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
2499 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2500 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2501 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2502 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2503 taskline = self.markerFindNext(line, 1 << self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2504 if taskline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2505 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2506 taskline = self.markerFindNext(0, 1 << self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2507 if taskline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2508 self.setCursorPosition(taskline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2509 self.ensureLineVisible(taskline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2510
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2511 def previousTask(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2512 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2513 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
2514 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2515 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2516 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
2517 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2518 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2519 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2520 taskline = self.markerFindPrevious(line, 1 << self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2521 if taskline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2522 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2523 taskline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2524 self.lines() - 1, 1 << self.taskmarker)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2525 if taskline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2526 self.setCursorPosition(taskline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2527 self.ensureLineVisible(taskline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2528
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2529 def extractTasks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2530 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2531 Public slot to extract all tasks.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2532 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
2533 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
2534 markers = {
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2535 Task.TypeWarning:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2536 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
2537 Task.TypeNote:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2538 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
2539 Task.TypeTodo:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2540 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
2541 Task.TypeFixme:
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2542 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
2543 }
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2544 txtList = self.text().split(self.getLineSeparator())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2545
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2546 # clear all task markers and tasks
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2547 self.markerDeleteAll(self.taskmarker)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2548 self.taskViewer.clearFileTasks(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2549 self.__hasTaskMarkers = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2550
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2551 # now search tasks and record them
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2552 lineIndex = -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2553 for line in txtList:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2554 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
2555 shouldBreak = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2556
1819
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2557 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
2558 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
2559 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
2560 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
2561 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
2562 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
2563 self.taskViewer.addFileTask(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2564 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
2565 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
2566 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
2567 break
cfcfd617216a Changed the tasks handling to allow for more fine grained task designations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
2568 if shouldBreak:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2569 break
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
2570 self.taskMarkersUpdated.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2571 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2572
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2573 ###########################################################################
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
2574 ## 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
2575 ###########################################################################
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2576
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2577 def __createChangeMarkerPixmap(self, key, size=16, width=4):
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2578 """
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2579 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
2580
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2581 @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
2582 @param size size of the pixmap (integer)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2583 @param width width of the marker line (integer)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2584 @return create pixmap (QPixmap)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2585 """
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2586 pixmap = QPixmap(size, size)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2587 pixmap.fill(Qt.transparent)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2588 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
2589 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
2590 Preferences.getEditorColour(key))
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2591 painter.end()
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2592 return pixmap
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2593
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
2594 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
2595 """
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
2596 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
2597 """
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
2598 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
2599 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
2600 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
2601 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
2602 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
2603 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
2604 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
2605 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
2606 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
2607 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
2608
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
2609 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
2610 """
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
2611 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
2612 """
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
2613 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
2614 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
2615 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
2616
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
2617 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
2618 """
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
2619 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
2620 """
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
2621 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
2622 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
2623 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
2624
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
2625 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
2626 """
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
2627 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
2628 """
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
2629 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
2630
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2631 # 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
2632 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
2633 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
2634 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
2635
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2636 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
2637 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
2638 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
2639 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
2640 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
2641
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2642 # 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
2643 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
2644 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
2645 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
2646
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
2647 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
2648 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
2649 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
2650 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
2651 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
2652
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
2653 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
2654 self.changeMarkersUpdated.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2655 self.__markerMap.update()
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
2656
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
2657 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
2658 """
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
2659 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
2660 """
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2661 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
2662 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
2663
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2664 # 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
2665 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
2666 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
2667 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
2668
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2669 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
2670 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
2671 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
2672 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
2673 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
2674
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2675 if self.__hasChangeMarkers:
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2676 self.changeMarkersUpdated.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2677 self.__markerMap.update()
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
2678
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
2679 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
2680 """
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
2681 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
2682 """
2164
d67b14a3f884 Improved the change tracing function by marking saved and unsaved changes differently.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2163
diff changeset
2683 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
2684 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
2685 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
2686 self.changeMarkersUpdated.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
2687 self.__markerMap.update()
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
2688
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2689 def getChangeLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2690 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2691 Public method to get the lines containing a change.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2692
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2693 @return list of lines containing a change (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2694 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2695 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2696 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2697 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2698 line = self.markerFindNext(line + 1, self.changeMarkersMask)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2699 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2700 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2701 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2702 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2703 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
2704
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
2705 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
2706 """
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
2707 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
2708
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
2709 @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
2710 """
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
2711 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
2712
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
2713 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
2714 """
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
2715 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
2716 """
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
2717 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
2718 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
2719 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
2720 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
2721 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
2722 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
2723 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
2724 # 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
2725 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
2726 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
2727 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
2728 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
2729
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
2730 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
2731 """
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
2732 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
2733 """
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
2734 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
2735 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
2736 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
2737 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
2738 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
2739 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
2740 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
2741 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2742 changeline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2743 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
2744 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
2745 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
2746 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
2747
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2748 ###########################################################################
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
2749 ## 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
2750 ###########################################################################
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
2751
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
2752 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
2753 """
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
2754 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
2755
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2756 @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
2757 """
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
2758 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
2759 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
2760
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2761 changedFlags = []
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2762
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
2763 # 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
2764 if "FileType" in flags:
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2765 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
2766 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
2767 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
2768 self.filetypeByFlag = True
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2769 if oldFiletype != self.filetype:
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2770 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
2771 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
2772 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
2773 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
2774 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
2775 self.__bindName(txt.splitlines()[0])
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2776 changedFlags.append("FileType")
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2777
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
2778 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
2779
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2780 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2781 ## 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
2782 ###########################################################################
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
2783
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2784 def checkDirty(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2785 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2786 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
2787
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2788 @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
2789 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2790 if self.isModified():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2791 fn = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2792 if fn is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2793 fn = self.noName
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2794 res = E5MessageBox.okToClearData(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2795 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2796 self.tr("File Modified"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2797 self.tr("<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
2798 .format(fn),
549
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2799 self.saveFile)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2800 if res:
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2801 self.vm.setEditorName(self, self.fileName)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 548
diff changeset
2802 return res
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2803
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2804 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2805
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2806 def revertToUnmodified(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2807 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2808 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
2809 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2810 undo_ = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2811 while self.isModified():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2812 if undo_:
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
2813 # try undo first
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2814 if self.isUndoAvailable():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2815 self.undo()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2816 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2817 undo_ = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2818 else:
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
2819 # try redo next
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2820 if self.isRedoAvailable():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2821 self.redo()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2822 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2823 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2824 # Couldn't find the unmodified state
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2825
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2826 def readFile(self, fn, createIt=False, encoding=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2827 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2828 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
2829
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2830 @param fn filename to read from (string)
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2831 @keyparam createIt flag indicating the creation of a new file, if the
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
2832 given one doesn't exist (boolean)
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2833 @keyparam encoding encoding to be used to read the file (string)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2834 (Note: this parameter overrides encoding detection)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2835 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2836 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2837
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2838 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2839 if createIt and not os.path.exists(fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2840 f = open(fn, "w")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2841 f.close()
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2842 if encoding:
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2843 txt, self.encoding = Utilities.readEncodedFileWithEncoding(
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2844 fn, encoding)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2845 else:
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
2846 txt, self.encoding = Utilities.readEncodedFile(fn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2847 except (UnicodeDecodeError, IOError) as why:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2848 QApplication.restoreOverrideCursor()
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2849 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2850 self.vm,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2851 self.tr('Open File'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2852 self.tr('<p>The file <b>{0}</b> could not be opened.</p>'
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2853 '<p>Reason: {1}</p>')
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2854 .format(fn, str(why)))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2855 QApplication.restoreOverrideCursor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2856 raise
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2857 fileEol = self.detectEolString(txt)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2858
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2859 modified = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2860 if (not Preferences.getEditor("TabForIndentation")) and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2861 Preferences.getEditor("ConvertTabsOnLoad") and \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
2862 not (self.lexer_ and
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2863 self.lexer_.alwaysKeepTabs()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2864 txtExpanded = txt.expandtabs(Preferences.getEditor("TabWidth"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2865 if txtExpanded != txt:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2866 modified = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2867 txt = txtExpanded
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2868 del txtExpanded
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2869
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2870 self.setText(txt)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2871
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
2872 # 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
2873 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
2874
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2875 # perform automatic eol conversion
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2876 if Preferences.getEditor("AutomaticEOLConversion"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2877 self.convertEols(self.eolMode())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2878 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2879 self.setEolModeByEolString(fileEol)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2880
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2881 self.extractTasks()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2882
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2883 QApplication.restoreOverrideCursor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2884
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2885 self.setModified(modified)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2886 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2887
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2888 def __removeTrailingWhitespace(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2889 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2890 Private method to remove trailing whitespace.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2891 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2892 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
2893
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2894 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
2895 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2896 while ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2897 self.replaceTarget("")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2898 ok = self.findNextTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2899 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2900
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2901 def writeFile(self, fn, backup=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2902 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2903 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
2904
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2905 @param fn filename to write to (string)
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2906 @param backup flag indicating to save a backup (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2907 @return flag indicating success (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2908 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2909 if Preferences.getEditor("StripTrailingWhitespace"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2910 self.__removeTrailingWhitespace()
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 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
2913 # 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
2914 # that the last line is terminated properly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2915 eol = self.getLineSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2916 if eol:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2917 if len(txt) >= len(eol):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2918 if txt[-len(eol):] != eol:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2919 txt += eol
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2920 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2921 txt += eol
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2922
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2923 # create a backup file, if the option is set
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2924 createBackup = backup and Preferences.getEditor("CreateBackupFile")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2925 if createBackup:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2926 if os.path.islink(fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2927 fn = os.path.realpath(fn)
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
2928 bfn = '{0}~'.format(fn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2929 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2930 permissions = os.stat(fn).st_mode
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2931 perms_valid = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2932 except EnvironmentError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2933 # if there was an error, ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2934 perms_valid = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2935 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2936 os.remove(bfn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2937 except EnvironmentError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2938 # if there was an error, ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2939 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2940 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2941 os.rename(fn, bfn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2942 except EnvironmentError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2943 # if there was an error, ignore it
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2944 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2945
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2946 # now write text to the file fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2947 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2948 self.encoding = Utilities.writeEncodedFile(fn, txt, self.encoding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2949 if createBackup and perms_valid:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2950 os.chmod(fn, permissions)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2951 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2952 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
2953 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
2954 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2955 self.tr('Save File'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2956 self.tr('<p>The file <b>{0}</b> could not be saved.<br/>'
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
2957 'Reason: {1}</p>')
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
2958 .format(fn, str(why)))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2959 return False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
2960
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2961 def __getSaveFileName(self, path=None):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2962 """
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2963 Private method to get the name of the file to be saved.
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2964
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2965 @param path directory to save the file in (string)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2966 @return file name (string)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2967 """
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2968 # save to project, if a project is loaded
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2969 if self.project.isOpen():
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2970 if self.fileName is not None and \
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2971 self.project.startswithProjectPath(self.fileName):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2972 path = os.path.dirname(self.fileName)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2973 else:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2974 path = self.project.getProjectPath()
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2975
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2976 if not path and self.fileName is not None:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2977 path = os.path.dirname(self.fileName)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2978 if not path:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2979 path = Preferences.getMultiProject("Workspace") or \
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2980 Utilities.getHomeDir()
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2981
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2982 from . import Lexers
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2983 if self.fileName:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2984 filterPattern = "(*{0})".format(
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2985 os.path.splitext(self.fileName)[1])
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2986 for filter in Lexers.getSaveFileFiltersList(True):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2987 if filterPattern in filter:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2988 defaultFilter = filter
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2989 break
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2990 else:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2991 defaultFilter = Preferences.getEditor("DefaultSaveFilter")
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2992 else:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2993 defaultFilter = Preferences.getEditor("DefaultSaveFilter")
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2994 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2995 self,
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2996 self.tr("Save File"),
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2997 path,
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2998 Lexers.getSaveFileFiltersList(True, True),
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
2999 defaultFilter,
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3000 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3001
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3002 if fn:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3003 if fn.endswith("."):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3004 fn = fn[:-1]
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3005
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3006 ext = QFileInfo(fn).suffix()
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3007 if not ext:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3008 ex = selectedFilter.split("(*")[1].split(")")[0]
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3009 if ex:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3010 fn += ex
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3011 if QFileInfo(fn).exists():
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3012 res = E5MessageBox.yesNo(
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3013 self,
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3014 self.tr("Save File"),
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3015 self.tr("<p>The file <b>{0}</b> already exists."
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3016 " Overwrite it?</p>").format(fn),
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3017 icon=E5MessageBox.Warning)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3018 if not res:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3019 return ""
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3020 fn = Utilities.toNativeSeparators(fn)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3021
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3022 return fn
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3023
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3024 def saveFileCopy(self, path=None):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3025 """
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3026 Public method to save a copy of the file.
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3027
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3028 @param path directory to save the file in (string)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3029 @return flag indicating success (boolean)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3030 """
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3031 fn = self.__getSaveFileName(path)
4411
15556f6b4b0f Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4405
diff changeset
3032 if not fn:
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3033 return False
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3034
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3035 res = self.writeFile(fn)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3036 if res:
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3037 # save to project, if a project is loaded
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3038 if self.project.isOpen() and \
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3039 self.project.startswithProjectPath(fn):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3040 self.project.appendFile(fn)
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3041
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3042 return res
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3043
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3044 def saveFile(self, saveas=False, path=None):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3045 """
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3046 Public method to save the text to a file.
92
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 @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
3049 @param path directory to save the file in (string)
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
3050 @return flag indicating success (boolean)
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 if not saveas and not self.isModified():
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
3053 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
3054
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3055 newName = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3056 if saveas or self.fileName is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3057 saveas = True
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
3058
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3059 fn = self.__getSaveFileName(path)
4411
15556f6b4b0f Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4405
diff changeset
3060 if not fn:
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3061 return False
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
3062
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3063 newName = fn
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
3064
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
3065 # 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
3066 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
3067 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
3068 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
3069 self.convertEols(self.eolMode())
92
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 fn = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3072
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
3073 self.editorAboutToBeSaved.emit(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3074 if self.writeFile(fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3075 if saveas:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3076 self.__clearBreakpoints(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3077 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3078 self.setModified(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3079 self.setReadOnly(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3080 self.setWindowTitle(self.fileName)
789
c190cd71b097 Fixed an issue introduced by the latest change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 788
diff changeset
3081 # get eric specific flags
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
3082 changedFlags = self.__processFlags()
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
3083 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
3084 self.setLanguage(self.fileName)
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 if saveas:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3087 self.isResourcesFile = self.fileName.endswith(".qrc")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3088 self.__initContextMenu()
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
3089 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
3090
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
3091 # 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
3092 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
3093 self.project.startswithProjectPath(fn):
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
3094 self.project.appendFile(fn)
825
9cdec3c5bc07 Merged "Save to Project" into "Save" and "Save As...".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 812
diff changeset
3095 self.addedToProject()
3152
0845347fe512 Fixed an issue setting syntax style in a 'save as' operation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3149
diff changeset
3096
0845347fe512 Fixed an issue setting syntax style in a 'save as' operation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3149
diff changeset
3097 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
3098
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3099 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3100 if newName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3101 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
3102 self.editorSaved.emit(self.fileName)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
3103 self.checkSyntax()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3104 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
3105 self.__resetOnlineChangeTraceInfo()
4405
c110bcfaad81 Fixed an issue in the editor causing the encodings menu not being synchronized after a save operation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4402
diff changeset
3106 self.__checkEncoding()
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
3107 return True
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3108 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3109 self.lastModified = QFileInfo(fn).lastModified()
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
3110 return False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3111
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3112 def saveFileAs(self, path=None, toProject=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3113 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3114 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
3115
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3116 @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
3117 @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
3118 (boolean)
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3119 @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
3120 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
3121 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3122 return self.saveFile(True, path)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3123
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3124 def handleRenamed(self, fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3125 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3126 Public slot to handle the editorRenamed signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3127
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3128 @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
3129 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3130 self.__clearBreakpoints(fn)
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 self.fileName = fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3133 self.setWindowTitle(self.fileName)
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 if self.lexer_ is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3136 self.setLanguage(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3137
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3138 self.lastModified = QFileInfo(self.fileName).lastModified()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3139 self.vm.setEditorName(self, self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3140 self.__updateReadOnly(True)
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 def fileRenamed(self, fn):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3143 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3144 Public slot to handle the editorRenamed signal.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3145
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3146 @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
3147 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3148 self.handleRenamed(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3149 if not self.inFileRenamed:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3150 self.inFileRenamed = True
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
3151 self.editorRenamed.emit(self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3152 self.inFileRenamed = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3153
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3154 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3155 ## 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
3156 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3157
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3158 def ensureVisible(self, line):
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 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
3161
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3162 @param line line number to make visible
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3163 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3164 self.ensureLineVisible(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3165
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3166 def ensureVisibleTop(self, line):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3167 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3168 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
3169 of the editor.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3170
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3171 @param line line number to make visible
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3172 """
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3173 self.setFirstVisibleLine(line - 1)
92
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 __marginClicked(self, margin, line, modifiers):
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 Private slot to handle the marginClicked signal.
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 margin id of the clicked margin (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3180 @param line line number of the click (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3181 @param modifiers keyboard modifiers (Qt.KeyboardModifiers)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3182 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3183 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3184 if margin == 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3185 if modifiers & Qt.KeyboardModifiers(Qt.ShiftModifier):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3186 if self.marginMenuActs["LMBbreakpoints"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3187 self.toggleBookmark(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3188 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3189 self.__toggleBreakpoint(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3190 elif modifiers & Qt.KeyboardModifiers(Qt.ControlModifier):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3191 if self.markersAtLine(line) & (1 << self.syntaxerror):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3192 self.__showSyntaxError(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3193 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
3194 self.__showWarning(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3195 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3196 if self.marginMenuActs["LMBbreakpoints"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3197 self.__toggleBreakpoint(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3198 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3199 self.toggleBookmark(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3200 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3201 if margin == self.__bmMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3202 self.toggleBookmark(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3203 elif margin == self.__bpMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3204 self.__toggleBreakpoint(line + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3205 elif margin == self.__indicMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3206 if self.markersAtLine(line) & (1 << self.syntaxerror):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3207 self.__showSyntaxError(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3208 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
3209 self.__showWarning(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3210
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3211 def handleMonospacedEnable(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3212 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
3213 Public slot to handle the Use Monospaced Font context menu entry.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3214 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3215 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
3216 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
3217 self.setMonospaced(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3218 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3219 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
3220 self.lexer_.readSettings(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3221 Preferences.Prefs.settings, "Scintilla")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3222 self.lexer_.initProperties()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3223 self.setMonospaced(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3224 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3225
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3226 def getWordBoundaries(self, line, index, useWordChars=True):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3227 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3228 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
3229
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3230 @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
3231 @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
3232 @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
3233 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
3234 @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
3235 (integer, integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3236 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3237 text = self.text(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3238 if self.caseSensitive():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3239 cs = Qt.CaseSensitive
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3240 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3241 cs = Qt.CaseInsensitive
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3242 wc = self.wordCharacters()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3243 if wc is None or not useWordChars:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3244 regExp = QRegExp('[^\w_]', cs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3245 else:
448
a1f1b226ff4b Fixed a few unicode related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 429
diff changeset
3246 wc = re.sub('\w', "", wc)
a1f1b226ff4b Fixed a few unicode related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 429
diff changeset
3247 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
3248 start = regExp.lastIndexIn(text, index) + 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3249 end = regExp.indexIn(text, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3250 if start == end + 1 and index > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3251 # we are on a word boundary, try again
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3252 start = regExp.lastIndexIn(text, index - 1) + 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3253 if start == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3254 start = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3255 if end == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3256 end = len(text)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3257
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3258 return (start, end)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3259
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3260 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
3261 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3262 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
3263
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3264 @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
3265 @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
3266 @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
3267 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
3268 @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
3269 method (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3270 @return the word at that position (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3271 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3272 start, end = self.getWordBoundaries(line, index, useWordChars)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3273 if direction == 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3274 end = index
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3275 elif direction == 2:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3276 start = index
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3277 if end > start:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3278 text = self.text(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3279 word = text[start:end]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3280 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3281 word = ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3282 return word
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3283
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3284 def getWordLeft(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3285 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3286 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
3287
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3288 @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
3289 @param index position to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3290 @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
3291 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3292 return self.getWord(line, index, 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3293
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3294 def getWordRight(self, line, index):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3295 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3296 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
3297
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3298 @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
3299 @param index position to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3300 @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
3301 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3302 return self.getWord(line, index, 2)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3303
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3304 def getCurrentWord(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3305 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3306 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
3307
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3308 @return the word at that current position (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3309 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3310 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3311 return self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3312
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
3313 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
3314 """
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
3315 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
3316
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
3317 @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
3318 (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
3319 """
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
3320 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
3321 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
3322
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3323 def selectWord(self, line, index):
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 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
3326
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3327 @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
3328 @param index position to look at (int)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3329 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3330 start, end = self.getWordBoundaries(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3331 self.setSelection(line, start, line, end)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3332
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3333 def selectCurrentWord(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3334 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3335 Public method to select the current word.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3336 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3337 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3338 self.selectWord(line, index)
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 def __getCharacter(self, pos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3341 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3342 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
3343 in the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3344
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3345 @param pos position to get character at (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3346 @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
3347 the next position (i.e. pos - 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3348 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3349 if pos <= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3350 return "", pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3351
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3352 pos = self.positionBefore(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3353 ch = self.charAt(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3354
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3355 # 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
3356 if ch == '\n' or ch == '\r':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3357 return "", pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3358
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3359 return ch, pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3360
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3361 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
3362 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3363 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
3364 next search operation.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3365
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3366 @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
3367 returned (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3368 @return selection or current word (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3369 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3370 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3371 text = self.selectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3372 if '\r' in text or '\n' in text:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3373 # 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
3374 # unlikely to be the expression to search for
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3375 return ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3376
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3377 return text
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3378
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3379 if not selectionOnly:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3380 # 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
3381 return self.getCurrentWord()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3382
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3383 return ''
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3384
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3385 def setSearchIndicator(self, startPos, indicLength):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3386 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3387 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
3388
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3389 @param startPos start position of the indicator (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3390 @param indicLength length of the indicator (integer)
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 self.setIndicatorRange(self.searchIndicator, startPos, indicLength)
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3393 line = self.lineIndexFromPosition(startPos)[0]
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3394 if line not in self.__searchIndicatorLines:
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3395 self.__searchIndicatorLines.append(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3396
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3397 def clearSearchIndicators(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3398 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3399 Public method to clear all search indicators.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3400 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3401 self.clearAllIndicators(self.searchIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3402 self.__markedText = ""
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3403 self.__searchIndicatorLines = []
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3404 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3405
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3406 def __markOccurrences(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3407 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3408 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
3409 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3410 word = self.getCurrentWord()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3411 if not word:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3412 self.clearSearchIndicators()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3413 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3414
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3415 if self.__markedText == word:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3416 return
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 self.clearSearchIndicators()
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3419 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
3420 0, 0)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3421 while ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3422 tgtPos, tgtLen = self.getFoundTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3423 self.setSearchIndicator(tgtPos, tgtLen)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3424 ok = self.findNextTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3425 self.__markedText = word
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3426 self.__markerMap.update()
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3427
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3428 def getSearchIndicatorLines(self):
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3429 """
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3430 Public method to get the lines containing a search indicator.
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3431
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3432 @return list of lines containing a search indicator (list of integer)
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3433 """
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3434 return self.__searchIndicatorLines[:]
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3435
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3436 def updateMarkerMap(self):
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3437 """
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3438 Public method to initiate an update of the marker map.
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3439 """
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4302
diff changeset
3440 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3441
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3442 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3443 ## 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
3444 ###########################################################################
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
3445
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3446 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
3447 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3448 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
3449 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
3450
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3451 @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
3452 @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
3453 @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
3454 """
476f6016114d Fixed an issue with the uncomment and toggle comment functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2490
diff changeset
3455 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
3456 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
3457 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
3458 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
3459
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3460 def toggleCommentBlock(self):
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3461 """
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3462 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
3463
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3464 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
3465 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
3466 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
3467 """
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3468 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
3469 return
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3470
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3471 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
3472 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
3473
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3474 # 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
3475 # 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
3476 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
3477 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
3478 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
3479 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
3480 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
3481 # 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
3482 self.commentLineOrSelection()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3483 else:
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3484 # 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
3485 begline = line
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3486 while begline > 0 and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
3487 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
3488 begline -= 1
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3489 # 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
3490 endline = line
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3491 lines = self.lines()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3492 while endline < lines and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
3493 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
3494 endline += 1
1500
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3495
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3496 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
3497 self.uncommentLineOrSelection()
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3498
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3499 # reset the cursor
6ce6deb421cf Added an action to the editor to toggle block comments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1491
diff changeset
3500 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
3501
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3502 def commentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3503 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3504 Public slot to comment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3505 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3506 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
3507 return
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 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3510 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3511 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3512 self.insertAt(self.lexer_.commentStr(), line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3513 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3514 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
3515 self.indentation(line))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3516 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3517
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3518 def uncommentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3519 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3520 Public slot to uncomment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3521 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3522 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
3523 return
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 commentStr = self.lexer_.commentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3526 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3527
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3528 # 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
3529 # 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
3530 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
3531 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3532
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3533 # now remove the comment string
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3534 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3535 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3536 self.setSelection(line, 0, line, len(commentStr))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3537 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
3538 self.setSelection(line, self.indentation(line),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3539 line, self.indentation(line) + len(commentStr))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3540 self.removeSelectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3541 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3542
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3543 def commentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3544 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3545 Public slot to comment the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3546 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3547 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
3548 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3549
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3550 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3551 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3552
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3553 commentStr = self.lexer_.commentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3554
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3555 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3556 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3557 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3558 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3559 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3560 endLine = lineTo
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 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3563 # iterate over the lines
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3564 for line in range(lineFrom, endLine + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3565 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3566 self.insertAt(commentStr, line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3567 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3568 self.insertAt(commentStr, line, self.indentation(line))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3569
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3570 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3571 self.setSelection(lineFrom, 0, endLine + 1, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3572 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3573
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3574 def uncommentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3575 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3576 Public slot to uncomment the current selection.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3577 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3578 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
3579 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3580
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3581 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3582 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3583
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3584 commentStr = self.lexer_.commentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3585
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3586 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3587 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3588 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3589 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3590 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3591 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3592
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3593 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3594 # 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
3595 for line in range(lineFrom, endLine + 1):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3596 # 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
3597 # 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
3598 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
3599 continue
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3600
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3601 if Preferences.getEditor("CommentColumn0"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3602 self.setSelection(line, 0, line, len(commentStr))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3603 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3604 self.setSelection(line,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3605 self.indentation(line),
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3606 line,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3607 self.indentation(line) + len(commentStr))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3608 self.removeSelectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3609
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3610 # adjust selection start
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3611 if line == lineFrom:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3612 indexFrom -= len(commentStr)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3613 if indexFrom < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3614 indexFrom = 0
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 # adjust selection end
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3617 if line == lineTo:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3618 indexTo -= len(commentStr)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3619 if indexTo < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3620 indexTo = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3621
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3622 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3623 self.setSelection(lineFrom, indexFrom, lineTo, indexTo)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3624 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3625
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3626 def commentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3627 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3628 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
3629 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3630 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3631 self.commentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3632 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3633 self.commentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3634
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3635 def uncommentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3636 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3637 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
3638 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3639 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3640 self.uncommentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3641 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3642 self.uncommentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3643
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3644 def streamCommentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3645 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3646 Public slot to stream comment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3647 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3648 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
3649 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3650
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3651 commentStr = self.lexer_.streamCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3652 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3653
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3654 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3655 self.insertAt(commentStr['end'], line, self.lineLength(line))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3656 self.insertAt(commentStr['start'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3657 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3658
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3659 def streamCommentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3660 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3661 Public slot to comment the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3662 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3663 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
3664 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3665
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3666 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3667 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3668
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3669 commentStr = self.lexer_.streamCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3670
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3671 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3672 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3673 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3674 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3675 endIndex = self.lineLength(endLine)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3676 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3677 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3678 endIndex = indexTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3679
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3680 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3681 self.insertAt(commentStr['end'], endLine, endIndex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3682 self.insertAt(commentStr['start'], lineFrom, indexFrom)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3683
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3684 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3685 if indexTo > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3686 indexTo += len(commentStr['end'])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3687 if lineFrom == endLine:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3688 indexTo += len(commentStr['start'])
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3689 self.setSelection(lineFrom, indexFrom, lineTo, indexTo)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3690 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3691
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3692 def streamCommentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3693 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3694 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
3695 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3696 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3697 self.streamCommentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3698 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3699 self.streamCommentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3700
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3701 def boxCommentLine(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3702 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3703 Public slot to box comment the current line.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3704 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3705 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
3706 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3707
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3708 commentStr = self.lexer_.boxCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3709 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3710
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3711 eol = self.getLineSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3712 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3713 self.insertAt(eol, line, self.lineLength(line))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3714 self.insertAt(commentStr['end'], line + 1, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3715 self.insertAt(commentStr['middle'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3716 self.insertAt(eol, line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3717 self.insertAt(commentStr['start'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3718 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3719
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3720 def boxCommentSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3721 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3722 Public slot to box comment the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3723 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3724 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
3725 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3726
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3727 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3728 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3729
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3730 commentStr = self.lexer_.boxCommentStr()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3731
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3732 # get the selection boundaries
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3733 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3734 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3735 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3736 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3737 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3738
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3739 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3740 # iterate over the lines
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3741 for line in range(lineFrom, endLine + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3742 self.insertAt(commentStr['middle'], line, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3743
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3744 # 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
3745 eol = self.getLineSeparator()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3746 self.insertAt(eol, endLine, self.lineLength(endLine))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3747 self.insertAt(commentStr['end'], endLine + 1, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3748 self.insertAt(eol, lineFrom, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3749 self.insertAt(commentStr['start'], lineFrom, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3750
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3751 # change the selection accordingly
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3752 self.setSelection(lineFrom, 0, endLine + 3, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3753 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3754
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3755 def boxCommentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3756 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3757 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
3758 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3759 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3760 self.boxCommentSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3761 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3762 self.boxCommentLine()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3763
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3764 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3765 ## 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
3766 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3767
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3768 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
3769 """
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3770 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
3771
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3772 @param indent flag indicating an indent operation (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3773 <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
3774 Otherwise the current line is unindented.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3775 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3776 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3777 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3778 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3779 self.indent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3780 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3781 self.unindent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3782 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3783 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3784 self.setCursorPosition(line, index + self.indentationWidth())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3785 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3786 self.setCursorPosition(line, index - self.indentationWidth())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3787
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3788 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
3789 """
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
3790 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
3791
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3792 @param indent flag indicating an indent operation (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3793 <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
3794 Otherwise the current line is unindented.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3795 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3796 if not self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3797 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3798
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3799 # get the selection
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3800 lineFrom, indexFrom, lineTo, indexTo = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3801
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3802 if indexTo == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3803 endLine = lineTo - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3804 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3805 endLine = lineTo
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3806
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3807 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3808 # iterate over the lines
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3809 for line in range(lineFrom, endLine + 1):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3810 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3811 self.indent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3812 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3813 self.unindent(line)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3814 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3815 if indent:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3816 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
3817 self.setSelection(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3818 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
3819 lineTo, 0)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3820 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3821 self.setSelection(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3822 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
3823 lineTo, indexTo + self.indentationWidth())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3824 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3825 indexStart = indexFrom - self.indentationWidth()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3826 if indexStart < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3827 indexStart = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3828 indexEnd = indexTo - self.indentationWidth()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3829 if indexEnd < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3830 indexEnd = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3831 self.setSelection(lineFrom, indexStart, lineTo, indexEnd)
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 def indentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3834 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
3835 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
3836 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3837 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3838 self.__indentSelection(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3839 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3840 self.__indentLine(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3841
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3842 def unindentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3843 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3844 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
3845 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3846 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3847 self.__indentSelection(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3848 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3849 self.__indentLine(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3850
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3851 def smartIndentLineOrSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3852 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3853 Public slot to indent current line smartly.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3854 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3855 if self.hasSelectedText():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3856 if self.lexer_ and self.lexer_.hasSmartIndent():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3857 self.lexer_.smartIndentSelection(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3858 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3859 self.__indentSelection(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3860 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3861 if self.lexer_ and self.lexer_.hasSmartIndent():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3862 self.lexer_.smartIndentLine(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3863 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3864 self.__indentLine(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3865
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3866 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
3867 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3868 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
3869
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3870 @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
3871 @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
3872 @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
3873 visible line (boolean)
832
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
3874 """
eb5ff61f927b Added a checker for PEP 8 compliance.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
3875 self.setCursorPosition(line - 1, pos - 1)
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3876 if firstVisible:
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3877 self.ensureVisibleTop(line)
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3878 else:
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1831
diff changeset
3879 self.ensureVisible(line)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3880
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
3881 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
3882 """
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
3883 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
3884
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
3885 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
3886 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
3887 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
3888 """
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
3889 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
3890
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
3891 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
3892 """
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
3893 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
3894 """
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
3895 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
3896 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
3897
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
3898 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
3899 """
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
3900 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
3901
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
3902 @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
3903 """
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
3904 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
3905
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
3906 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
3907 """
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
3908 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
3909 """
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
3910 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
3911 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
3912
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
3913 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
3914 """
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
3915 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
3916
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
3917 @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
3918 """
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
3919 if self.isPyFile() 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
3920 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
3921 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
3922 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
3923 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
3924 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
3925 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
3926 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
3927 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
3928 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
3929 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
3930 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
3931 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
3932 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
3933 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
3934 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
3935 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
3936 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
3937
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
3938 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
3939 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
3940 # 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
3941 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
3942 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
3943 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
3944 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
3945 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
3946 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
3947 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
3948 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
3949 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
3950 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
3951 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
3952 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
3953 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
3954 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
3955 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
3956 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
3957 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
3958
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
3959 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
3960 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
3961 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
3962 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
3963
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
3964 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3965 ## 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
3966 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3967
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3968 def readSettings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3969 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3970 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
3971 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3972 # read the lexer settings and reinit the properties
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3973 if self.lexer_ is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3974 self.lexer_.readSettings(Preferences.Prefs.settings, "Scintilla")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3975 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
3976
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
3977 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
3978 self.lexer_.setDefaultPaper(self.lexer_.paper(0))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3979
4227
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
3980 self.__bindLexer(self.fileName)
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
3981 self.recolor()
8a39c8b968f4 Fixed an issue with the API auto-prepare function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4201
diff changeset
3982
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3983 # read the typing completer settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3984 if self.completer is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3985 self.completer.readSettings()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3986
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3987 # set the margins layout
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3988 if QSCINTILLA_VERSION() >= 0x020301:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3989 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3990
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3991 # set the line marker colours
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3992 self.__setLineMarkerColours()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3993
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3994 # set the text display
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3995 self.__setTextDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3996
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3997 # set margin 0 and 2 configuration
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3998 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
3999
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4000 # set the autocompletion and calltips function
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4001 self.__setAutoCompletion()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4002 self.__setCallTips()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4003
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4004 # set the autosave flags
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4005 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4006
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4007 if Preferences.getEditor("MiniContextMenu") != self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4008 # regenerate context menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4009 self.__initContextMenu()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4010 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4011 # set checked context menu items
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4012 self.menuActs["AutoCompletionEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4013 self.autoCompletionThreshold() != -1)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4014 self.menuActs["MonospacedFont"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4015 self.useMonospaced)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4016 self.menuActs["AutosaveEnable"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4017 self.autosaveEnabled and not self.autosaveManuallyDisabled)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4018
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4019 # regenerate the margins context menu(s)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4020 self.__initContextMenuMargins()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4021
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4022 if Preferences.getEditor("MarkOccurrencesEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4023 self.__markOccurrencesTimer.setInterval(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4024 Preferences.getEditor("MarkOccurrencesTimeout"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4025 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4026 self.__markOccurrencesTimer.stop()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4027 self.clearSearchIndicators()
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4028
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4029 if Preferences.getEditor("OnlineSyntaxCheck"):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4030 self.__onlineSyntaxCheckTimer.setInterval(
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4031 Preferences.getEditor("OnlineSyntaxCheckInterval") * 1000)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4032 else:
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4033 self.__onlineSyntaxCheckTimer.stop()
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
4034
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
4035 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
4036 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
4037 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
4038 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
4039 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
4040 self.__deleteAllChangeMarkers()
2165
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
4041 self.markerDefine(self.__createChangeMarkerPixmap(
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
4042 "OnlineChangeTraceMarkerUnsaved"), self.__changeMarkerUnsaved)
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
4043 self.markerDefine(self.__createChangeMarkerPixmap(
f89fc1162ffe Finalized the change tracing stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2164
diff changeset
4044 "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
4045
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4046 # refresh the annotations display
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4047 self.__refreshAnnotations()
3341
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3329
diff changeset
4048
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3329
diff changeset
4049 self.__markerMap.initColors()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4050
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4051 def __setLineMarkerColours(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4052 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4053 Private method to set the line marker colours.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4054 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4055 self.setMarkerForegroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4056 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
4057 self.setMarkerBackgroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4058 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
4059 self.setMarkerForegroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4060 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
4061 self.setMarkerBackgroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4062 Preferences.getEditorColour("ErrorMarker"), self.errorline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4063
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4064 def __setMarginsDisplay(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4065 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4066 Private method to configure margins 0 and 2.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4067 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4068 # set the settings for all margins
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4069 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
4070 self.setMarginsForegroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4071 Preferences.getEditorColour("MarginsForeground"))
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4072 self.setMarginsBackgroundColor(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4073 Preferences.getEditorColour("MarginsBackground"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4074
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4075 # reset standard margins settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4076 for margin in range(5):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4077 self.setMarginLineNumbers(margin, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4078 self.setMarginMarkerMask(margin, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4079 self.setMarginWidth(margin, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4080 self.setMarginSensitivity(margin, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4081
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4082 # set marker margin(s) settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4083 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
4084 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
4085 (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
4086 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4087 (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
4088 (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
4089 (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
4090 (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
4091 (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
4092 (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
4093 (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
4094 (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
4095 (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
4096 (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
4097 (1 << self.__changeMarkerSaved)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4098 self.setMarginWidth(1, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4099 self.setMarginSensitivity(1, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4100 self.setMarginMarkerMask(1, margin1Mask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4101
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4102 self.__linenoMargin = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4103 self.__foldMargin = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4104 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4105
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4106 self.__bmMargin = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4107 self.__linenoMargin = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4108 self.__bpMargin = 2
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4109 self.__foldMargin = 3
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4110 self.__indicMargin = 4
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4111
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4112 marginBmMask = (1 << self.bookmark)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4113 self.setMarginWidth(self.__bmMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4114 self.setMarginSensitivity(self.__bmMargin, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4115 self.setMarginMarkerMask(self.__bmMargin, marginBmMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4116
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4117 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
4118 (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
4119 (1 << self.tbreakpoint) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4120 (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
4121 (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
4122 (1 << self.currentline) | \
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4123 (1 << self.errorline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4124 self.setMarginWidth(self.__bpMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4125 self.setMarginSensitivity(self.__bpMargin, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4126 self.setMarginMarkerMask(self.__bpMargin, marginBpMask)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4127
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4128 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
4129 (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
4130 (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
4131 (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
4132 (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
4133 (1 << self.__changeMarkerSaved)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4134 self.setMarginWidth(self.__indicMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4135 self.setMarginSensitivity(self.__indicMargin, True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4136 self.setMarginMarkerMask(self.__indicMargin, marginIndicMask)
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 # set linenumber margin settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4139 linenoMargin = Preferences.getEditor("LinenoMargin")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4140 self.setMarginLineNumbers(self.__linenoMargin, linenoMargin)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4141 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
4142 self.__resizeLinenoMargin()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4143 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4144 self.setMarginWidth(self.__linenoMargin, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4145
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4146 # set folding margin settings
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4147 if Preferences.getEditor("FoldingMargin"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4148 self.setMarginWidth(self.__foldMargin, 16)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4149 folding = Preferences.getEditor("FoldingStyle")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4150 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4151 folding = QsciScintilla.FoldStyle(folding)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4152 except AttributeError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4153 pass
342
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
4154 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
4155 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
4156 Preferences.getEditorColour("FoldmarginBackground"),
342
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
4157 Preferences.getEditorColour("FoldmarginBackground"))
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
4158 self.setFoldMarkersColors(
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
4159 Preferences.getEditorColour("FoldMarkersForeground"),
360c4eb76d6c Added capability to configure the colors of the foldmarkers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
4160 Preferences.getEditorColour("FoldMarkersBackground"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4161 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4162 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
4163 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
4164
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
4165 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
4166 """
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
4167 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
4168 """
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
4169 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
4170 if linenoMargin:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4171 self.setMarginWidth(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4172 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
4173
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4174 def __setTextDisplay(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4175 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4176 Private method to configure the text display.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4177 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4178 self.setTabWidth(Preferences.getEditor("TabWidth"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4179 self.setIndentationWidth(Preferences.getEditor("IndentWidth"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4180 if self.lexer_ and self.lexer_.alwaysKeepTabs():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4181 self.setIndentationsUseTabs(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4182 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4183 self.setIndentationsUseTabs(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4184 Preferences.getEditor("TabForIndentation"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4185 self.setTabIndents(Preferences.getEditor("TabIndents"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4186 self.setBackspaceUnindents(Preferences.getEditor("TabIndents"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4187 self.setIndentationGuides(Preferences.getEditor("IndentationGuides"))
4176
4c09d3d75768 Added capability to configure the indentation guides colors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4170
diff changeset
4188 self.setIndentationGuidesBackgroundColor(
4c09d3d75768 Added capability to configure the indentation guides colors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4170
diff changeset
4189 Preferences.getEditorColour("IndentationGuidesBackground"))
4c09d3d75768 Added capability to configure the indentation guides colors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4170
diff changeset
4190 self.setIndentationGuidesForegroundColor(
4c09d3d75768 Added capability to configure the indentation guides colors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4170
diff changeset
4191 Preferences.getEditorColour("IndentationGuidesForeground"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4192 if Preferences.getEditor("ShowWhitespace"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4193 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
4194 try:
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
4195 self.setWhitespaceForegroundColor(
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
4196 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
4197 self.setWhitespaceBackgroundColor(
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
4198 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
4199 self.setWhitespaceSize(
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
4200 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
4201 except AttributeError:
10d3a201cd27 Added configuration options for visible whitespace (as of QScintilla 2.5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 938
diff changeset
4202 # 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
4203 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4204 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4205 self.setWhitespaceVisibility(QsciScintilla.WsInvisible)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4206 self.setEolVisibility(Preferences.getEditor("ShowEOL"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4207 self.setAutoIndent(Preferences.getEditor("AutoIndentation"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4208 if Preferences.getEditor("BraceHighlighting"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4209 self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4210 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4211 self.setBraceMatching(QsciScintilla.NoBraceMatch)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4212 self.setMatchedBraceForegroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4213 Preferences.getEditorColour("MatchingBrace"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4214 self.setMatchedBraceBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4215 Preferences.getEditorColour("MatchingBraceBack"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4216 self.setUnmatchedBraceForegroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4217 Preferences.getEditorColour("NonmatchingBrace"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4218 self.setUnmatchedBraceBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4219 Preferences.getEditorColour("NonmatchingBraceBack"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4220 if Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4221 self.setSelectionBackgroundColor(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4222 Preferences.getEditorColour("SelectionBackground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4223 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4224 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
4225 QApplication.palette().color(QPalette.Highlight))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4226 if Preferences.getEditor("ColourizeSelText"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4227 self.resetSelectionForegroundColor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4228 elif Preferences.getEditor("CustomSelectionColours"):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4229 self.setSelectionForegroundColor(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4230 Preferences.getEditorColour("SelectionForeground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4231 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4232 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
4233 QApplication.palette().color(QPalette.HighlightedText))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4234 self.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4235 self.setCaretForegroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4236 Preferences.getEditorColour("CaretForeground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4237 self.setCaretLineBackgroundColor(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4238 Preferences.getEditorColour("CaretLineBackground"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4239 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
4240 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
4241 Preferences.getEditor("CaretLineAlwaysVisible"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4242 self.caretWidth = Preferences.getEditor("CaretWidth")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4243 self.setCaretWidth(self.caretWidth)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4244 self.useMonospaced = Preferences.getEditor("UseMonospacedFont")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4245 self.setMonospaced(self.useMonospaced)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4246 edgeMode = Preferences.getEditor("EdgeMode")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4247 edge = QsciScintilla.EdgeMode(edgeMode)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4248 self.setEdgeMode(edge)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4249 if edgeMode:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4250 self.setEdgeColumn(Preferences.getEditor("EdgeColumn"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4251 self.setEdgeColor(Preferences.getEditorColour("Edge"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4252
2262
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4253 wrapVisualFlag = Preferences.getEditor("WrapVisualFlag")
2371836c3c45 Made some more adjustments for QScintilla 2.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2261
diff changeset
4254 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
4255 self.setWrapVisualFlags(wrapVisualFlag, wrapVisualFlag)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4256
230
2cde09c26384 Added code to configure the zoom factor a file is opened with.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 206
diff changeset
4257 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
4258
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4259 self.searchIndicator = QsciScintilla.INDIC_CONTAINER
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4260 self.indicatorDefine(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4261 self.searchIndicator, QsciScintilla.INDIC_BOX,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4262 Preferences.getEditorColour("SearchMarkers"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4263 if not Preferences.getEditor("SearchMarkersEnabled") and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4264 not Preferences.getEditor("QuickSearchMarkersEnabled") and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4265 not Preferences.getEditor("MarkOccurrencesEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4266 self.clearAllIndicators(self.searchIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4267
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4268 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
4269 self.indicatorDefine(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4270 self.spellingIndicator, QsciScintilla.INDIC_SQUIGGLE,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4271 Preferences.getEditorColour("SpellingMarkers"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4272 self.__setSpelling()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4273
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
4274 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
4275
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4276 try:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4277 if Preferences.getEditor("AnnotationsEnabled"):
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4278 self.setAnnotationDisplay(QsciScintilla.AnnotationBoxed)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4279 else:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4280 self.setAnnotationDisplay(QsciScintilla.AnnotationHidden)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4281 except AttributeError:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
4282 pass
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4283 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
4284
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
4285 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
4286 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
4287 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
4288
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4289 self.setVirtualSpaceOptions(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4290 Preferences.getEditor("VirtualSpaceOptions"))
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
4291
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
4292 self.__markerMap.setEnabled(True)
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
4293
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4294 def __setEolMode(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4295 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4296 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
4297 """
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4298 if self.fileName and \
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4299 self.project.isOpen() and \
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4300 self.project.isProjectFile(self.fileName):
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4301 self.setEolModeByEolString(self.project.getEolString())
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4302 else:
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4303 eolMode = Preferences.getEditor("EOLMode")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4304 eolMode = QsciScintilla.EolMode(eolMode)
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
4305 self.setEolMode(eolMode)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4306 self.__eolChanged()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4307
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4308 def __setAutoCompletion(self):
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 Private method to configure the autocompletion function.
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 if self.lexer_:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4313 self.setAutoCompletionFillupsEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4314 Preferences.getEditor("AutoCompletionFillups"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4315 self.setAutoCompletionCaseSensitivity(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4316 Preferences.getEditor("AutoCompletionCaseSensitivity"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4317 self.setAutoCompletionReplaceWord(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4318 Preferences.getEditor("AutoCompletionReplaceWord"))
971
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4319 try:
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4320 self.setAutoCompletionUseSingle(
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4321 Preferences.getEditor("AutoCompletionShowSingle"))
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4322 except AttributeError:
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4323 self.setAutoCompletionShowSingle(
1243c600ba57 Added a compatibilitiy fix for QScintilla 2.5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 954
diff changeset
4324 Preferences.getEditor("AutoCompletionShowSingle"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4325 autoCompletionSource = Preferences.getEditor("AutoCompletionSource")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4326 if autoCompletionSource == QsciScintilla.AcsDocument:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4327 self.setAutoCompletionSource(QsciScintilla.AcsDocument)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4328 elif autoCompletionSource == QsciScintilla.AcsAPIs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4329 self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4330 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4331 self.setAutoCompletionSource(QsciScintilla.AcsAll)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4332 if Preferences.getEditor("AutoCompletionEnabled"):
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4333 if self.__acHookFunction is None or \
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4334 not self.__completionListHookFunctions:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4335 self.setAutoCompletionThreshold(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4336 Preferences.getEditor("AutoCompletionThreshold"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4337 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4338 self.setAutoCompletionThreshold(0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4339 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4340 self.setAutoCompletionThreshold(-1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4341 self.setAutoCompletionSource(QsciScintilla.AcsNone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4342
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4343 def __setCallTips(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4344 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4345 Private method to configure the calltips function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4346 """
4201
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4347 self.setCallTipsBackgroundColor(
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4348 Preferences.getEditorColour("CallTipsBackground"))
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4349 self.setCallTipsVisible(Preferences.getEditor("CallTipsVisible"))
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4350 calltipsStyle = Preferences.getEditor("CallTipsStyle")
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4351 try:
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4352 self.setCallTipsPosition(
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4353 Preferences.getEditor("CallTipsPosition"))
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4354 except AttributeError:
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4355 pass
2a9316cb3fad Fixed an issue causing wrong display of manually invoked calltips when auto-caltips were disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4176
diff changeset
4356
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4357 if Preferences.getEditor("CallTipsEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4358 if calltipsStyle == QsciScintilla.CallTipsNoContext:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4359 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
4360 elif calltipsStyle == \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4361 QsciScintilla.CallTipsNoAutoCompletionContext:
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4362 self.setCallTipsStyle(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4363 QsciScintilla.CallTipsNoAutoCompletionContext)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4364 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4365 self.setCallTipsStyle(QsciScintilla.CallTipsContext)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4366 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4367 self.setCallTipsStyle(QsciScintilla.CallTipsNone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4368
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4369 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4370 ## 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
4371 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4372
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4373 def canAutoCompleteFromAPIs(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4374 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4375 Public method to check for API availablity.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4376
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4377 @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
4378 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4379 return self.acAPI
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4380
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4381 def autoCompleteQScintilla(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4382 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4383 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
4384 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4385 acs = Preferences.getEditor("AutoCompletionSource")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4386 if acs == QsciScintilla.AcsDocument:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4387 self.autoCompleteFromDocument()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4388 elif acs == QsciScintilla.AcsAPIs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4389 self.autoCompleteFromAPIs()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4390 elif acs == QsciScintilla.AcsAll:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4391 self.autoCompleteFromAll()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4392 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4393 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4394 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4395 self.tr("Autocompletion"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4396 self.tr(
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4397 """Autocompletion is not available because"""
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4398 """ there is no autocompletion source set."""))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4399
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4400 def setAutoCompletionEnabled(self, enable):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4401 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4402 Public method to enable/disable autocompletion.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4403
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4404 @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
4405 (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4406 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4407 if enable:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4408 self.setAutoCompletionThreshold(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4409 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
4410 autoCompletionSource = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4411 Preferences.getEditor("AutoCompletionSource")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4412 if autoCompletionSource == QsciScintilla.AcsDocument:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4413 self.setAutoCompletionSource(QsciScintilla.AcsDocument)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4414 elif autoCompletionSource == QsciScintilla.AcsAPIs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4415 self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4416 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4417 self.setAutoCompletionSource(QsciScintilla.AcsAll)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4418 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4419 self.setAutoCompletionThreshold(-1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4420 self.setAutoCompletionSource(QsciScintilla.AcsNone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4421
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4422 def __toggleAutoCompletionEnable(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4423 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4424 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
4425 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4426 if self.menuActs["AutoCompletionEnable"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4427 self.setAutoCompletionEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4428 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4429 self.setAutoCompletionEnabled(False)
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 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4432 ## Support for autocompletion hook methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4433 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4434
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4435 def __charAdded(self, charNumber):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4436 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
4437 Private slot called to handle the user entering a character.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4438
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4439 @param charNumber value of the character entered (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4440 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4441 if self.isListActive():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4442 char = chr(charNumber)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4443 if self.__isStartChar(char):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4444 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
4445 self.autoComplete(auto=True, context=True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4446 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4447 elif char == '(':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4448 self.cancelList()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4449
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4450 if self.callTipsStyle() != QsciScintilla.CallTipsNone and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4451 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
4452 self.callTip()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4453
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4454 if not self.isCallTipActive():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4455 char = chr(charNumber)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4456 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
4457 self.autoComplete(auto=True, context=True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4458 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4459
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4460 line, col = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4461 txt = self.getWordLeft(line, col)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4462 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
4463 self.autoComplete(auto=True, context=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4464 return
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 def __isStartChar(self, ch):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4467 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4468 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
4469 character.
92
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 @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
4472 @return flag indicating the result (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4473 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4474 if self.lexer_ is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4475 return False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4476
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4477 wseps = self.lexer_.autoCompletionWordSeparators()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4478 for wsep in wseps:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4479 if wsep.endswith(ch):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4480 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4481
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4482 return False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4483
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4484 #####################################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4485 ## old auto-completion hook interfaces (before 6.1.0)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4486 #####################################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4487
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4488 def setAutoCompletionHook(self, func):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4489 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4490 Public method to set an autocompletion hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4491
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4492 @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
4493 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
4494 a boolean indicating to complete a context.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4495 """
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
4496 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
4497 # 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
4498 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4499 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4500 self.tr("Activating Auto-Completion Provider"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4501 self.tr("""Auto-completion provider cannot be connected"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4502 """ because there is already another one active."""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4503 """ Please check your configuration."""))
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
4504 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
4505
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4506 if self.autoCompletionThreshold() > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4507 self.setAutoCompletionThreshold(0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4508 self.__acHookFunction = func
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4509 self.SCN_CHARADDED.connect(self.__charAdded)
92
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 unsetAutoCompletionHook(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 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
4514 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
4515 self.SCN_CHARADDED.disconnect(self.__charAdded)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4516 self.__acHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4517 if self.autoCompletionThreshold() == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4518 self.setAutoCompletionThreshold(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4519 Preferences.getEditor("AutoCompletionThreshold"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4520
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4521 def autoCompletionHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4522 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4523 Public method to get the autocompletion hook function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4524
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4525 @return function set by setAutoCompletionHook()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4526 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4527 return self.__acHookFunction
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4528
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4529 ########################################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4530 ## new auto-completion hook interfaces (6.1.0 and later)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4531 ########################################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4532
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4533 def addCompletionListHook(self, key, func):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4534 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4535 Public method to set an auto-completion list provider.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4536
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4537 @param key name of the provider
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4538 @type str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4539 @param func function providing completion list. func
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4540 should be a function taking a reference to the editor and
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4541 a boolean indicating to complete a context. It should return
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4542 the possible completions as a list of strings.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4543 @type function(editor, bool) -> list of str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4544 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4545 if key in self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4546 # it was already registered
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4547 E5MessageBox.warning(
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4548 self,
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4549 self.tr("Auto-Completion Provider"),
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4550 self.tr("""The completion list provider '{0}' was already"""
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4551 """ registered. Ignoring duplicate request.""")
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4552 .format(key))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4553 return
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4554
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4555 if not self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4556 if self.autoCompletionThreshold() > 0:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4557 self.setAutoCompletionThreshold(0)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4558 self.SCN_CHARADDED.connect(self.__charAdded)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4559 self.__completionListHookFunctions[key] = func
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4560
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4561 def removeCompletionListHook(self, key):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4562 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4563 Public method to remove a previously registered completion list
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4564 provider.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4565
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4566 @param key name of the provider
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4567 @type str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4568 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4569 if key in self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4570 del self.__completionListHookFunctions[key]
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4571
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4572 if not self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4573 self.SCN_CHARADDED.disconnect(self.__charAdded)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4574 if self.autoCompletionThreshold() == 0:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4575 self.setAutoCompletionThreshold(
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4576 Preferences.getEditor("AutoCompletionThreshold"))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4577
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4578 def getCompletionListHook(self, key):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4579 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4580 Public method to get the registered completion list provider.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4581
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4582 @param key name of the provider
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4583 @type str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4584 @return function providing completion list
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4585 @rtype function or None
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4586 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4587 if key in self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4588 return self.__completionListHookFunctions[key]
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4589 else:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4590 return None
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4591
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4592 def autoComplete(self, auto=False, context=True):
92
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 Public method to start autocompletion.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4595
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4596 @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
4597 (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4598 @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
4599 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4600 if auto and self.autoCompletionThreshold() == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4601 # autocompletion is disabled
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4602 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4603
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4604 if self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4605 if self.isListActive():
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4606 self.cancelList()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4607 completionsList = []
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4608 for key in self.__completionListHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4609 completionsList.extend(
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4610 self.__completionListHookFunctions[key](self, context))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4611 completionsList = list(set(completionsList))
4282
c72c9b51ae73 Fixed a bug in the editor resulting in an empty QScintilla completion list being shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4272
diff changeset
4612 if len(completionsList) == 0:
c72c9b51ae73 Fixed a bug in the editor resulting in an empty QScintilla completion list being shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4272
diff changeset
4613 if Preferences.getEditor("AutoCompletionScintillaOnFail") and \
c72c9b51ae73 Fixed a bug in the editor resulting in an empty QScintilla completion list being shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4272
diff changeset
4614 (self.autoCompletionSource() != QsciScintilla.AcsNone or
c72c9b51ae73 Fixed a bug in the editor resulting in an empty QScintilla completion list being shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4272
diff changeset
4615 not auto):
c72c9b51ae73 Fixed a bug in the editor resulting in an empty QScintilla completion list being shown.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4272
diff changeset
4616 self.autoCompleteQScintilla()
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4617 else:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4618 completionsList.sort()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4619 self.showUserList(EditorAutoCompletionListID,
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4620 completionsList)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4621 elif self.__acHookFunction is not None:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4622 # for backward compatibility
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4623 self.__acHookFunction(self, context)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4624 elif not auto:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4625 self.autoCompleteQScintilla()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4626 elif self.autoCompletionSource() != QsciScintilla.AcsNone:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4627 self.autoCompleteQScintilla()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4628
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4629 def __completionListSelected(self, id, txt):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4630 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4631 Private slot to handle the selection from the completion list.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4632
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4633 @param id the ID of the user list (should be 1) (integer)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4634 @param txt the selected text (string)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4635 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4636 if id == EditorAutoCompletionListID:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4637 lst = txt.split()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4638 if len(lst) > 1:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4639 txt = lst[0]
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4640
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4641 if Preferences.getEditor("AutoCompletionReplaceWord"):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4642 self.selectCurrentWord()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4643 self.removeSelectedText()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4644 line, col = self.getCursorPosition()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4645 else:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4646 line, col = self.getCursorPosition()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4647 wLeft = self.getWordLeft(line, col)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4648 if not txt.startswith(wLeft):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4649 self.selectCurrentWord()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4650 self.removeSelectedText()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4651 line, col = self.getCursorPosition()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4652 elif wLeft:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4653 txt = txt[len(wLeft):]
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4654 self.insert(txt)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4655 self.setCursorPosition(line, col + len(txt))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4656 elif id == TemplateCompletionListID:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4657 self.__applyTemplate(txt, self.getLanguage())
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4658
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4659 def canProvideDynamicAutoCompletion(self):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4660 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4661 Public method to test the dynamic auto-completion availability.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4662
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4663 @return flag indicating the availability of dynamic auto-completion
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4664 (boolean)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4665 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4666 return (self.acAPI or
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4667 self.__acHookFunction is not None or
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4668 bool(self.__completionListHookFunctions))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4669
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4670 def callTip(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4671 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4672 Public method to show calltips.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4673 """
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4674 if bool(self.__ctHookFunctions) or self.__ctHookFunction is not None:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4675 self.__callTip()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4676 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
4677 super(Editor, self).callTip()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4678
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4679 def __callTip(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4680 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4681 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
4682 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4683 pos = self.currentPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4684
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4685 # 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
4686 # which argument to highlight
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4687 commas = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4688 found = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4689 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4690 while ch:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4691 if ch == ',':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4692 commas += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4693 elif ch == ')':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4694 depth = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4695
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4696 # 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
4697 # parenthesis
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4698 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4699 while ch:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4700 if ch == ')':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4701 depth += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4702 elif ch == '(':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4703 depth -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4704 if depth == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4705 break
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
4706 ch, pos = self.__getCharacter(pos)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4707 elif ch == '(':
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4708 found = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4709 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4710
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4711 ch, pos = self.__getCharacter(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4712
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4713 self.SendScintilla(QsciScintilla.SCI_CALLTIPCANCEL)
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 not found:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4716 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4717
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4718 if self.__ctHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4719 callTips = []
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4720 for key in self.__ctHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4721 callTips.extend(self.__ctHookFunctions[key](self, pos, commas))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4722 callTips = list(set(callTips))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4723 callTips.sort()
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4724 else:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4725 # for backward compatibility
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4726 callTips = self.__ctHookFunction(self, pos, commas)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4727 if len(callTips) == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4728 if Preferences.getEditor("CallTipsScintillaOnFail"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4729 # 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
4730 super(Editor, self).callTip()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4731 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4732
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4733 ctshift = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4734 for ct in callTips:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4735 shift = ct.index("(")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4736 if ctshift < shift:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4737 ctshift = shift
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4738
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4739 cv = self.callTipsVisible()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4740 if cv > 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4741 # 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
4742 ct = self._encodeString("\n".join(callTips[:cv]))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4743 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4744 # 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
4745 ct = self._encodeString("\n".join(callTips))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4746
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
4747 self.SendScintilla(QsciScintilla.SCI_CALLTIPSHOW,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4748 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
4749 if b'\n' in ct:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4750 return
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 # Highlight the current argument
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4753 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
4754 astart = ct.find(b'(')
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4755 else:
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4756 astart = ct.find(b',')
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4757 commas -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4758 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
4759 astart = ct.find(b',', astart + 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4760 commas -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4761
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4762 if astart == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4763 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4764
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4765 depth = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4766 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
4767 ch = ct[aend:aend + 1]
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4768
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4769 if ch == b',' and depth == 0:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4770 break
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4771 elif ch == b'(':
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4772 depth += 1
502
7500b9d5b21d Fixed an issue in the editor related to unicode handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
4773 elif ch == b')':
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4774 if depth == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4775 break
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 depth -= 1
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 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
4780 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
4781 astart + 1, aend)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4782
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4783 def __adjustedCallTipPosition(self, ctshift, pos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4784 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4785 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
4786
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4787 @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
4788 @param pos position into the text (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4789 @return new position for the calltip (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4790 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4791 ct = pos
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4792 if ctshift:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4793 ctmin = self.SendScintilla(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
4794 QsciScintilla.SCI_POSITIONFROMLINE,
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4795 self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, ct))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4796 if ct - ctshift < ctmin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4797 ct = ctmin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4798 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4799 ct = ct - ctshift
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4800 return ct
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4801
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4802 ##############################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4803 ## old calltips hook interfaces (before 6.1.0)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4804 ##############################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4805
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4806 def setCallTipHook(self, func):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4807 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4808 Public method to set a calltip hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4809
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4810 @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
4811 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
4812 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
4813 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
4814 calltips as a list of strings.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4815 """
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
4816 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
4817 # 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
4818 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
4819 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4820 self.tr("Activating Calltip Provider"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4821 self.tr("""Calltip provider cannot be connected"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4822 """ because there is already another one active."""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
4823 """ Please check your configuration."""))
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
4824 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
4825
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4826 self.__ctHookFunction = func
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4827
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4828 def unsetCallTipHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4829 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4830 Public method to unset a calltip hook.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4831 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4832 self.__ctHookFunction = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4833
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4834 def callTipHook(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4835 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4836 Public method to get the calltip hook function.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4837
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4838 @return function set by setCallTipHook()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4839 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4840 return self.__ctHookFunction
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4841
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4842 ########################################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4843 ## new auto-completion hook interfaces (6.1.0 and later)
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4844 ########################################################
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4845
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4846 def addCallTipHook(self, key, func):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4847 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4848 Public method to set a calltip provider.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4849
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4850 @param key name of the provider
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4851 @type str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4852 @param func function providing calltips. func
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4853 should be a function taking a reference to the editor,
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4854 a position into the text and the amount of commas to the
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4855 left of the cursor. It should return the possible
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4856 calltips as a list of strings.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4857 @type function(editor, int, int) -> list of str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4858 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4859 if key in self.__ctHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4860 # it was already registered
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4861 E5MessageBox.warning(
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4862 self,
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4863 self.tr("Call-Tips Provider"),
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4864 self.tr("""The call-tips provider '{0}' was already"""
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4865 """ registered. Ignoring duplicate request.""")
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4866 .format(key))
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4867 return
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4868
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4869 self.__ctHookFunctions[key] = func
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4870
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4871 def removeCallTipHook(self, key):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4872 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4873 Public method to remove a previously registered calltip provider.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4874
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4875 @param key name of the provider
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4876 @type str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4877 """
4272
169835cdf784 Fixed a bug introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4271
diff changeset
4878 if key in self.__ctHookFunctions:
169835cdf784 Fixed a bug introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4271
diff changeset
4879 del self.__ctHookFunctions[key]
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4880
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4881 def getCallTipHook(self, key):
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4882 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4883 Public method to get the registered calltip provider.
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4884
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4885 @param key name of the provider
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4886 @type str
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4887 @return function providing calltips
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4888 @rtype function or None
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4889 """
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4890 if key in self.__ctHookFunctions:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4891 return self.__ctHookFunctions[key]
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4892 else:
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4893 return None
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4894
4133
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4895 def canProvideCallTipps(self):
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4896 """
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4897 Public method to test the calltips availability.
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4898
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4899 @return flag indicating the availability of calltips (boolean)
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4900 """
4271
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4901 return (self.acAPI or
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4902 self.__ctHookFunction is not None or
480434472ac1 Added capability to the editor to ask multiple completion list and call-tip providers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4227
diff changeset
4903 bool(self.__ctHookFunctions))
4133
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
4904
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4905 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4906 ## Methods needed by the context menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4907 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4908
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4909 def __marginNumber(self, xPos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4910 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4911 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
4912
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4913 @param xPos x position (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4914 @return margin number (integer, -1 for no margin)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4915 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4916 width = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4917 for margin in range(5):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4918 width += self.marginWidth(margin)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4919 if xPos <= width:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4920 return margin
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4921 return -1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4922
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4923 def contextMenuEvent(self, evt):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4924 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
4925 Protected method implementing the context menu event.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4926
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4927 @param evt the context menu event (QContextMenuEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4928 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4929 evt.accept()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4930 if self.__marginNumber(evt.x()) == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4931 self.spellingMenuPos = self.positionFromPoint(evt.pos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4932 if self.spellingMenuPos >= 0 and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4933 self.spell is not None and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4934 self.hasIndicator(self.spellingIndicator, self.spellingMenuPos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4935 self.spellingMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4936 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4937 self.menu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4938 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4939 self.line = self.lineAt(evt.pos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4940 if self.__unifiedMargins:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4941 self.marginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4942 else:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4943 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
4944 self.__linenoMargin]:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4945 self.bmMarginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4946 elif self.__marginNumber(evt.x()) == self.__bpMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4947 self.bpMarginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4948 elif self.__marginNumber(evt.x()) == self.__indicMargin:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4949 self.indicMarginMenu.popup(evt.globalPos())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4950
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4951 def __showContextMenu(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4952 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4953 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
4954 """
3395
7e923cf9918f Made the reopen with encoding editor context menu react upon file modification status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3394
diff changeset
4955 self.menuActs["Reopen"].setEnabled(
7e923cf9918f Made the reopen with encoding editor context menu react upon file modification status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3394
diff changeset
4956 not self.isModified() and bool(self.fileName))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4957 self.menuActs["Save"].setEnabled(self.isModified())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4958 self.menuActs["Undo"].setEnabled(self.isUndoAvailable())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4959 self.menuActs["Redo"].setEnabled(self.isRedoAvailable())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4960 self.menuActs["Revert"].setEnabled(self.isModified())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4961 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4962 self.menuActs["Cut"].setEnabled(self.hasSelectedText())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4963 self.menuActs["Copy"].setEnabled(self.hasSelectedText())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4964 if not self.isResourcesFile:
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
4965 if self.fileName and self.isPyFile():
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4966 self.menuActs["Show"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4967 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4968 self.menuActs["Show"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4969 if self.fileName and \
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
4970 (self.isPyFile() or self.isRubyFile()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4971 self.menuActs["Diagrams"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4972 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4973 self.menuActs["Diagrams"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4974 if not self.miniMenu:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4975 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
4976 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
4977 self.lexer_.canBlockComment())
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4978 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
4979 self.lexer_.canBlockComment())
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4980 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
4981 self.lexer_.canStreamComment())
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4982 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
4983 self.lexer_.canBoxComment())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4984 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4985 self.menuActs["Comment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4986 self.menuActs["Uncomment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4987 self.menuActs["StreamComment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4988 self.menuActs["BoxComment"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4989
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
4990 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
4991 self.completer is not None)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
4992 self.menuActs["TypingAidsEnabled"].setChecked(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4993 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
4994
4153
95b18307079f Corrected some auto-completion related terms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4142
diff changeset
4995 self.menuActs["calltip"].setEnabled(self.acAPI)
95b18307079f Corrected some auto-completion related terms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4142
diff changeset
4996
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
4997 from .SpellChecker import SpellChecker
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4998 spellingAvailable = SpellChecker.isAvailable()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
4999 self.menuActs["SpellCheck"].setEnabled(spellingAvailable)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5000 self.menuActs["SpellCheckSelection"].setEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5001 spellingAvailable and self.hasSelectedText())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5002 self.menuActs["SpellCheckRemove"].setEnabled(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5003 spellingAvailable and self.spellingMenuPos >= 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5004
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
5005 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
5006 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
5007 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
5008 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
5009 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
5010 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
5011
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
5012 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
5013
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
5014 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
5015 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
5016 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
5017 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
5018 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
5019 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
5020 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
5021
4376
7847a37ee71d Little enhancement to the editor context menu to enable the Tools submenu only, if it contains some entries (populated by plug-ins).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4304
diff changeset
5022 self.menuActs["Tools"].setEnabled(not self.toolsMenu.isEmpty())
7847a37ee71d Little enhancement to the editor context menu to enable the Tools submenu only, if it contains some entries (populated by plug-ins).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4304
diff changeset
5023
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5024 self.showMenu.emit("Main", self.menu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5025
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5026 def __showContextMenuAutocompletion(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5027 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5028 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
5029 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5030 self.menuActs["acDynamic"].setEnabled(
4133
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
5031 self.canProvideDynamicAutoCompletion())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5032 self.menuActs["acAPI"].setEnabled(self.acAPI)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5033 self.menuActs["acAPIDocument"].setEnabled(self.acAPI)
4133
3d868439dddc Improved the handling of the various auto-completion actions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4074
diff changeset
5034 self.menuActs["calltip"].setEnabled(self.canProvideCallTipps())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5035
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5036 self.showMenu.emit("Autocompletion", self.autocompletionMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5037
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5038 def __showContextMenuShow(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5039 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5040 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
5041 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5042 prEnable = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5043 coEnable = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5044
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5045 # 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
5046 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
5047 self.project.isProjectSource(self.fileName):
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
5048 fn = self.project.getMainScript(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5049 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5050 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5051 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5052 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5053 prEnable = prEnable or \
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5054 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
5055 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
5056 coEnable = (
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
5057 coEnable or
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
5058 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
5059 os.path.isfile("{0}.coverage".format(tbasename))) and \
3496
b905cb8c520c Enable coverage info in Python2 projects.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484
diff changeset
5060 (self.project.isPy3Project() or
b905cb8c520c Enable coverage info in Python2 projects.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484
diff changeset
5061 self.project.isPy2Project())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5062
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5063 # now check ourself
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5064 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5065 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5066 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5067 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5068 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5069 prEnable = prEnable or \
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5070 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
5071 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
5072 coEnable = (
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
5073 coEnable or
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
5074 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
5075 os.path.isfile("{0}.coverage".format(tbasename))) and \
3496
b905cb8c520c Enable coverage info in Python2 projects.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3484
diff changeset
5076 self.isPyFile()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5077
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5078 # now check for syntax errors
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5079 if self.hasSyntaxErrors():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5080 coEnable = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5081
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5082 self.profileMenuAct.setEnabled(prEnable)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5083 self.coverageMenuAct.setEnabled(coEnable)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5084 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
5085 coEnable and len(self.notcoveredMarkers) == 0)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5086 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
5087 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
5088
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5089 self.showMenu.emit("Show", self.menuShow, self)
92
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 def __showContextMenuGraphics(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5092 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5093 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
5094 menu.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5095 """
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5096 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
5097 self.project.isProjectSource(self.fileName):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5098 self.applicationDiagramMenuAct.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5099 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5100 self.applicationDiagramMenuAct.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5101
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5102 self.showMenu.emit("Graphics", self.graphicsMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5103
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5104 def __showContextMenuMargin(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5105 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5106 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
5107 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5108 """
3446
5a670e55adbb Improved the way the Python variant of a source file is detected (thanks to Tobias Rzepka).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3441
diff changeset
5109 if self.fileName and (self.isPyFile() or self.isRubyFile()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5110 self.marginMenuActs["Breakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5111 self.marginMenuActs["TempBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5112 if self.markersAtLine(self.line) & self.breakpointMask:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5113 self.marginMenuActs["EditBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5114 self.marginMenuActs["EnableBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5115 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5116 self.marginMenuActs["EditBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5117 self.marginMenuActs["EnableBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5118 if self.markersAtLine(self.line) & (1 << self.dbreakpoint):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5119 self.marginMenuActs["EnableBreakpoint"].setText(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5120 self.tr('Enable breakpoint'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5121 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5122 self.marginMenuActs["EnableBreakpoint"].setText(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5123 self.tr('Disable breakpoint'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5124 if self.breaks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5125 self.marginMenuActs["NextBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5126 self.marginMenuActs["PreviousBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5127 self.marginMenuActs["ClearBreakpoint"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5128 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5129 self.marginMenuActs["NextBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5130 self.marginMenuActs["PreviousBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5131 self.marginMenuActs["ClearBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5132 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5133 self.marginMenuActs["Breakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5134 self.marginMenuActs["TempBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5135 self.marginMenuActs["EditBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5136 self.marginMenuActs["EnableBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5137 self.marginMenuActs["NextBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5138 self.marginMenuActs["PreviousBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5139 self.marginMenuActs["ClearBreakpoint"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5140
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5141 if self.bookmarks:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5142 self.marginMenuActs["NextBookmark"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5143 self.marginMenuActs["PreviousBookmark"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5144 self.marginMenuActs["ClearBookmark"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5145 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5146 self.marginMenuActs["NextBookmark"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5147 self.marginMenuActs["PreviousBookmark"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5148 self.marginMenuActs["ClearBookmark"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5149
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5150 if len(self.syntaxerrors):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5151 self.marginMenuActs["GotoSyntaxError"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5152 self.marginMenuActs["ClearSyntaxError"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5153 if self.markersAtLine(self.line) & (1 << self.syntaxerror):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5154 self.marginMenuActs["ShowSyntaxError"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5155 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5156 self.marginMenuActs["ShowSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5157 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5158 self.marginMenuActs["GotoSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5159 self.marginMenuActs["ClearSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5160 self.marginMenuActs["ShowSyntaxError"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5161
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5162 if len(self.warnings):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5163 self.marginMenuActs["NextWarningMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5164 self.marginMenuActs["PreviousWarningMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5165 self.marginMenuActs["ClearWarnings"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5166 if self.markersAtLine(self.line) & (1 << self.warning):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5167 self.marginMenuActs["ShowWarning"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5168 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5169 self.marginMenuActs["ShowWarning"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5170 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5171 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
5172 self.marginMenuActs["PreviousWarningMarker"].setEnabled(False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5173 self.marginMenuActs["ClearWarnings"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5174 self.marginMenuActs["ShowWarning"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5175
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5176 if self.notcoveredMarkers:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5177 self.marginMenuActs["NextCoverageMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5178 self.marginMenuActs["PreviousCoverageMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5179 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5180 self.marginMenuActs["NextCoverageMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5181 self.marginMenuActs["PreviousCoverageMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5182
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5183 if self.__hasTaskMarkers:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5184 self.marginMenuActs["PreviousTaskMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5185 self.marginMenuActs["NextTaskMarker"].setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5186 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5187 self.marginMenuActs["PreviousTaskMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5188 self.marginMenuActs["NextTaskMarker"].setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5189
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
5190 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
5191 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
5192 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
5193 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
5194 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
5195 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
5196
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5197 self.showMenu.emit("Margin", self.sender(), self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5198
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5199 def __showContextMenuChecks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5200 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5201 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
5202 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5203 """
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5204 self.showMenu.emit("Checks", self.checksMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5205
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
5206 def __showContextMenuTools(self):
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
5207 """
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
5208 Private slot handling the aboutToShow signal of the tools context
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
5209 menu.
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
5210 """
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
5211 self.showMenu.emit("Tools", self.toolsMenu, self)
3155
7e10d00e27ca Added a 'Tools' submenu to be populated by plug-ins and updated the plug-in document.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3152
diff changeset
5212
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5213 def __reopenWithEncodingMenuTriggered(self, act):
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5214 """
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5215 Private method to handle the rereading of the file with a selected
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5216 encoding.
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5217
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5218 @param act reference to the action that was triggered (QAction)
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5219 """
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5220 encoding = act.data()
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5221 self.readFile(self.fileName, encoding=encoding)
4418
32f721a2fdc6 Fixed an issue in the editor causing the encodings menu not being synchronized after a re-open operation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4411
diff changeset
5222 self.__checkEncoding()
3394
d1d4d79b4f11 Added a context menu entry to reload a file with a given encoding.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3393
diff changeset
5223
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5224 def __contextSave(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5225 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5226 Private slot handling the save context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5227 """
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
5228 ok = self.saveFile()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5229 if ok:
548
ac7af05dd54a Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 547
diff changeset
5230 self.vm.setEditorName(self, self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5231
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5232 def __contextSaveAs(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5233 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5234 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
5235 """
559
ee695ebbd6e0 Fixed an issue introduced by the E5MessageBox job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
5236 ok = self.saveFileAs()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5237 if ok:
559
ee695ebbd6e0 Fixed an issue introduced by the E5MessageBox job.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
5238 self.vm.setEditorName(self, self.fileName)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5239
4402
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
5240 def __contextSaveCopy(self):
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
5241 """
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
5242 Private slot handling the save copy context menu entry.
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
5243 """
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
5244 self.saveFileCopy()
ad524553e765 Added capability to save a copy of the editor contents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4385
diff changeset
5245
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5246 def __contextClose(self):
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 Private slot handling the close context menu entry.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5249 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5250 self.vm.closeEditor(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5251
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
5252 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
5253 """
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
5254 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
5255 """
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
5256 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
5257 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
5258 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
5259 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
5260
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5261 def __newView(self):
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 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
5264 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5265 self.vm.newEditorView(self.fileName, self, self.filetype)
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 def __newViewNewSplit(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5268 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5269 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
5270 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5271 self.vm.addSplit()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5272 self.vm.newEditorView(self.fileName, self, self.filetype)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5273
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5274 def __selectAll(self):
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 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
5277 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5278 self.selectAll(True)
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 def __deselectAll(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5281 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5282 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
5283 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5284 self.selectAll(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5285
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
5286 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
5287 """
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
5288 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
5289 """
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
5290 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
5291 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
5292 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
5293
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
5294 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
5295 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
5296 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
5297 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
5298
2994
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5299 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
5300 line1Text.lstrip().startswith(("'", '"')):
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5301 # merging multi line strings
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5302 startChars = "\r\n\\ \t'\""
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5303 endChars = " \t'\""
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5304 else:
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5305 startChars = "\r\n\\ \t"
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5306 endChars = " \t"
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5307
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
5308 # 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
5309 startIndex = len(line0Text)
2994
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5310 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
5311 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
5312 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
5313 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
5314
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
5315 # 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
5316 endIndex = 0
2994
5ae1349b8fb4 A little enhancement to the editors line joining function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2980
diff changeset
5317 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
5318 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
5319
e7d778ea21d6 Added an editor action to join the current line with the next one.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 461
diff changeset
5320 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
5321 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
5322 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
5323 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
5324 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
5325
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5326 def shortenEmptyLines(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5327 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5328 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
5329 characters.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5330 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5331 searchRE = r"^[ \t]+$"
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5332
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5333 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
5334 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5335 while ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5336 self.replaceTarget("")
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5337 ok = self.findNextTarget()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5338 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5339
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5340 def __autosaveEnable(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5341 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5342 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
5343 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5344 if self.menuActs["AutosaveEnable"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5345 self.autosaveManuallyDisabled = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5346 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5347 self.autosaveManuallyDisabled = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5348
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5349 def shouldAutosave(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5350 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5351 Public slot to check the autosave flags.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5352
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5353 @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
5354 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5355 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
5356 not self.autosaveManuallyDisabled and \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
5357 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
5358
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
5359 def checkSyntax(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5360 """
3581
03b351be4436 Einige kleinere Korrekturen.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3579
diff changeset
5361 Public method to perform an automatic syntax check of the file.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5362 """
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
5363 if self.syntaxCheckService is None or \
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
5364 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
5365 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
5366
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5367 if Preferences.getEditor("AutoCheckSyntax"):
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5368 if Preferences.getEditor("OnlineSyntaxCheck"):
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
5369 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
5370
3241
957673fc463a Interface for adding different languages to the syntax check, background service
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3177
diff changeset
5371 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
5372 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
5373
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5374 def __processSyntaxCheckError(self, fn, msg):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5375 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5376 Private slot to report an error message of a syntax check.
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5377
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5378 @param fn filename of the file
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5379 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5380 @param msg error message
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5381 @type str
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5382 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5383 if fn != self.fileName and (
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5384 self.fileName is not None or fn != "(Unnamed)"):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5385 return
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5386
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5387 self.clearSyntaxError()
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5388 self.clearFlakesWarnings()
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5389
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5390 self.toggleWarning(0, 0, True, msg)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5391
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5392 self.updateVerticalScrollBar()
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5393
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5394 def __processSyntaxCheckResult(self, fn, problems):
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5395 """
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
5396 Private slot to report the resulting messages of a syntax check.
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
5397
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
5398 @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
5399 @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
5400 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
5401 (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
5402 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
5403 """
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
5404 # 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
5405 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
5406 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
5407 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
5408
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
5409 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
5410 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
5411
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
5412 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
5413 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
5414 _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
5415 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
5416
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
5417 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
5418 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
5419 self.toggleWarning(lineno, col, True, msg)
4433
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4418
diff changeset
5420
7ab862396a8a Workaround for missing lines at vertical scroll bar caused by annotations.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4418
diff changeset
5421 self.updateVerticalScrollBar()
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
5422
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5423 def __initOnlineSyntaxCheck(self):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5424 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5425 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
5426 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5427 self.__onlineSyntaxCheckTimer = QTimer(self)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5428 self.__onlineSyntaxCheckTimer.setSingleShot(True)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5429 self.__onlineSyntaxCheckTimer.setInterval(
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5430 Preferences.getEditor("OnlineSyntaxCheckInterval") * 1000)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
5431 self.__onlineSyntaxCheckTimer.timeout.connect(self.checkSyntax)
1353
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5432 self.textChanged.connect(self.__resetOnlineSyntaxCheckTimer)
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5433
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5434 def __resetOnlineSyntaxCheckTimer(self):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5435 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5436 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
5437 """
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5438 if Preferences.getEditor("OnlineSyntaxCheck"):
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5439 self.__onlineSyntaxCheckTimer.stop()
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5440 self.__onlineSyntaxCheckTimer.start()
e1c0af081a8e Added a syntax check while typing function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1308
diff changeset
5441
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5442 def __showCodeMetrics(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5443 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5444 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
5445 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5446 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5447 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5448
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
5449 from DataViews.CodeMetricsDialog import CodeMetricsDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5450 self.codemetrics = CodeMetricsDialog()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5451 self.codemetrics.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5452 self.codemetrics.start(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5453
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5454 def __getCodeCoverageFile(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5455 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5456 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
5457 info.
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 @return filename of the coverage file (string)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5460 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5461 files = []
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 # 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
5464 # 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
5465 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
5466 self.project.isProjectSource(self.fileName):
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
5467 fn = self.project.getMainScript(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5468 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5469 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5470 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5471 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5472
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5473 f = "{0}.coverage".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5474 tf = "{0}.coverage".format(tbasename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5475 if os.path.isfile(f):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5476 files.append(f)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5477 if os.path.isfile(tf):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5478 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5479
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5480 # 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
5481 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5482 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5483 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5484 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5485 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5486
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5487 f = "{0}.coverage".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5488 tf = "{0}.coverage".format(tbasename)
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
5489 if os.path.isfile(f) and f not in files:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5490 files.append(f)
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
5491 if os.path.isfile(tf) and tf not in files:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5492 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5493
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5494 if files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5495 if len(files) > 1:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5496 fn, ok = QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5497 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5498 self.tr("Code Coverage"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5499 self.tr("Please select a coverage file"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5500 files,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5501 0, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5502 if not ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5503 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5504 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5505 fn = files[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5506 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5507 fn = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5508
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5509 return fn
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5510
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5511 def __showCodeCoverage(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5512 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5513 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
5514 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5515 fn = self.__getCodeCoverageFile()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5516 if fn:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
5517 from DataViews.PyCoverageDialog import PyCoverageDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5518 self.codecoverage = PyCoverageDialog()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5519 self.codecoverage.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5520 self.codecoverage.start(fn, self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5521
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
5522 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
5523 """
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
5524 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
5525 """
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
5526 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
5527 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
5528
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
5529 def codeCoverageShowAnnotations(self, silent=False):
2163
2b02339f52bf Enhanced the code coverage dialog functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2162
diff changeset
5530 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5531 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
5532 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
5533
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
5534 @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
5535 """
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
5536 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
5537
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5538 fn = self.__getCodeCoverageFile()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5539 if fn:
4489
d0d6e4ad31bd Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4433
diff changeset
5540 from 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
5541 cover = coverage(data_file=fn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5542 cover.load()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5543 missing = cover.analysis2(self.fileName)[3]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5544 if missing:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5545 for line in missing:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5546 handle = self.markerAdd(line - 1, self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5547 self.notcoveredMarkers.append(handle)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
5548 self.coverageMarkersShown.emit(True)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
5549 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5550 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
5551 if not silent:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5552 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5553 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5554 self.tr("Show Code Coverage Annotations"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5555 self.tr("""All lines have been covered."""))
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
5556 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
5557 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
5558 if not silent:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5559 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5560 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5561 self.tr("Show Code Coverage Annotations"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5562 self.tr("""There is no coverage file available."""))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5563
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5564 def __codeCoverageHideAnnotations(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5565 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5566 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
5567 menu action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5568 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5569 for handle in self.notcoveredMarkers:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5570 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5571 self.notcoveredMarkers = []
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5572 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
5573 self.showingNotcoveredMarkers = False
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
5574 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5575
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5576 def getCoverageLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5577 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5578 Public method to get the lines containing a coverage marker.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5579
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5580 @return list of lines containing a coverage marker (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5581 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5582 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5583 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5584 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5585 line = self.markerFindNext(line + 1, 1 << self.notcovered)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5586 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5587 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5588 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5589 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5590 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5591
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5592 def hasCoverageMarkers(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5593 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5594 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
5595
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
5596 @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
5597 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5598 return len(self.notcoveredMarkers) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5599
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5600 def nextUncovered(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5601 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5602 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
5603 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5604 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
5605 if line == self.lines() - 1:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5606 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5607 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5608 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5609 ucline = self.markerFindNext(line, 1 << self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5610 if ucline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5611 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5612 ucline = self.markerFindNext(0, 1 << self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5613 if ucline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5614 self.setCursorPosition(ucline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5615 self.ensureLineVisible(ucline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5616
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5617 def previousUncovered(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5618 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5619 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
5620 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5621 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5622 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
5623 line = self.lines() - 1
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5624 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5625 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5626 ucline = self.markerFindPrevious(line, 1 << self.notcovered)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5627 if ucline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5628 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5629 ucline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5630 self.lines() - 1, 1 << self.notcovered)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5631 if ucline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5632 self.setCursorPosition(ucline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5633 self.ensureLineVisible(ucline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5634
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5635 def __showProfileData(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5636 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5637 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
5638 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5639 files = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5640
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5641 # 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
5642 # 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
5643 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
5644 self.project.isProjectSource(self.fileName):
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
5645 fn = self.project.getMainScript(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5646 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5647 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5648 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5649 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5650
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5651 f = "{0}.profile".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5652 tf = "{0}.profile".format(tbasename)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5653 if os.path.isfile(f):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5654 files.append(f)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5655 if os.path.isfile(tf):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5656 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5657
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5658 # 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
5659 fn = self.getFileName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5660 if fn is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5661 tfn = Utilities.getTestFileName(fn)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5662 basename = os.path.splitext(fn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5663 tbasename = os.path.splitext(tfn)[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5664
429
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5665 f = "{0}.profile".format(basename)
dcc623c99907 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 404
diff changeset
5666 tf = "{0}.profile".format(tbasename)
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
5667 if os.path.isfile(f) and f not in files:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5668 files.append(f)
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
5669 if os.path.isfile(tf) and tf not in files:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5670 files.append(tf)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5671
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5672 if files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5673 if len(files) > 1:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
5674 fn, ok = QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5675 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5676 self.tr("Profile Data"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5677 self.tr("Please select a profile file"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5678 files,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5679 0, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5680 if not ok:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5681 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5682 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5683 fn = files[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5684 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5685 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5686
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
5687 from DataViews.PyProfileDialog import PyProfileDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5688 self.profiledata = PyProfileDialog()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5689 self.profiledata.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5690 self.profiledata.start(fn, self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5691
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5692 def __lmBbookmarks(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5693 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5694 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
5695 action.
92
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 self.marginMenuActs["LMBbookmarks"].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5698 self.marginMenuActs["LMBbreakpoints"].setChecked(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5699
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5700 def __lmBbreakpoints(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5701 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5702 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
5703 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5704 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5705 self.marginMenuActs["LMBbookmarks"].setChecked(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5706 self.marginMenuActs["LMBbreakpoints"].setChecked(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5707
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5708 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5709 ## 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
5710 ###########################################################################
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5711
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5712 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
5713 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5714 Public method to toggle a syntax error indicator.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5715
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5716 @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
5717 @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
5718 @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
5719 set or deleted (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5720 @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
5721 @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
5722 (boolean)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5723 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5724 if line == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5725 line = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5726 # 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
5727 if error:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5728 # set a new syntax error marker
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5729 markers = self.markersAtLine(line - 1)
3441
1b07f996e9ee Continued improving JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3438
diff changeset
5730 index += self.indentation(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5731 if not (markers & (1 << self.syntaxerror)):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5732 handle = self.markerAdd(line - 1, self.syntaxerror)
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
5733 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
5734 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
5735 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
5736 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
5737 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
5738 (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
5739 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
5740 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
5741 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
5742 self.ensureLineVisible(line - 1)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5743 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5744 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5745 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5746 del self.syntaxerrors[handle]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5747 self.markerDeleteHandle(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5748 self.syntaxerrorToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5749
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5750 self.__setAnnotation(line - 1)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
5751 self.__markerMap.update()
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5752
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5753 def getSyntaxErrors(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5754 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5755 Public method to retrieve the syntax error markers.
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 @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
5758 (list of integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5759 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5760 selist = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5761 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5762 selist.append(self.markerLine(handle) + 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5763
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5764 selist.sort()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5765 return selist
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5766
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5767 def getSyntaxErrorLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5768 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5769 Public method to get the lines containing a syntax error.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5770
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5771 @return list of lines containing a syntax error (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5772 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5773 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5774 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5775 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5776 line = self.markerFindNext(line + 1, 1 << self.syntaxerror)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5777 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5778 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5779 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5780 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5781 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5782
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5783 def hasSyntaxErrors(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5784 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5785 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
5786
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5787 @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
5788 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5789 return len(self.syntaxerrors) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5790
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5791 def gotoSyntaxError(self):
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 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
5794 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5795 seline = self.markerFindNext(0, 1 << self.syntaxerror)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5796 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
5797 index = 0
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5798 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
5799 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
5800 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
5801 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
5802 self.ensureLineVisible(seline)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5803
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5804 def clearSyntaxError(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5805 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5806 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
5807 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5808 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5809 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
5810 self.toggleSyntaxError(line, 0, False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5811
3149
e98100461710 Fixed an issue in the editor related to resetting a syntax error marker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3100
diff changeset
5812 self.syntaxerrors = {}
e98100461710 Fixed an issue in the editor related to resetting a syntax error marker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3100
diff changeset
5813 self.syntaxerrorToggled.emit(self)
e98100461710 Fixed an issue in the editor related to resetting a syntax error marker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3100
diff changeset
5814
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
5815 def __showSyntaxError(self, line=-1):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5816 """
915
c1e052773c08 Changed syntax check to report error position within the line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 882
diff changeset
5817 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
5818 context menu action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5819
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5820 @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
5821 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5822 if line == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5823 line = self.line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5824
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5825 for handle in list(self.syntaxerrors.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5826 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
5827 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
5828 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5829 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5830 self.tr("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
5831 "\n".join(errors))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5832 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5833 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5834 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
5835 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5836 self.tr("Syntax Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
5837 self.tr("No syntax error message available."))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5838
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5839 ###########################################################################
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
5840 ## 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
5841 ###########################################################################
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
5842
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
5843 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
5844 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
5845 """
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
5846 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
5847
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
5848 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
5849
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
5850 @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
5851 @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
5852 @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
5853 set or deleted (boolean)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5854 @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
5855 @keyparam warningType type of warning message (integer)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5856 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5857 if line == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5858 line = 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5859 # 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
5860 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
5861 # 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
5862 warn = (msg, warningType)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5863 markers = self.markersAtLine(line - 1)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5864 if not (markers & (1 << self.warning)):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5865 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
5866 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
5867 self.syntaxerrorToggled.emit(self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5868 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5869 for handle in list(self.warnings.keys()):
95
261bc03812fd Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 92
diff changeset
5870 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
5871 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
5872 self.warnings[handle].append(warn)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5873 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5874 for handle in list(self.warnings.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5875 if self.markerLine(handle) == line - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5876 del self.warnings[handle]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5877 self.markerDeleteHandle(handle)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
5878 self.syntaxerrorToggled.emit(self)
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5879
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
5880 self.__setAnnotation(line - 1)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
5881 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5882
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
5883 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
5884 """
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
5885 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
5886
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
5887 @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
5888 (list of integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5889 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5890 fwlist = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5891 for handle in list(self.warnings.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5892 fwlist.append(self.markerLine(handle) + 1)
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 fwlist.sort()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5895 return fwlist
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5896
3325
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5897 def getWarningLines(self):
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5898 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5899 Public method to get the lines containing a warning.
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5900
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5901 @return list of lines containing a warning (list of integer)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5902 """
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5903 lines = []
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5904 line = -1
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5905 while True:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5906 line = self.markerFindNext(line + 1, 1 << self.warning)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5907 if line < 0:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5908 break
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5909 else:
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5910 lines.append(line)
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5911 return lines
d2d6dda86d32 Added methods to extract the line numbers of the various marker types to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3261
diff changeset
5912
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
5913 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
5914 """
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
5915 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
5916
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
5917 @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
5918 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5919 return len(self.warnings) > 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5920
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
5921 def nextWarning(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5922 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5923 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
5924 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5925 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5926 if line == self.lines() - 1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5927 line = 0
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5928 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5929 line += 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5930 fwline = self.markerFindNext(line, 1 << self.warning)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5931 if fwline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5932 # wrap around
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5933 fwline = self.markerFindNext(0, 1 << self.warning)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5934 if fwline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5935 self.setCursorPosition(fwline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5936 self.ensureLineVisible(fwline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5937
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
5938 def previousWarning(self):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5939 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5940 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
5941 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5942 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5943 if line == 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5944 line = self.lines() - 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5945 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5946 line -= 1
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5947 fwline = self.markerFindPrevious(line, 1 << self.warning)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5948 if fwline < 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5949 # wrap around
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5950 fwline = self.markerFindPrevious(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
5951 self.lines() - 1, 1 << self.warning)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5952 if fwline >= 0:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5953 self.setCursorPosition(fwline, 0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5954 self.ensureLineVisible(fwline)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5955
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5956 def clearFlakesWarnings(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
5957 """
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
5958 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
5959 """
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
5960 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
5961
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
5962 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
5963 """
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
5964 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
5965 """
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
5966 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
5967
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
5968 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
5969 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
5970 Private method to clear warnings of a specific kind.
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
5971
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
5972 @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
5973 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
5974 """
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
5975 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
5976
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
5977 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
5978 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
5979 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
5980 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
5981 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
5982
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
5983 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
5984
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
5985 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
5986 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
5987 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
5988 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
5989 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
5990 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
5991 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
5992 self.syntaxerrorToggled.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
5993 self.__markerMap.update()
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
5994
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
5995 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
5996 """
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
5997 Public slot to clear all warnings.
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 for handle in self.warnings:
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6000 self.warnings[handle] = []
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6001 self.__setAnnotation(self.markerLine(handle))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6002 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6003 self.warnings = {}
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6004 self.syntaxerrorToggled.emit(self)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
6005 self.__markerMap.update()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6006
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
6007 def __showWarning(self, line=-1):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6008 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6009 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
6010
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
6011 @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
6012 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6013 if line == -1:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6014 line = self.line
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6015
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6016 for handle in list(self.warnings.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6017 if self.markerLine(handle) == line:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6018 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6019 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6020 self.tr("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
6021 '\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
6022 break
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6023 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6024 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6025 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6026 self.tr("Warning"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6027 self.tr("No warning messages available."))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6028
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6029 ###########################################################################
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6030 ## 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
6031 ###########################################################################
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6032
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6033 def __setAnnotationStyles(self):
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6034 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6035 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
6036 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6037 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
6038 self.annotationWarningStyle = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6039 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
6040 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6041 QsciScintilla.SCI_STYLESETFORE,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6042 self.annotationWarningStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6043 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
6044 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6045 QsciScintilla.SCI_STYLESETBACK,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6046 self.annotationWarningStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6047 Preferences.getEditorColour("AnnotationsWarningBackground"))
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6048
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6049 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
6050 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6051 QsciScintilla.SCI_STYLESETFORE,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6052 self.annotationErrorStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6053 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
6054 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6055 QsciScintilla.SCI_STYLESETBACK,
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6056 self.annotationErrorStyle,
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6057 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
6058
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6059 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
6060 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6061 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
6062 self.annotationStyleStyle,
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6063 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
6064 self.SendScintilla(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6065 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
6066 self.annotationStyleStyle,
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6067 Preferences.getEditorColour("AnnotationsStyleBackground"))
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6068
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6069 def __setAnnotation(self, line):
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6070 """
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6071 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
6072
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6073 @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
6074 """
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6075 if hasattr(QsciScintilla, "annotate"):
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6076 warningAnnotations = []
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6077 errorAnnotations = []
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6078 styleAnnotations = []
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6079
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6080 # 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
6081 for handle in self.warnings.keys():
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6082 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
6083 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
6084 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
6085 styleAnnotations.append(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6086 self.tr("Style: {0}").format(msg))
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6087 else:
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6088 warningAnnotations.append(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6089 self.tr("Warning: {0}").format(msg))
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6090
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6091 # 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
6092 for handle in self.syntaxerrors.keys():
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6093 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
6094 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
6095 errorAnnotations.append(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6096 self.tr("Error: {0}").format(msg))
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6097
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6098 annotations = []
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
6099 if styleAnnotations:
2905
a1ae4b297bc0 Added capability to have different warning styles to the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2904
diff changeset
6100 annotationStyleTxt = "\n".join(styleAnnotations)
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
6101 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
6102 annotationStyleTxt += "\n"
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6103 annotations.append(QsciStyledText(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6104 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
6105
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
6106 if warningAnnotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6107 annotationWarningTxt = "\n".join(warningAnnotations)
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
6108 if errorAnnotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6109 annotationWarningTxt += "\n"
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6110 annotations.append(QsciStyledText(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6111 annotationWarningTxt, self.annotationWarningStyle))
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6112
2959
86ad8854361b Corrected an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2955
diff changeset
6113 if errorAnnotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6114 annotationErrorTxt = "\n".join(errorAnnotations)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6115 annotations.append(QsciStyledText(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6116 annotationErrorTxt, self.annotationErrorStyle))
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6117
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6118 if annotations:
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6119 self.annotate(line, annotations)
726
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6120 else:
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6121 self.clearAnnotations(line)
57d1efea16e0 Started implementing annotations support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 723
diff changeset
6122
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6123 def __refreshAnnotations(self):
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6124 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6125 Private method to refresh the annotations.
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6126 """
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6127 if hasattr(QsciScintilla, "annotate"):
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6128 self.clearAnnotations()
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6129 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
6130 list(self.syntaxerrors.keys()):
728
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6131 line = self.markerLine(handle)
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6132 self.__setAnnotation(line)
3ee110082fb7 Finished implementing the display of annotations .
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 726
diff changeset
6133
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 ## Macro handling methods
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
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6138 def __getMacroName(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6139 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6140 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
6141
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6142 @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
6143 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
6144 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6145 qs = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6146 for s in list(self.macros.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6147 qs.append(s)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6148 qs.sort()
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
6149 return QInputDialog.getItem(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6150 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6151 self.tr("Macro Name"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6152 self.tr("Select a macro name:"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6153 qs,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6154 0, False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6155
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6156 def macroRun(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6157 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6158 Public method to execute a macro.
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 name, ok = self.__getMacroName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6161 if ok and name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6162 self.macros[name].play()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6163
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6164 def macroDelete(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6165 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6166 Public method to delete a macro.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6167 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6168 name, ok = self.__getMacroName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6169 if ok and name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6170 del self.macros[name]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6171
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6172 def macroLoad(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6173 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6174 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
6175 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6176 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
6177 fname = E5FileDialog.getOpenFileName(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6178 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6179 self.tr("Load macro file"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6180 configDir,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6181 self.tr("Macro files (*.macro)"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6182
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6183 if not fname:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6184 return # user aborted
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6185
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6186 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
6187 f = open(fname, "r", encoding="utf-8")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6188 lines = f.readlines()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6189 f.close()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6190 except IOError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6191 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6192 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6193 self.tr("Error loading macro"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6194 self.tr(
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6195 "<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
6196 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6197 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6198
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6199 if len(lines) != 2:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6200 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6201 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6202 self.tr("Error loading macro"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6203 self.tr("<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
6204 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6205 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6206
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6207 macro = QsciMacro(lines[1], self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6208 self.macros[lines[0].strip()] = macro
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6209
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6210 def macroSave(self):
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 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
6213 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6214 configDir = Utilities.getConfigDir()
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 name, ok = self.__getMacroName()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6217 if not ok or not name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6218 return # user abort
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6219
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6220 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6221 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6222 self.tr("Save macro file"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6223 configDir,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6224 self.tr("Macro files (*.macro)"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6225 "",
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6226 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6227
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6228 if not fname:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6229 return # user aborted
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6230
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6231 ext = QFileInfo(fname).suffix()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6232 if not ext:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6233 ex = selectedFilter.split("(*")[1].split(")")[0]
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6234 if ex:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6235 fname += ex
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6236 if QFileInfo(fname).exists():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6237 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6238 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6239 self.tr("Save macro"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6240 self.tr("<p>The macro file <b>{0}</b> already exists."
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6241 " 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
6242 icon=E5MessageBox.Warning)
546
c3e7bf5648be Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 542
diff changeset
6243 if not res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6244 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6245 fname = Utilities.toNativeSeparators(fname)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6246
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6247 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
6248 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
6249 f.write("{0}{1}".format(name, "\n"))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6250 f.write(self.macros[name].save())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6251 f.close()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6252 except IOError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6253 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6254 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6255 self.tr("Error saving macro"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6256 self.tr(
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6257 "<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
6258 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6259 return
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 def macroRecordingStart(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6262 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6263 Public method to start macro recording.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6264 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6265 if self.recording:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6266 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6267 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6268 self.tr("Start Macro Recording"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6269 self.tr("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
6270 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
6271 yesDefault=True)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
6272 if res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6273 self.macroRecordingStop()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6274 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6275 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6276 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6277 self.recording = True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6278
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6279 self.curMacro = QsciMacro(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6280 self.curMacro.startRecording()
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 def macroRecordingStop(self):
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 Public method to stop macro recording.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6285 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6286 if not self.recording:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6287 return # we are not recording
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6288
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6289 self.curMacro.endRecording()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6290 self.recording = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6291
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
6292 name, ok = QInputDialog.getText(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6293 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6294 self.tr("Macro Recording"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6295 self.tr("Enter name of the macro:"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6296 QLineEdit.Normal)
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 if ok and name:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6299 self.macros[name] = self.curMacro
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6300
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6301 self.curMacro = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6302
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6303 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6304 ## Overwritten methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6305 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6306
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6307 def undo(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6308 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6309 Public method to undo the last recorded change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6310 """
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
6311 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
6312 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
6313 self.redoAvailable.emit(self.isRedoAvailable())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6314
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6315 def redo(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6316 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6317 Public method to redo the last recorded change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6318 """
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
6319 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
6320 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
6321 self.redoAvailable.emit(self.isRedoAvailable())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6322
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6323 def close(self, alsoDelete=False):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6324 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6325 Public method called when the window gets closed.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6326
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6327 This overwritten method redirects the action to our
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6328 ViewManager.closeEditor, which in turn calls our closeIt
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6329 method.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6330
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6331 @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
6332 @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
6333 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6334 return self.vm.closeEditor(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6335
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6336 def closeIt(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6337 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6338 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
6339 """
1930
3ecd42f536fd Fixed an issue related to breakpoints and cloned editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1928
diff changeset
6340 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
6341 self.__menuClearBreakpoints()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6342
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6343 for clone in self.__clones[:]:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6344 self.removeClone(clone)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6345 clone.removeClone(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6346
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
6347 self.breakpointModel.rowsAboutToBeRemoved.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6348 self.__deleteBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
6349 self.breakpointModel.dataAboutToBeChanged.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6350 self.__breakPointDataAboutToBeChanged)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
6351 self.breakpointModel.dataChanged.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6352 self.__changeBreakPoints)
460
6a3899e91d76 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 448
diff changeset
6353 self.breakpointModel.rowsInserted.disconnect(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6354 self.__addBreakPoints)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6355
3972
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
6356 if self.syntaxCheckService is not None:
efc9c803ebdc Fixed an issue related to handling an inactive syntax checker in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3971
diff changeset
6357 self.syntaxCheckService.syntaxChecked.disconnect(
4503
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
6358 self.__processSyntaxCheckResult)
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
6359 self.syntaxCheckService.error.disconnect(
d68dcbe1deb3 Improved the syntax checker, code style checker and indentation checker interfaces.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4498
diff changeset
6360 self.__processSyntaxCheckError)
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
6361
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6362 if self.spell:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6363 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
6364
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
6365 try:
507
23652b3a0533 Fixed an issue with not connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 502
diff changeset
6366 self.project.projectPropertiesChanged.disconnect(
23652b3a0533 Fixed an issue with not connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 502
diff changeset
6367 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
6368 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
6369 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6370
1406
e2f1634cceed Fixed an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1373
diff changeset
6371 if self.fileName:
e2f1634cceed Fixed an issue in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1373
diff changeset
6372 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
6373
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
6374 super(Editor, self).close()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6375
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6376 def keyPressEvent(self, ev):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6377 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
6378 Protected method to handle the user input a key at a time.
92
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 @param ev key event (QKeyEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6381 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6382 txt = ev.text()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6383
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6384 # See it is text to insert.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6385 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
6386 super(Editor, self).keyPressEvent(ev)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6387 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6388 ev.ignore()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6389
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6390 def focusInEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6391 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6392 Protected method called when the editor receives focus.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6393
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6394 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
6395 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
6396 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
6397 reread.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6398
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6399 @param event the event object (QFocusEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6400 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6401 self.recolor()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6402 self.vm.editActGrp.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6403 self.vm.editorActGrp.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6404 self.vm.copyActGrp.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6405 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
6406 self.vm.searchActGrp.setEnabled(True)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6407 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6408 self.setCaretWidth(self.caretWidth)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6409 except AttributeError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6410 pass
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6411 self.__updateReadOnly(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6412 if self.vm.editorsCheckFocusInEnabled() and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6413 not self.inReopenPrompt and self.fileName and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6414 QFileInfo(self.fileName).lastModified().toString() != \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6415 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
6416 self.inReopenPrompt = True
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6417 if Preferences.getEditor("AutoReopen") and not self.isModified():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6418 self.refresh()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6419 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6420 msg = self.tr(
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6421 """<p>The file <b>{0}</b> has been changed while it"""
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
6422 """ was opened in eric6. Reread it?</p>""")\
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6423 .format(self.fileName)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
6424 yesDefault = True
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6425 if self.isModified():
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6426 msg += self.tr(
929
ed471c1f23b8 Fixed a typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 915
diff changeset
6427 """<br><b>Warning:</b> You will lose"""
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6428 """ your changes upon reopening it.""")
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
6429 yesDefault = False
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6430 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6431 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6432 self.tr("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
6433 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
6434 yesDefault=yesDefault)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
6435 if res:
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6436 self.refresh()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6437 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6438 # do not prompt for this change again...
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6439 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
6440 self.inReopenPrompt = False
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6441
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
6442 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
6443
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
6444 super(Editor, self).focusInEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6445
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6446 def focusOutEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6447 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
6448 Protected method called when the editor loses focus.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6449
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6450 @param event the event object (QFocusEvent)
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 self.vm.editorActGrp.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6453 self.setCaretWidth(0)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6454
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
6455 super(Editor, self).focusOutEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6456
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6457 def changeEvent(self, evt):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6458 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6459 Protected method called to process an event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6460
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6461 This implements special handling for the events showMaximized,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6462 showMinimized and showNormal. The windows caption is shortened
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6463 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
6464 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
6465 with the QWorkspace.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6466
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6467 @param evt the event, that was generated (QEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6468 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6469 if evt.type() == QEvent.WindowStateChange and \
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6470 self.fileName is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6471 if self.windowState() == Qt.WindowStates(Qt.WindowMinimized):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6472 cap = os.path.basename(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6473 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6474 cap = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6475 if self.isReadOnly():
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6476 cap = self.tr("{0} (ro)").format(cap)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6477 self.setWindowTitle(cap)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6478
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
6479 super(Editor, self).changeEvent(evt)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6480
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6481 def mousePressEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6482 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6483 Protected method to handle the mouse press event.
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 @param event the mouse press event (QMouseEvent)
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 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
6488 super(Editor, self).mousePressEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6489
1507
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6490 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
6491 """
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6492 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
6493
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6494 @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
6495 """
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
6496 if qVersion() >= "5.0.0":
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
6497 delta = evt.angleDelta().y()
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
6498 else:
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
6499 delta = evt.delta()
1507
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6500 if evt.modifiers() & Qt.ControlModifier:
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
6501 if 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
6502 self.zoomOut()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6503 else:
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6504 self.zoomIn()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6505 evt.accept()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6506 return
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6507
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6508 if evt.modifiers() & Qt.ShiftModifier:
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
6509 if 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
6510 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
6511 else:
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6512 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
6513 evt.accept()
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6514 return
9225700cbff5 - added capability to zoom by Ctrl + Mouse Wheel to the editor
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1500
diff changeset
6515
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
6516 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
6517
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
6518 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
6519 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
6520 Public method handling events.
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
6521
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
6522 @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
6523 @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
6524 """
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
6525 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
6526 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
6527 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
6528
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
6529 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
6530
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
6531 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
6532 """
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
6533 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
6534
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
6535 @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
6536 """
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
6537 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
6538 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
6539 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
6540 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
6541 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
6542 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
6543 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
6544 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
6545 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
6546 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
6547 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
6548 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
6549 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
6550 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
6551 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
6552
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6553 def resizeEvent(self, evt):
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6554 """
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6555 Protected method handling resize events.
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6556
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6557 @param evt reference to the resize event (QResizeEvent)
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6558 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3456 3446
diff changeset
6559 super(Editor, self).resizeEvent(evt)
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6560 self.__markerMap.calculateGeometry()
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6561
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6562 def viewportEvent(self, evt):
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6563 """
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6564 Protected method handling event of the viewport.
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6565
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6566 @param evt reference to the event (QEvent)
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6567 @return flag indiating that the event was handled (boolean)
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6568 """
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6569 self.__markerMap.calculateGeometry()
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3456 3446
diff changeset
6570 return super(Editor, self).viewportEvent(evt)
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6571
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6572 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
6573 """
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
6574 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
6575
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6576 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
6577 the attributes have actually changed, such as during
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6578 initialization time. A signal is emitted after the
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6579 caption change.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6580
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6581 @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
6582 signal if there was an attribute change.
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.fileName is None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6585 return
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6586 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
6587 self.isReadOnly()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6588 if not bForce and (readOnly == self.isReadOnly()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6589 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6590 cap = self.fileName
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6591 if readOnly:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6592 cap = self.tr("{0} (ro)".format(cap))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6593 self.setReadOnly(readOnly)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6594 self.setWindowTitle(cap)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6595 self.captionChanged.emit(cap, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6596
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6597 def refresh(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6598 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6599 Public slot to refresh the editor contents.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6600 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6601 # save cursor position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6602 cline, cindex = self.getCursorPosition()
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 # save bookmarks and breakpoints and clear them
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6605 bmlist = self.getBookmarks()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6606 self.clearBookmarks()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6607
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6608 # clear syntax error markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6609 self.clearSyntaxError()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6610
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6611 # 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
6612 self.clearWarnings()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6613
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6614 # clear breakpoint markers
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6615 for handle in list(self.breaks.keys()):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6616 self.markerDeleteHandle(handle)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6617 self.breaks = {}
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6618
3261
b8fee972444b Fixed issues with reopening a project where files were delete while they were opened in an editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3211
diff changeset
6619 if not os.path.exists(self.fileName):
b8fee972444b Fixed issues with reopening a project where files were delete while they were opened in an editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3211
diff changeset
6620 # close the file, if it was deleted in the background
b8fee972444b Fixed issues with reopening a project where files were delete while they were opened in an editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3211
diff changeset
6621 self.close()
b8fee972444b Fixed issues with reopening a project where files were delete while they were opened in an editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3211
diff changeset
6622 return
b8fee972444b Fixed issues with reopening a project where files were delete while they were opened in an editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3211
diff changeset
6623
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6624 # reread the file
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6625 try:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6626 self.readFile(self.fileName)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6627 except IOError:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6628 # do not prompt for this change again...
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6629 self.lastModified = QDateTime.currentDateTime()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6630 self.setModified(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6631
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
6632 # 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
6633 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
6634
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6635 # reset cursor position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6636 self.setCursorPosition(cline, cindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6637 self.ensureCursorVisible()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6638
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6639 # reset bookmarks and breakpoints to their old position
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6640 if bmlist:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6641 for bm in bmlist:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6642 self.toggleBookmark(bm)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6643 self.__restoreBreakpoints()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6644
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
6645 self.editorSaved.emit(self.fileName)
3579
eccd12461319 BackgroundService: Restart of the client in different situations handled.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3576
diff changeset
6646 self.checkSyntax()
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6647
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
6648 self.__markerMap.update()
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3327
diff changeset
6649
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
6650 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
6651
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6652 def setMonospaced(self, on):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6653 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6654 Public method to set/reset a monospaced font.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6655
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6656 @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
6657 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6658 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
6659 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
6660 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
6661 self.monospacedStyles(f)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6662 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6663 if not self.lexer_:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6664 self.clearStyles()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6665 self.__setMarginsDisplay()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6666 self.setFont(Preferences.getEditorOtherFonts("DefaultFont"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6667
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6668 self.useMonospaced = on
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6669
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
6670 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
6671 """
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
6672 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
6673 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
6674 """
3142
55030c09e142 Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3080 3100
diff changeset
6675 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
6676 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
6677 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
6678 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
6679
92
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 ## Drag and Drop Support
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6682 #################################################################
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 dragEnterEvent(self, event):
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 Protected method to handle the drag enter event.
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 @param event the drag enter event (QDragEnterEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6689 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6690 self.inDragDrop = event.mimeData().hasUrls()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6691 if self.inDragDrop:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6692 event.acceptProposedAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6693 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
6694 super(Editor, self).dragEnterEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6695
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6696 def dragMoveEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6697 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6698 Protected method to handle the drag move event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6699
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6700 @param event the drag move event (QDragMoveEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6701 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6702 if self.inDragDrop:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6703 event.accept()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6704 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
6705 super(Editor, self).dragMoveEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6706
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6707 def dragLeaveEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6708 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6709 Protected method to handle the drag leave event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6710
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6711 @param event the drag leave event (QDragLeaveEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6712 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6713 if self.inDragDrop:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6714 self.inDragDrop = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6715 event.accept()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6716 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
6717 super(Editor, self).dragLeaveEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6718
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6719 def dropEvent(self, event):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6720 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6721 Protected method to handle the drop event.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6722
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6723 @param event the drop event (QDropEvent)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6724 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6725 if event.mimeData().hasUrls():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6726 for url in event.mimeData().urls():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6727 fname = url.toLocalFile()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6728 if fname:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6729 if not QFileInfo(fname).isDir():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6730 self.vm.openSourceFile(fname)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6731 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6732 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6733 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6734 self.tr("Drop Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6735 self.tr("""<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
6736 .format(fname))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6737 event.acceptProposedAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6738 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
6739 super(Editor, self).dropEvent(event)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6740
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6741 self.inDragDrop = False
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6742
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6743 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6744 ## Support for Qt resources files
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6745 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6746
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6747 def __initContextMenuResources(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6748 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6749 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
6750
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
6751 @return reference to the generated menu (QMenu)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6752 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6753 menu = QMenu(self.tr('Resources'))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6754
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6755 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6756 self.tr('Add file...'), self.__addFileResource)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6757 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6758 self.tr('Add files...'), self.__addFileResources)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6759 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6760 self.tr('Add aliased file...'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6761 self.__addFileAliasResource)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6762 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6763 self.tr('Add localized resource...'),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6764 self.__addLocalizedResource)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6765 menu.addSeparator()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6766 menu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6767 self.tr('Add resource frame'), self.__addResourceFrame)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6768
461
34528aaedf1c Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 460
diff changeset
6769 menu.aboutToShow.connect(self.__showContextMenuResources)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6770
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6771 return menu
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6772
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6773 def __showContextMenuResources(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6774 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6775 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
6776 menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6777 """
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
6778 self.showMenu.emit("Resources", self.resourcesMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6779
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6780 def __addFileResource(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6781 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6782 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
6783 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6784 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
6785 file = E5FileDialog.getOpenFileName(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6786 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6787 self.tr("Add file resource"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6788 dirStr,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6789 "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6790 if file:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6791 relFile = QDir(dirStr).relativeFilePath(file)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6792 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6793 self.insert(" <file>{0}</file>\n".format(relFile))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6794 self.setCursorPosition(line + 1, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6795
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6796 def __addFileResources(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6797 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6798 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
6799 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6800 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
6801 files = E5FileDialog.getOpenFileNames(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6802 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6803 self.tr("Add file resources"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6804 dirStr,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6805 "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6806 if files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6807 myDir = QDir(dirStr)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6808 filesText = ""
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6809 for file in files:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6810 relFile = myDir.relativeFilePath(file)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6811 filesText += " <file>{0}</file>\n".format(relFile)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6812 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6813 self.insert(filesText)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6814 self.setCursorPosition(line + len(files), index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6815
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6816 def __addFileAliasResource(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6817 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6818 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
6819 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6820 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
6821 file = E5FileDialog.getOpenFileName(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6822 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6823 self.tr("Add aliased file resource"),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6824 dirStr,
882
34b86be88bf0 Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 880
diff changeset
6825 "")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6826 if file:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6827 relFile = QDir(dirStr).relativeFilePath(file)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 559
diff changeset
6828 alias, ok = QInputDialog.getText(
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6829 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6830 self.tr("Add aliased file resource"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6831 self.tr("Alias for file <b>{0}</b>:").format(relFile),
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6832 QLineEdit.Normal,
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6833 relFile)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6834 if ok and alias:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6835 line, index = self.getCursorPosition()
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
6836 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
6837 .format(relFile, alias))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6838 self.setCursorPosition(line + 1, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6839
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6840 def __addLocalizedResource(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6841 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6842 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
6843 action.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6844 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6845 from Project.AddLanguageDialog import AddLanguageDialog
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6846 dlg = AddLanguageDialog(self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6847 if dlg.exec_() == QDialog.Accepted:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6848 lang = dlg.getSelectedLanguage()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6849 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6850 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
6851 self.setCursorPosition(line + 2, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6852
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6853 def __addResourceFrame(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6854 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6855 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
6856 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6857 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6858 self.insert('<!DOCTYPE RCC>\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6859 '<RCC version="1.0">\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6860 '<qresource>\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6861 '</qresource>\n'
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6862 '</RCC>\n')
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6863 self.setCursorPosition(line + 5, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6864
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6865 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6866 ## Support for diagrams below
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6867 #################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6868
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6869 def __showClassDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6870 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6871 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
6872 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6873 from Graphics.UMLDialog import UMLDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6874 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6875 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6876
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6877 self.classDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6878 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
6879 self, noAttrs=False)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6880 self.classDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6881
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6882 def __showPackageDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6883 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6884 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
6885 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6886 from Graphics.UMLDialog import UMLDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6887 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6888 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6889
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6890 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
6891 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
6892 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6893 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6894 self.tr("Package Diagram"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6895 self.tr("""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
6896 yesDefault=True)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6897 self.packageDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6898 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
6899 self, noAttrs=not res)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6900 self.packageDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6901
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6902 def __showImportsDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6903 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6904 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
6905 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6906 from Graphics.UMLDialog import UMLDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6907 if not self.checkDirty():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6908 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6909
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6910 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
6911 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
6912 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6913 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6914 self.tr("Imports Diagram"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6915 self.tr("""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
6916 self.importsDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6917 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
6918 self, showExternalImports=res)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6919 self.importsDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6920
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6921 def __showApplicationDiagram(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6922 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6923 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
6924 """
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2025
diff changeset
6925 from Graphics.UMLDialog import UMLDialog
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6926 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
6927 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6928 self.tr("Application Diagram"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
6929 self.tr("""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
6930 yesDefault=True)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6931 self.applicationDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6932 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
6933 self, noModules=not res)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6934 self.applicationDiagram.show()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6935
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6936 def __loadDiagram(self):
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6937 """
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6938 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
6939 """
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6940 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
6941 self.loadedDiagram = UMLDialog(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
6942 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
6943 if self.loadedDiagram.load():
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6944 self.loadedDiagram.show(fromFile=True)
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6945 else:
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6946 self.loadedDiagram = None
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
6947
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6948 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6949 ## Typing aids related methods below
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6950 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6951
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6952 def __toggleTypingAids(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6953 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6954 Private slot to toggle the typing aids.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6955 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6956 if self.menuActs["TypingAidsEnabled"].isChecked():
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6957 self.completer.setEnabled(True)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6958 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6959 self.completer.setEnabled(False)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6960
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6961 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6962 ## Autocompleting templates
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6963 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6964
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6965 def editorCommand(self, cmd):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6966 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6967 Public method to perform a simple editor command.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6968
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6969 @param cmd the scintilla command to be performed
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6970 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6971 if cmd == QsciScintilla.SCI_TAB:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6972 line, index = self.getCursorPosition()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6973 tmplName = self.getWordLeft(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6974 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
6975 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
6976 tmplName, self.getLanguage()):
1723
6e690a8f5971 Fixed an issue in the editor applying templates.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
6977 self.__applyTemplate(tmplName, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6978 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6979 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6980 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
6981 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
6982 tmplName, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6983 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
6984 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
6985 self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6986 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6987 elif len(templateNames) > 1:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6988 self.showUserList(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
6989 TemplateCompletionListID,
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
6990 ["{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
6991 for t in templateNames])
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6992 return
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6993
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
6994 super(Editor, self).editorCommand(cmd)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6995
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
6996 def __applyTemplate(self, templateName, language):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6997 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6998 Private method to apply a template by name.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
6999
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7000 @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
7001 @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
7002 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
7003 """
1151d1ea562a Enhanced the autocompletion of templates to observe the language of the current file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 994
diff changeset
7004 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
7005 templateName, self.getLanguage()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7006 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
7007 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
7008 templateName, self.getLanguage())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7009
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7010 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7011 ## Project related methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7012 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7013
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7014 def __projectPropertiesChanged(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7015 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7016 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
7017 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7018 if self.spell:
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
7019 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
7020 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
7021 pwl=pwl, pel=pel)
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
7022
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
7023 self.setEolModeByEolString(self.project.getEolString())
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 252
diff changeset
7024 self.convertEols(self.eolMode())
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7025
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7026 def addedToProject(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7027 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7028 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
7029 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7030 if self.spell:
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
7031 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
7032 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
7033 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
7034
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7035 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
7036 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
7037
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
7038 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
7039 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
7040 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
7041 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
7042 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
7043 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
7044 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
7045 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
7046 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
7047
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
7048 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
7049 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
7050 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
7051 """
4e2f87d03546 Fixed an issue in the editor caused by double connecting to a signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1723
diff changeset
7052 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
7053 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
7054 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
7055 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
7056 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7057
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7058 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7059 ## Spellchecking related methods
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7060 #######################################################################
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7061
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
7062 def __setSpellingLanguage(self, language, pwl="", pel=""):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7063 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7064 Private slot to set the spell checking language.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7065
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7066 @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
7067 @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
7068 @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
7069 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7070 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
7071 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
7072 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7073
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7074 def __setSpelling(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7075 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7076 Private method to initialize the spell checking functionality.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7077 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7078 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
7079 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
7080 "SpellCheckStringsOnly")
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7081 if self.spell is None:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
7082 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
7083 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
7084 checkRegion=self.isSpellCheckRegion)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7085 self.setSpellingForProject()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7086 self.spell.setMinimumWordSize(
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7087 Preferences.getEditor("SpellCheckingMinWordSize"))
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7088
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7089 self.setAutoSpellChecking()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7090 else:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7091 self.spell = None
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7092 self.clearAllIndicators(self.spellingIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7093
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7094 def setSpellingForProject(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7095 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7096 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
7097 to the current project.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7098 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7099 if self.fileName and \
252
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
7100 self.project.isOpen() and \
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
7101 self.project.isProjectSource(self.fileName):
05692e3d37bf Some code cleanup in Editor.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
7102 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
7103 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
7104 pwl=pwl, pel=pel)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7105
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7106 def setAutoSpellChecking(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7107 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7108 Public method to set the automatic spell checking.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7109 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7110 if Preferences.getEditor("AutoSpellCheckingEnabled"):
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
7111 try:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7112 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
7113 self.__spellCharAdded, Qt.UniqueConnection)
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
7114 except TypeError:
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
7115 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7116 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7117 else:
542
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
7118 try:
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
7119 self.SCN_CHARADDED.disconnect(self.__spellCharAdded)
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
7120 except TypeError:
26a79c19993c Fixed a signal/slot issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
7121 pass
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7122 self.clearAllIndicators(self.spellingIndicator)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7123
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7124 def isSpellCheckRegion(self, pos):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7125 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7126 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
7127 should be spell checked.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7128
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7129 @param pos position to be checked (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7130 @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
7131 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7132 if self.__spellCheckStringsOnly:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7133 style = self.styleAt(pos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7134 if self.lexer_ is not None:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7135 return self.lexer_.isCommentStyle(style) or \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
7136 self.lexer_.isStringStyle(style)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7137 return True
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7138
1768
8a04ce23e083 Fixed another issue with a multi-connected signal.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1762
diff changeset
7139 @pyqtSlot(int)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7140 def __spellCharAdded(self, charNumber):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7141 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
7142 Private slot called to handle the user entering a character.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7143
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7144 @param charNumber value of the character entered (integer)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7145 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7146 if self.spell:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7147 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
7148 self.spell.checkWord(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7149 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
7150 elif self.hasIndicator(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7151 self.spellingIndicator, self.currentPosition()):
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7152 self.spell.checkWord(self.currentPosition())
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7153
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7154 def checkSpelling(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7155 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7156 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
7157 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7158 if self.spell:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7159 cline, cindex = self.getCursorPosition()
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
7160 from .SpellCheckingDialog import SpellCheckingDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7161 dlg = SpellCheckingDialog(self.spell, 0, self.length(), self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7162 dlg.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7163 self.setCursorPosition(cline, cindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7164 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7165 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7166
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7167 def __checkSpellingSelection(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7168 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7169 Private slot to spell check the current selection.
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7170 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
7171 from .SpellCheckingDialog import SpellCheckingDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7172 sline, sindex, eline, eindex = self.getSelection()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7173 startPos = self.positionFromLineIndex(sline, sindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7174 endPos = self.positionFromLineIndex(eline, eindex)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7175 dlg = SpellCheckingDialog(self.spell, startPos, endPos, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7176 dlg.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7177
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7178 def __checkSpellingWord(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7179 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7180 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
7181 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2391
diff changeset
7182 from .SpellCheckingDialog import SpellCheckingDialog
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7183 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7184 wordStart, wordEnd = self.getWordBoundaries(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7185 wordStartPos = self.positionFromLineIndex(line, wordStart)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7186 wordEndPos = self.positionFromLineIndex(line, wordEnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7187 dlg = SpellCheckingDialog(self.spell, wordStartPos, wordEndPos, self)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7188 dlg.exec_()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7189
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7190 def __showContextMenuSpelling(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7191 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7192 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
7193 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7194 self.spellingMenu.clear()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7195 self.spellingSuggActs = []
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7196 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7197 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7198 suggestions = self.spell.getSuggestions(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7199 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
7200 self.spellingSuggActs.append(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7201 self.spellingMenu.addAction(suggestion))
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7202 if suggestions:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7203 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
7204 self.spellingMenu.addAction(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7205 UI.PixmapCache.getIcon("spellchecking.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
7206 self.tr("Check spelling..."), self.__checkSpellingWord)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
7207 self.spellingMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
7208 self.tr("Add to dictionary"), self.__addToSpellingDictionary)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
7209 self.spellingMenu.addAction(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
7210 self.tr("Ignore All"), self.__ignoreSpellingAlways)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7211
3327
1338767b5315 Started implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3325
diff changeset
7212 self.showMenu.emit("Spelling", self.spellingMenu, self)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7213
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7214 def __contextMenuSpellingTriggered(self, action):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7215 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7216 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
7217 context menu.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7218
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7219 @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
7220 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7221 if action in self.spellingSuggActs:
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7222 replacement = action.text()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7223 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7224 wordStart, wordEnd = self.getWordBoundaries(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7225 self.setSelection(line, wordStart, line, wordEnd)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7226 self.beginUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7227 self.removeSelectedText()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7228 self.insert(replacement)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7229 self.endUndoAction()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7230
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7231 def __addToSpellingDictionary(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7232 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7233 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
7234 dictionary.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7235 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7236 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7237 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7238 self.spell.add(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7239
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7240 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
7241 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
7242 line, wordEnd)
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7243 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7244 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7245
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7246 def __removeFromSpellingDictionary(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7247 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7248 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
7249 dictionary.
92
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7250 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7251 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7252 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7253 self.spell.remove(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7254
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7255 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7256 self.spell.checkDocumentIncrementally()
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7257
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7258 def __ignoreSpellingAlways(self):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7259 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7260 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
7261 """
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7262 line, index = self.lineIndexFromPosition(self.spellingMenuPos)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7263 word = self.getWord(line, index)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7264 self.spell.ignoreAlways(word)
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7265 if Preferences.getEditor("AutoSpellCheckingEnabled"):
30ffedc3e418 Refined the flakes integration code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 88
diff changeset
7266 self.spell.checkDocumentIncrementally()
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7267
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7268 #######################################################################
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7269 ## Cooperation related methods
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7270 #######################################################################
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7271
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7272 def getSharingStatus(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7273 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7274 Public method to get some share status info.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7275
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7276 @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
7277 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
7278 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
7279 (boolean, boolean, boolean, boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7280 """
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
7281 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
7282 self.project.isOpen() and \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
7283 self.project.isProjectFile(self.fileName), \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
7284 self.__isShared, self.__inSharedEdit, self.__inRemoteSharedEdit
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7285
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7286 def shareConnected(self, connected):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7287 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7288 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
7289
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7290 @param connected flag indicating the connected state (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7291 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7292 if not connected:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7293 self.__inRemoteSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7294 self.setReadOnly(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7295 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
7296 self.cancelSharedEdit(send=False)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7297 self.__isSyncing = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7298 self.__receivedWhileSyncing = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7299
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7300 def shareEditor(self, share):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7301 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7302 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
7303
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7304 @param share flag indicating the share status (boolean)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7305 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7306 self.__isShared = share
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7307 if not share:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7308 self.shareConnected(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7309
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7310 def startSharedEdit(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7311 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7312 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
7313 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7314 self.__inSharedEdit = True
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7315 self.__savedText = self.text()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7316 hash = str(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7317 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
7318 Utilities.encode(self.__savedText, self.encoding)[0],
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7319 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
7320 encoding="utf-8")
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7321 self.__send(Editor.StartEditToken, hash)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7322
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7323 def sendSharedEdit(self):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7324 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7325 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
7326 send the changes.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7327 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7328 commands = self.__calculateChanges(self.__savedText, self.text())
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7329 self.__send(Editor.EndEditToken, commands)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7330 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7331 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7332
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
7333 def cancelSharedEdit(self, send=True):
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7334 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7335 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
7336
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7337 @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
7338 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7339 self.__inSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7340 self.__savedText = ""
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7341 if send:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7342 self.__send(Editor.CancelEditToken)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7343
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
7344 def __send(self, token, args=None):
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7345 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7346 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
7347
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7348 @param token command token (string)
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7349 @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
7350 """
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7351 if self.vm.isConnected():
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7352 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
7353 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
7354 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
7355 Editor.RequestSyncToken,
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7356 Editor.SyncToken):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7357 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
7358 token,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 939
diff changeset
7359 Editor.Separator,
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7360 args
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7361 )
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7362 elif token == Editor.CancelEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7363 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
7364 token,
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7365 Editor.Separator
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7366 )
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7367
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7368 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
7369
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7370 def receive(self, command):
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7371 """
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7372 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
7373
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7374 @param command command string (string)
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7375 """
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7376 if self.__isShared:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7377 if self.__isSyncing and \
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7378 not command.startswith(Editor.SyncToken + Editor.Separator):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7379 self.__receivedWhileSyncing.append(command)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7380 else:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7381 self.__dispatchCommand(command)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7382
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7383 def __dispatchCommand(self, command):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7384 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7385 Private method to dispatch received commands.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7386
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7387 @param command command to be processed (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7388 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7389 token, argsString = command.split(Editor.Separator, 1)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7390 if token == Editor.StartEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7391 self.__processStartEditCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7392 elif token == Editor.CancelEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7393 self.shareConnected(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7394 elif token == Editor.EndEditToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7395 self.__processEndEditCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7396 elif token == Editor.RequestSyncToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7397 self.__processRequestSyncCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7398 elif token == Editor.SyncToken:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7399 self.__processSyncCommand(argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7400
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7401 def __processStartEditCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7402 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
7403 Private slot to process a remote StartEdit command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7404
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7405 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7406 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7407 if not self.__inSharedEdit and not self.__inRemoteSharedEdit:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7408 self.__inRemoteSharedEdit = True
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7409 self.setReadOnly(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7410 self.__updateReadOnly()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7411 hash = str(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7412 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
7413 Utilities.encode(self.text(), self.encoding)[0],
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7414 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
7415 encoding="utf-8")
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7416 if hash != argsString:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7417 # 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
7418 self.__isSyncing = True
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7419 self.__send(Editor.RequestSyncToken, argsString)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7420
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7421 def __calculateChanges(self, old, new):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7422 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7423 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
7424 new text.
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7425
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7426 @param old old text (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7427 @param new new text (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7428 @return commands to change old into new (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7429 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7430 oldL = old.splitlines()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7431 newL = new.splitlines()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7432 matcher = difflib.SequenceMatcher(None, oldL, newL)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7433
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7434 formatStr = "@@{0} {1} {2} {3}"
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7435 commands = []
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7436 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
7437 if token == "insert":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7438 commands.append(formatStr.format("i", j1, j2 - j1, -1))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7439 commands.extend(newL[j1:j2])
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7440 elif token == "delete":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7441 commands.append(formatStr.format("d", j1, i2 - i1, -1))
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7442 elif token == "replace":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7443 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
7444 commands.extend(newL[j1:j2])
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7445
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7446 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
7447
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7448 def __processEndEditCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7449 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
7450 Private slot to process a remote EndEdit command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7451
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7452 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7453 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7454 commands = argsString.splitlines()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7455 sep = self.getLineSeparator()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7456 cur = self.getCursorPosition()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7457
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7458 self.setReadOnly(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7459 self.beginUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7460 while commands:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7461 commandLine = commands.pop(0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7462 if not commandLine.startswith("@@"):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7463 continue
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7464
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
7465 args = commandLine.split()
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
7466 command = args.pop(0)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7467 pos, l1, l2 = [int(arg) for arg in args]
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7468 if command == "@@i":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7469 txt = sep.join(commands[0:l1]) + sep
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7470 self.insertAt(txt, pos, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7471 del commands[0:l1]
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7472 elif command == "@@d":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7473 self.setSelection(pos, 0, pos + l1, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7474 self.removeSelectedText()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7475 elif command == "@@r":
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7476 self.setSelection(pos, 0, pos + l1, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7477 self.removeSelectedText()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7478 txt = sep.join(commands[0:l2]) + sep
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7479 self.insertAt(txt, pos, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7480 del commands[0:l2]
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7481 self.endUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7482 self.__updateReadOnly()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7483 self.__inRemoteSharedEdit = False
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7484
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7485 self.setCursorPosition(*cur)
155
375e3c884874 Added code to transmit selections to remote editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 128
diff changeset
7486
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7487 def __processRequestSyncCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7488 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
7489 Private slot to process a remote RequestSync command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7490
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7491 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7492 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7493 if self.__inSharedEdit:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7494 hash = str(
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7495 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
7496 Utilities.encode(self.__savedText, self.encoding)[0],
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7497 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
7498 encoding="utf-8")
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7499
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7500 if hash == argsString:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7501 self.__send(Editor.SyncToken, self.__savedText)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7502
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7503 def __processSyncCommand(self, argsString):
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7504 """
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2959
diff changeset
7505 Private slot to process a remote Sync command.
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7506
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7507 @param argsString string containing the command parameters (string)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7508 """
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7509 if self.__isSyncing:
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7510 cur = self.getCursorPosition()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7511
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7512 self.setReadOnly(False)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7513 self.beginUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7514 self.selectAll()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7515 self.removeSelectedText()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7516 self.insertAt(argsString, 0, 0)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7517 self.endUndoAction()
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7518 self.setReadOnly(True)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7519
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7520 self.setCursorPosition(*cur)
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7521
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7522 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
7523 command = self.__receivedWhileSyncing.pop(0)
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 825
diff changeset
7524 self.__dispatchCommand(command)
158
6a561f87bc07 Added shared editor functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
7525
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
7526 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
7527
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
7528 #######################################################################
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
7529 ## 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
7530 #######################################################################
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
7531
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
7532 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
7533 """
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
7534 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
7535 """
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
7536 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
7537
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
7538 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
7539 """
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
7540 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
7541 """
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
7542 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
7543
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
7544 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
7545 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3583
diff changeset
7546 Private slot to search the next occurrence of the current word.
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
7547
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
7548 @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
7549 """
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3067
diff changeset
7550 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
7551 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
7552 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
7553 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
7554 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
7555 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
7556
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
7557 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
7558 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
7559 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
7560 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
7561 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
7562
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
7563 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
7564 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
7565 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
7566 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
7567 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
7568 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
7569 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
7570 # 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
7571 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
7572 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
7573 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
7574 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
7575 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
7576 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
7577 # 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
7578 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
7579 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
7580 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
7581 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
7582 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
7583
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
7584 #######################################################################
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
7585 ## 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
7586 #######################################################################
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
7587
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
7588 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
7589 """
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
7590 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
7591 """
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7592 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
7593 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
7594
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
7595 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
7596 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
7597 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
7598 ascending, alnum, caseSensitive = dlg.getData()
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7599 origStartLine, origStartIndex, origEndLine, origEndIndex = \
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7600 self.getRectangularSelection()
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7601 # convert to upper-left to lower-right
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7602 startLine = min(origStartLine, origEndLine)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7603 startIndex = min(origStartIndex, origEndIndex)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7604 endLine = max(origStartLine, origEndLine)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7605 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
7606
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7607 # 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
7608 # 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
7609 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
7610 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
7611 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
7612 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
7613 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
7614 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
7615 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
7616 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
7617 except ValueError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
7618 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
7619 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
7620 self.tr("Sort Lines"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3169
diff changeset
7621 self.tr(
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2994
diff changeset
7622 """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
7623 """ 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
7624 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
7625
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
7626 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
7627 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
7628 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
7629 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
7630
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
7631 # 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
7632 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
7633 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
7634 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
7635 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
7636 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
7637
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
7638 # step 3: sort the lines
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7639 eol = self.getLineSeparator()
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7640 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
7641 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
7642 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
7643 for line in selText[txt]:
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7644 txt = txtLines[line]
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7645 if not txt.endswith(eol):
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7646 lastWithEol = False
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7647 txt += eol
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7648 newLines.append(txt)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7649 if not lastWithEol:
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7650 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
7651
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
7652 # 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
7653 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
7654 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
7655 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
7656 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
7657
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
7658 # step 5: reset the rectangular selection
2590
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7659 self.setRectangularSelection(origStartLine, origStartIndex,
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7660 origEndLine, origEndIndex)
abe9b3e04381 Finished the sort implementation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2589
diff changeset
7661 self.selectionChanged.emit()
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7662
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7663 #######################################################################
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7664 ## Mouse click handler related methods
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7665 #######################################################################
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7666
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7667 def mouseReleaseEvent(self, evt):
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7668 """
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7669 Protected method calling a registered mouse click handler function.
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7670
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7671 @param evt event object
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7672 @type QMouseEvent
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7673 """
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7674 modifiers = evt.modifiers()
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7675 button = evt.button()
4292
9dfee1559826 Fixed an issue in the mouse click handler of the editor. Needed to cast the modifiers and mouse button to an integer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4290
diff changeset
7676 key = (int(modifiers), int(button))
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7677
4297
8ece10107224 Corrected the mouse release event handler of the editor to call the super class one first.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4292
diff changeset
7678 self.vm.eventFilter(self, evt)
8ece10107224 Corrected the mouse release event handler of the editor to call the super class one first.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4292
diff changeset
7679 super(Editor, self).mouseReleaseEvent(evt)
8ece10107224 Corrected the mouse release event handler of the editor to call the super class one first.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4292
diff changeset
7680
4288
1c9c1c12111a Added a configuration page for mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4287
diff changeset
7681 if button != Qt.NoButton and \
1c9c1c12111a Added a configuration page for mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4287
diff changeset
7682 Preferences.getEditor("MouseClickHandlersEnabled") and \
1c9c1c12111a Added a configuration page for mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4287
diff changeset
7683 key in self.__mouseClickHandlers:
4297
8ece10107224 Corrected the mouse release event handler of the editor to call the super class one first.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4292
diff changeset
7684 evt.accept()
4302
748f4945462b Changed the call to mouse click handlers in the editor to pass the calling editor as a parameter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4299
diff changeset
7685 self.__mouseClickHandlers[key][1](self)
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7686
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7687 def setMouseClickHandler(self, name, modifiers, button, function):
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7688 """
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7689 Public method to set a mouse click handler.
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7690
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7691 @param name name of the plug-in (or 'internal') setting this handler
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7692 @type str
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7693 @param modifiers keyboard modifiers of the handler
4299
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7694 @type Qt.KeyboardModifiers or int
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7695 @param button mouse button of the handler
4299
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7696 @type Qt.MouseButton or int
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7697 @param function handler function
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7698 @type func
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7699 @return flag indicating success
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7700 @rtype bool
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7701 """
4299
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7702 if int(button):
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7703 key = (int(modifiers), int(button))
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7704 if key in self.__mouseClickHandlers:
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7705 E5MessageBox.warning(
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7706 self,
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7707 self.tr("Register Mouse Click Handler"),
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7708 self.tr("""A mouse click handler for "{0}" was already"""
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7709 """ registered by "{1}". Aborting request by"""
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7710 """ "{2}"...""").format(
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7711 MouseUtilities.MouseButtonModifier2String(
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7712 modifiers, button),
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7713 self.__mouseClickHandlers[key][0],
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7714 name))
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7715 return False
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7716
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7717 self.__mouseClickHandlers[key] = (name, function)
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7718 return True
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7719
93219cb8f66b Small ammendment to the mouse click handler functions of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4297
diff changeset
7720 return False
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7721
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7722 def getMouseClickHandler(self, modifiers, button):
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7723 """
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7724 Public method to get a registered mouse click handler.
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7725
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7726 @param modifiers keyboard modifiers of the handler
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7727 @type Qt.KeyboardModifiers
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7728 @param button mouse button of the handler
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7729 @type Qt.MouseButton
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7730 @return plug-in name and registered function
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7731 @rtype tuple of str and func
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7732 """
4292
9dfee1559826 Fixed an issue in the mouse click handler of the editor. Needed to cast the modifiers and mouse button to an integer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4290
diff changeset
7733 key = (int(modifiers), int(button))
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7734 if key in self.__mouseClickHandlers:
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7735 return self.__mouseClickHandlers[key]
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7736 else:
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7737 return ("", None)
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7738
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7739 def getMouseClickHandlers(self, name):
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7740 """
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7741 Public method to get all registered mouse click handlers of
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7742 a plug-in.
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7743
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7744 @param name name of the plug-in
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7745 @type str
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7746 @return registered mouse click handlers as list of modifiers,
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7747 mouse button and function
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7748 @rtype list of tuple of (Qt.KeyboardModifiers, Qt.MouseButton,func)
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7749 """
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7750 lst = []
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7751 for key, value in self.__mouseClickHandlers.items():
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7752 if value[0] == name:
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7753 lst.append((key[0], key[1], value[1]))
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7754 return lst
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7755
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7756 def removeMouseClickHandler(self, modifiers, button):
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7757 """
4287
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7758 Public method to un-registered a mouse click handler.
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7759
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7760 @param modifiers keyboard modifiers of the handler
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7761 @type Qt.KeyboardModifiers
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7762 @param button mouse button of the handler
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7763 @type Qt.MouseButton
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7764 """
4292
9dfee1559826 Fixed an issue in the mouse click handler of the editor. Needed to cast the modifiers and mouse button to an integer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4290
diff changeset
7765 key = (int(modifiers), int(button))
4287
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7766 if key in self.__mouseClickHandlers:
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7767 del self.__mouseClickHandlers[key]
4286
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7768
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7769 def removeMouseClickHandlers(self, name):
255f56eb7f05 Started implementing support for mouse click handlers into the Editor. This can be used by plug-ins to implement function executed by a mouse click (e.g. goto definition upon Ctrl+Left Button).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4283
diff changeset
7770 """
4287
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7771 Public method to un-registered all mouse click handlers of
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7772 a plug-in.
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7773
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7774 @param name name of the plug-in
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7775 @type str
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7776 """
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7777 keys = []
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7778 for key in self.__mouseClickHandlers:
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7779 if self.__mouseClickHandlers[key][0] == name:
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7780 keys.append(key)
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7781 for key in keys:
12274edd3050 Completed the mouse click handler support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4286
diff changeset
7782 del self.__mouseClickHandlers[key]

eric ide

mercurial