eric6/QScintilla/EditorMarkerMap.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a class for showing an editor marker map.
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3341
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
10 from E5Gui.E5MapWidget import E5MapWidget
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
3341
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
12 import Preferences
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 class EditorMarkerMap(E5MapWidget):
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 Class implementing a class for showing an editor marker map.
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 def __init__(self, parent=None):
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Constructor
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 @param parent reference to the parent widget (QWidget)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3341
diff changeset
25 super(EditorMarkerMap, self).__init__(parent)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
3913
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
27 self.setWhatsThis(self.tr(
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
28 """<b>Editor Map</b>"""
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
29 """<p>This shows a 'map' of the editor. The visible area is"""
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
30 """ highlighted by the box and all markers like bookmarks,"""
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
31 """ breakpoints, errors or changed lines are indicated"""
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
32 """ by differently colored lines configurable via the"""
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
33 """ Editor\u279dStyle page of the configuration dialog.</p>"""
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
34 ))
9d13be0ff3d2 Added a "What's This" help to the marker map widget of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
35
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 # initialize colors for various markers
3341
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
37 self.initColors()
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
38
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
39 def initColors(self):
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
40 """
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
41 Public method to initialize the colors.
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
42 """
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
43 self.setBackgroundColor(
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
44 Preferences.getEditorColour("MarkerMapBackground"))
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
45
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
46 self.__bookmarkColor = Preferences.getEditorColour("BookmarksMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
47 self.__errorColor = Preferences.getEditorColour("ErrorsMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
48 self.__warningColor = Preferences.getEditorColour("WarningsMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
49 self.__breakpointColor = Preferences.getEditorColour("BreakpointsMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
50 self.__taskColor = Preferences.getEditorColour("TasksMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
51 self.__coverageColor = Preferences.getEditorColour("CoverageMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
52 self.__changeColor = Preferences.getEditorColour("ChangesMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
53 self.__currentLineMarker = Preferences.getEditorColour("CurrentMap")
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
54 self.__searchMarkerColor = Preferences.getEditorColour(
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
55 "SearchMarkersMap")
6111
d38b38117d83 Added VCS conflict markers to the types shown on the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
56 self.__vcsConflictMarkerColor = Preferences.getEditorColour(
d38b38117d83 Added VCS conflict markers to the types shown on the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 "VcsConflictMarkersMap")
3341
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
58 self.update()
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def __drawIndicator(self, line, painter, color):
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Private method to draw an indicator.
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @param line line number (integer)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @param painter reference to the painter (QPainter)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param color color to be used (QColor)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
6031
ccab25598d90 Fixed an issue drawing the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
68 displayLine = self._master.getVisibleLineFromDocLine(line)
ccab25598d90 Fixed an issue drawing the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
69 position = self.value2Position(displayLine)
3339
d0a603f1bfcd Added support for wheel events and mouse move events to the map widget and made some adjustments to the representation (colors).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3329
diff changeset
70 painter.setPen(color)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 painter.setBrush(color)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 painter.drawRect(self.generateIndicatorRect(position))
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def _paintIt(self, painter):
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Protected method for painting the widget's indicators.
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @param painter reference to the painter object (QPainter)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 # draw indicators in reverse order of priority
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 # 1. changes
6648
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
83 if Preferences.getEditor("ShowMarkerChanges"):
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
84 for line in self._master.getChangeLines():
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
85 self.__drawIndicator(line, painter, self.__changeColor)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 # 2. coverage
6648
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
88 if Preferences.getEditor("ShowMarkerCoverage"):
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
89 for line in self._master.getCoverageLines():
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
90 self.__drawIndicator(line, painter, self.__coverageColor)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 # 3. tasks
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 for line in self._master.getTaskLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__drawIndicator(line, painter, self.__taskColor)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 # 4. breakpoints
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 for line in self._master.getBreakpointLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__drawIndicator(line, painter, self.__breakpointColor)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 # 5. bookmarks
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 for line in self._master.getBookmarkLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__drawIndicator(line, painter, self.__bookmarkColor)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
104 # 6. search markers
6648
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
105 if Preferences.getEditor("ShowMarkerSearch"):
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
106 for line in self._master.getSearchIndicatorLines():
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
107 self.__drawIndicator(line, painter, self.__searchMarkerColor)
4304
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
108
f85965649066 Added the search markers to the marker map of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
109 # 7. warnings
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 for line in self._master.getWarningLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__drawIndicator(line, painter, self.__warningColor)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
6648
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
113 # 8. VCS conflict markers
6111
d38b38117d83 Added VCS conflict markers to the types shown on the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
114 for line in self._master.getVcsConflictMarkerLines():
d38b38117d83 Added VCS conflict markers to the types shown on the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
115 self.__drawIndicator(line, painter, self.__vcsConflictMarkerColor)
d38b38117d83 Added VCS conflict markers to the types shown on the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
116
6648
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
117 # 9. errors
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 for line in self._master.getSyntaxErrorLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__drawIndicator(line, painter, self.__errorColor)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
6648
c09e6c6006eb EditorMarkerMap: added cpability to suppress some markers in the marker map.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
121 # 10. current line
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.__drawIndicator(self._master.getCursorPosition()[0], painter,
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__currentLineMarker)

eric ide

mercurial