Differential D4136 Diff 10170 plugins/extensions/pykrita/plugin/plugins/scripter/ui_scripter/editor/pythoneditor.py
Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/scripter/ui_scripter/editor/pythoneditor.py
Show All 10 Lines | 7 | class CodeEditor(QPlainTextEdit): | |||
---|---|---|---|---|---|
11 | def __init__(self, scripter, parent=None): | 11 | def __init__(self, scripter, parent=None): | ||
12 | super(CodeEditor, self).__init__(parent) | 12 | super(CodeEditor, self).__init__(parent) | ||
13 | 13 | | |||
14 | self.setLineWrapMode(self.NoWrap) | 14 | self.setLineWrapMode(self.NoWrap) | ||
15 | 15 | | |||
16 | self.scripter = scripter | 16 | self.scripter = scripter | ||
17 | self.lineNumberArea = linenumberarea.LineNumberArea(self) | 17 | self.lineNumberArea = linenumberarea.LineNumberArea(self) | ||
18 | self.debugArea = debugarea.DebugArea(self) | 18 | self.debugArea = debugarea.DebugArea(self) | ||
19 | self.debugIcon = QIcon('/home/eliakincosta/Pictures/debug_arrow.svg') | | |||
20 | 19 | | |||
21 | self.blockCountChanged.connect(self.updateMarginsWidth) | 20 | self.blockCountChanged.connect(self.updateMarginsWidth) | ||
22 | self.updateRequest.connect(self.updateLineNumberArea) | 21 | self.updateRequest.connect(self.updateLineNumberArea) | ||
23 | self.cursorPositionChanged.connect(self.highlightCurrentLine) | 22 | self.cursorPositionChanged.connect(self.highlightCurrentLine) | ||
24 | 23 | | |||
25 | self.updateMarginsWidth() | 24 | self.updateMarginsWidth() | ||
26 | self.highlightCurrentLine() | 25 | self.highlightCurrentLine() | ||
27 | self.font = "Monospace" | 26 | self.font = "Monospace" | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 99 | if self._stepped: | |||
101 | cursor = QTextCursor(block) | 100 | cursor = QTextCursor(block) | ||
102 | self.setTextCursor(cursor) | 101 | self.setTextCursor(cursor) | ||
103 | self._stepped = False | 102 | self._stepped = False | ||
104 | 103 | | |||
105 | top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top()) | 104 | top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top()) | ||
106 | bottom = top + int(self.blockBoundingRect(block).height()) | 105 | bottom = top + int(self.blockBoundingRect(block).height()) | ||
107 | 106 | | |||
108 | painter = QPainter(self.debugArea) | 107 | painter = QPainter(self.debugArea) | ||
109 | pixmap = self.debugIcon.pixmap(QSize(self.debugAreaWidth()-3, int(self.blockBoundingRect(block).height()))) | 108 | painter.fillRect(0, top, self.debugAreaWidth()-3, int(self.blockBoundingRect(block).height()), QColor(Qt.yellow).darker(300)) | ||
110 | painter.drawPixmap(QPoint(0, top), pixmap) | | |||
111 | 109 | | |||
112 | def highlightCurrentLine(self): | 110 | def highlightCurrentLine(self): | ||
113 | """Highlight current line under cursor""" | 111 | """Highlight current line under cursor""" | ||
114 | currentSelection = QTextEdit.ExtraSelection() | 112 | currentSelection = QTextEdit.ExtraSelection() | ||
115 | 113 | | |||
116 | lineColor = QColor(Qt.gray).darker(250) | 114 | lineColor = QColor(Qt.gray).darker(250) | ||
117 | currentSelection.format.setBackground(lineColor) | 115 | currentSelection.format.setBackground(lineColor) | ||
118 | currentSelection.format.setProperty(QTextFormat.FullWidthSelection, True) | 116 | currentSelection.format.setProperty(QTextFormat.FullWidthSelection, True) | ||
Show All 31 Lines |