QScintilla/EditorMarkerMap.py

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

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 15:02:45 +0200
changeset 3682
2543741b47b7
parent 3484
645c12de6b0c
child 3913
9d13be0ff3d2
permissions
-rw-r--r--

Changed a few files to reference eric6.

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
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de>
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
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3341
diff changeset
10 from __future__ import unicode_literals
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3341
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 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
13
3341
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
14 import Preferences
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
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 EditorMarkerMap(E5MapWidget):
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 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
20 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 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
22 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @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
26 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3341
diff changeset
27 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
28
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 # 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
30 self.initColors()
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
31
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
32 def initColors(self):
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
33 """
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
34 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
35 """
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
36 self.setBackgroundColor(
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
37 Preferences.getEditorColour("MarkerMapBackground"))
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 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
40 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
41 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
42 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
43 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
44 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
45 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
46 self.__currentLineMarker = Preferences.getEditorColour("CurrentMap")
7c015811fc4d Finished implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3339
diff changeset
47 self.update()
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 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
50 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 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
52
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @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
54 @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
55 @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
56 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 position = self.value2Position(line)
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
58 painter.setPen(color)
3329
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 painter.setBrush(color)
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 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
61
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def _paintIt(self, painter):
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 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
65
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @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
67 """
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 # 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
69
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 # 1. changes
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 for line in self._master.getChangeLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__drawIndicator(line, painter, self.__changeColor)
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 # 2. coverage
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 for line in self._master.getCoverageLines():
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__drawIndicator(line, painter, self.__coverageColor)
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 # 3. tasks
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 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
80 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
81
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 # 4. breakpoints
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 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
84 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
85
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 # 5. bookmarks
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 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
88 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
89
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 # 6. warnings
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 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
92 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
93
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 # 7. errors
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 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
96 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
97
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 # 8. current line
1ee38e29ed4f Continued implementing support for a marker map in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 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
100 self.__currentLineMarker)

eric ide

mercurial