Krita Source Code Documentation
Loading...
Searching...
No Matches
scripter.ui_scripter.editor.pythoneditor.CodeEditor Class Reference
+ Inheritance diagram for scripter.ui_scripter.editor.pythoneditor.CodeEditor:

Public Member Functions

 __init__ (self, scripter, parent=None)
 
 autoindent (self)
 
 debugAreaPaintEvent (self, event)
 
 debugAreaWidth (self)
 
 dedent (self)
 
 dedentBlock (self, blockNumber)
 
 font (self)
 
 font (self, font="Monospace")
 
 highlightCurrentLine (self)
 
 indent (self)
 
 isEmptyBlock (self, blockNumber)
 
 keyPressEvent (self, e)
 
 lineNumberAreaPaintEvent (self, event)
 
 lineNumberAreaWidth (self)
 
 repaintDebugArea (self)
 
 resizeEvent (self, event)
 
 setDocumentModified (self, changed=False)
 
 setFontSize (self, size=10)
 
 setStepped (self, status)
 
 toggleComment (self)
 
 updateLineNumberArea (self, rect, dy)
 
 updateMarginsWidth (self)
 
 wheelEvent (self, e)
 

Public Attributes

 debugArea
 
 debugArrow
 
 font
 
 highlightCurrentLine
 
 indent_width
 
 lineNumberArea
 
 scripter
 
 setDocumentModified
 
 updateLineNumberArea
 
 updateMarginsWidth
 

Static Public Attributes

int DEBUG_AREA_WIDTH = 20
 

Protected Attributes

 _documentChanged
 
 _documentModified
 
 _font
 
 _stepped
 

Detailed Description

Definition at line 37 of file pythoneditor.py.

Constructor & Destructor Documentation

◆ __init__()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.__init__ ( self,
scripter,
parent = None )

Definition at line 41 of file pythoneditor.py.

41 def __init__(self, scripter, parent=None):
42 super(CodeEditor, self).__init__(parent)
43
44 self.setLineWrapMode(QPlainTextEdit.LineWrapMode.NoWrap)
45
46 self.scripter = scripter
47 self.lineNumberArea = linenumberarea.LineNumberArea(self)
48 self.debugArea = debugarea.DebugArea(self)
49
50 self.blockCountChanged.connect(self.updateMarginsWidth)
51 self.updateRequest.connect(self.updateLineNumberArea)
52 self.cursorPositionChanged.connect(self.highlightCurrentLine)
53
54 self.updateMarginsWidth()
55 self.highlightCurrentLine()
56 self.font = "Monospace"
57 self._stepped = False
58 self.debugArrow = QIcon(':/icons/debug_arrow.svg')
59 self.setCornerWidget(QLabel(str()))
60 self._documentChanged = False
61 self.indent_width = INDENT_WIDTH # maybe one day connect this to a setting
62
63 self.undoAvailable.connect(self.setDocumentModified)
64
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))

References scripter.ui_scripter.editor.pythoneditor.CodeEditor.__init__(), KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, and xcfLayer.dim.

Member Function Documentation

◆ autoindent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.autoindent ( self)
The return key has just been pressed (and processed by the editor)
now insert leading spaces to reflect an appropriate indent level
against the previous line.
This will depend on the end of the previous line. If it ends:
* with a colon (:) then indent to a new indent level
* with a comma (,) then this is an implied continuation line, probably
  in the middle of a function's parameter list
  - look for last open bracket on previous line (, [ or {
    - if found indent to that level + one character,
    - otherwise use previous line whitespace, this is probably a list or
      parameter list so line up with other elements
* with a backslash (\‍) then this is a continuation line, probably
  on the RHS of an assignment
  - similar rules as for comma, but if there is an = character
    use that plus one indent level if that is greater
* if it is an open bracket of some sort treat similarly to comma


* anything else - a new line at the same indent level. This will preserve
  the indent level of whitespace lines. User can shift-tab to dedent
  as necessary

Definition at line 278 of file pythoneditor.py.

278 def autoindent(self):
279 r"""The return key has just been pressed (and processed by the editor)
280 now insert leading spaces to reflect an appropriate indent level
281 against the previous line.
282 This will depend on the end of the previous line. If it ends:
283 * with a colon (:) then indent to a new indent level
284 * with a comma (,) then this is an implied continuation line, probably
285 in the middle of a function's parameter list
286 - look for last open bracket on previous line (, [ or {
287 - if found indent to that level + one character,
288 - otherwise use previous line whitespace, this is probably a list or
289 parameter list so line up with other elements
290 * with a backslash (\‍) then this is a continuation line, probably
291 on the RHS of an assignment
292 - similar rules as for comma, but if there is an = character
293 use that plus one indent level if that is greater
294 * if it is an open bracket of some sort treat similarly to comma
295
296
297 * anything else - a new line at the same indent level. This will preserve
298 the indent level of whitespace lines. User can shift-tab to dedent
299 as necessary
300 """
301
302 cursor = self.textCursor()
303 block = cursor.block()
304 block = block.previous()
305 text = block.text()
306 indentLevel = len(text) - len(text.lstrip()) # base indent level
307
308 # get last char
309 try:
310 lastChar = text.rstrip()[-1]
311 except IndexError:
312 lastChar = None
313
314 # work out indent level
315 if lastChar == CHAR_COLON:
316 indentLevel = indentLevel + self.indent_width
317 elif lastChar == CHAR_COMMA: # technically these are mutually exclusive so if would work
318 braceLevels = []
319 for c in [CHAR_OPEN_BRACE, CHAR_OPEN_BRACKET, CHAR_OPEN_SQUARE_BRACKET]:
320 braceLevels.append(text.rfind(c))
321 bracePosition = max(braceLevels)
322 if bracePosition > 0:
323 indentLevel = bracePosition + 1
324 elif lastChar == CHAR_CONTINUATION:
325 braceLevels = []
326 for c in [CHAR_OPEN_BRACE, CHAR_OPEN_BRACKET, CHAR_OPEN_SQUARE_BRACKET]:
327 braceLevels.append(text.rfind(c))
328 bracePosition = max(braceLevels)
329 equalPosition = text.rfind(CHAR_EQUALS)
330 if bracePosition > equalPosition:
331 indentLevel = bracePosition + 1
332 if equalPosition > bracePosition:
333 indentLevel = equalPosition + self.indent_width
334 # otherwise they're the same - ie both -1 so use base indent level
335 elif lastChar in [CHAR_OPEN_BRACE, CHAR_OPEN_BRACKET, CHAR_OPEN_SQUARE_BRACKET]:
336 indentLevel = len(text.rstrip())
337
338 # indent
339 cursor.insertText(CHAR_SPACE * indentLevel)
340

◆ debugAreaPaintEvent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugAreaPaintEvent ( self,
event )

Definition at line 138 of file pythoneditor.py.

138 def debugAreaPaintEvent(self, event):
139 if self.scripter.debugcontroller.isActive and self.scripter.debugcontroller.currentLine:
140 lineNumber = self.scripter.debugcontroller.currentLine
141 block = self.document().findBlockByLineNumber(lineNumber - 1)
142
143 if self._stepped:
144 cursor = QTextCursor(block)
145 self.setTextCursor(cursor)
146 self._stepped = False
147
148 top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top())
149
150 painter = QPainter(self.debugArea)
151 pixmap = self.debugArrow.pixmap(QSize(self.debugAreaWidth() - 3, int(self.blockBoundingRect(block).height())))
152 painter.drawPixmap(QPoint(0, top), pixmap)
153

References scripter.ui_scripter.editor.pythoneditor.CodeEditor._stepped, scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugArea, scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugAreaWidth(), scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugArrow, KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, KoTextShapeDataBase.document(), KoShapeAnchor::TextLocation.document(), KoTextShapeDataBasePrivate.document, krita::Document::Private.document, Document.document(), View.document(), KisAslXmlWriter::Private.document, KisAslXmlWriter.document(), KisAnimationImporter::Private.document, KisCloneDocumentStroke.document, KisDecorationsWrapperLayer::Private.document, KisDecorationsWrapperLayer.document(), KisView.document, KisView.document(), KisViewManager.document(), KoItemToolTip.document, KisTimeBasedItemModel::Private.document, KisTimeBasedItemModel.document(), krita.sceditor.highlighter.PythonHighlighter.document, KisKraLoader::Private.document, scripter.ui_scripter.syntax.syntax.PythonHighlighter.document, ToolReferenceImages.document(), scripter.debugcontroller.DebugController.scripter, scripter.debugger_scripter.debugger.Debugger.scripter, scripter.ui_scripter.actions.closeaction.closeaction.CloseAction.scripter, scripter.ui_scripter.actions.debugaction.debugaction.DebugAction.scripter, scripter.ui_scripter.actions.newaction.newaction.NewAction.scripter, scripter.ui_scripter.actions.openaction.openaction.OpenAction.scripter, scripter.ui_scripter.actions.reloadaction.reloadaction.ReloadAction.scripter, scripter.ui_scripter.actions.runaction.runaction.RunAction.scripter, scripter.ui_scripter.actions.saveaction.saveaction.SaveAction.scripter, scripter.ui_scripter.actions.saveasaction.saveasaction.SaveAsAction.scripter, scripter.ui_scripter.actions.settingsaction.settingsaction.SettingsAction.scripter, scripter.ui_scripter.actions.settingsaction.settingsdialog.SettingsDialog.scripter, scripter.ui_scripter.editor.pythoneditor.CodeEditor.scripter, scripter.ui_scripter.tabwidgets.debuggerwidget.debuggerwidget.DebuggerWidget.scripter, scripter.ui_scripter.tabwidgets.debuggerwidget.stepaction.StepAction.scripter, scripter.ui_scripter.tabwidgets.debuggerwidget.stopaction.StopAction.scripter, scripter.ui_scripter.tabwidgets.outputwidget.clearaction.ClearAction.scripter, scripter.ui_scripter.tabwidgets.outputwidget.outputwidget.OutPutWidget.scripter, and scripter.uicontroller.UIController.scripter.

◆ debugAreaWidth()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugAreaWidth ( self)

Definition at line 65 of file pythoneditor.py.

65 def debugAreaWidth(self):
66 return self.DEBUG_AREA_WIDTH
67

References scripter.ui_scripter.editor.pythoneditor.CodeEditor.DEBUG_AREA_WIDTH.

◆ dedent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.dedent ( self)

Definition at line 262 of file pythoneditor.py.

262 def dedent(self):
263 cursor = self.textCursor()
264 selectionStart = cursor.selectionStart()
265 selectionEnd = cursor.selectionEnd()
266
267 cursor.setPosition(selectionStart)
268 startBlock = cursor.blockNumber()
269 cursor.setPosition(selectionEnd)
270 endBlock = cursor.blockNumber()
271
272 if endBlock < startBlock:
273 startBlock, endBlock = endBlock, startBlock
274
275 for blockNumber in range(startBlock, endBlock + 1):
276 self.dedentBlock(blockNumber)
277

◆ dedentBlock()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.dedentBlock ( self,
blockNumber )

Definition at line 246 of file pythoneditor.py.

246 def dedentBlock(self, blockNumber):
247 # dedent the line at blockNumber
248 cursor = self.textCursor()
249 cursor.movePosition(QTextCursor.MoveOperation.Start)
250 cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=blockNumber)
251
252 for _ in range(self.indent_width):
253 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
254 cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.ModeMode.KeepAnchor)
255 if cursor.selectedText() == " ": # need to test each char
256 cursor.removeSelectedText()
257 else:
258 break # stop deleting!
259
260 return
261

◆ font() [1/2]

scripter.ui_scripter.editor.pythoneditor.CodeEditor.font ( self)

Definition at line 386 of file pythoneditor.py.

386 def font(self):
387 return self._font
388

◆ font() [2/2]

scripter.ui_scripter.editor.pythoneditor.CodeEditor.font ( self,
font = "Monospace" )

Definition at line 390 of file pythoneditor.py.

390 def font(self, font="Monospace"):
391 self._font = font
392 self.setFont(QFont(font, self.fontInfo().pointSize()))
393

◆ highlightCurrentLine()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.highlightCurrentLine ( self)
Highlight current line under cursor

Definition at line 154 of file pythoneditor.py.

154 def highlightCurrentLine(self):
155 """Highlight current line under cursor"""
156 currentSelection = QTextEdit.ExtraSelection()
157
158 lineColor = QColor(self.palette().base().color()).darker(120)
159 if (self.palette().base().color().lightness() < 128):
160 lineColor = QColor(self.palette().base().color()).lighter(120)
161 if (self.palette().base().color().lightness() < 1):
162 lineColor = QColor(43, 43, 43)
163
164 currentSelection.format.setBackground(lineColor)
165 currentSelection.format.setProperty(QTextFormat.Property.FullWidthSelection, True)
166 currentSelection.cursor = self.textCursor()
167 currentSelection.cursor.clearSelection()
168
169 self.setExtraSelections([currentSelection])
170

◆ indent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.indent ( self)

Definition at line 213 of file pythoneditor.py.

213 def indent(self):
214 # tab key has been pressed. Indent current line or selected block by self.indent_width
215
216 cursor = self.textCursor()
217 # is there a selection?
218
219 selectionStart = cursor.selectionStart()
220 selectionEnd = cursor.selectionEnd()
221
222 if selectionStart == selectionEnd and cursor.atBlockEnd():
223 # ie no selection and don't insert in the middle of text
224 # something smarter might skip whitespace and add a tab in front of
225 # the next non whitespace character
226 cursor.insertText(" " * self.indent_width)
227 return
228
229 cursor.setPosition(selectionStart)
230 startBlock = cursor.blockNumber()
231 cursor.setPosition(selectionEnd)
232 endBlock = cursor.blockNumber()
233
234 cursor.movePosition(QTextCursor.MoveOperation.Start)
235 cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=startBlock)
236
237 for i in range(0, endBlock - startBlock + 1):
238 if not self.isEmptyBlock(startBlock + i): # Don't insert whitespace on empty lines
239 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
240 cursor.insertText(" " * self.indent_width)
241
242 cursor.movePosition(QTextCursor.MoveOperation.NextBlock)
243
244 # QT maintains separate cursors, so don't need to track or reset user's cursor
245

◆ isEmptyBlock()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.isEmptyBlock ( self,
blockNumber )
 test whether block with number blockNumber contains any non-whitespace
If only whitespace: return true, else return false

Definition at line 197 of file pythoneditor.py.

197 def isEmptyBlock(self, blockNumber):
198 """ test whether block with number blockNumber contains any non-whitespace
199 If only whitespace: return true, else return false"""
200
201 # get block text
202 cursor = self.textCursor()
203 cursor.movePosition(QTextCursor.MoveOperation.Start)
204 cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=blockNumber)
205 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
206 cursor.movePosition(QTextCursor.MoveOperation.EndOfLine, QTextCursor.MoveMode.KeepAnchor)
207 text = cursor.selectedText()
208 if text.strip() == "":
209 return True
210 else:
211 return False
212

◆ keyPressEvent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.keyPressEvent ( self,
e )

Definition at line 183 of file pythoneditor.py.

183 def keyPressEvent(self, e):
184 modifiers = e.modifiers()
185 if (e.key() == Qt.Key.Key_Tab):
186 self.indent()
187 elif e.key() == Qt.Key.Key_Backtab:
188 self.dedent()
189 elif modifiers == MODIFIER_COMMENT and e.key() == KEY_COMMENT:
190 self.toggleComment()
191 elif e.key() == Qt.Key.Key_Return:
192 super(CodeEditor, self).keyPressEvent(e)
193 self.autoindent()
194 else:
195 super(CodeEditor, self).keyPressEvent(e)
196

◆ lineNumberAreaPaintEvent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberAreaPaintEvent ( self,
event )
This method draws the current lineNumberArea for while

Definition at line 112 of file pythoneditor.py.

112 def lineNumberAreaPaintEvent(self, event):
113 """This method draws the current lineNumberArea for while"""
114 blockColor = QColor(self.palette().base().color()).darker(120)
115 if (self.palette().base().color().lightness() < 128):
116 blockColor = QColor(self.palette().base().color()).lighter(120)
117 if (self.palette().base().color().lightness() < 1):
118 blockColor = QColor(43, 43, 43)
119 painter = QPainter(self.lineNumberArea)
120 painter.fillRect(event.rect(), blockColor)
121
122 block = self.firstVisibleBlock()
123 blockNumber = block.blockNumber()
124 top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top())
125 bottom = top + int(self.blockBoundingRect(block).height())
126 while block.isValid() and top <= event.rect().bottom():
127 if block.isVisible() and bottom >= event.rect().top():
128 number = str(blockNumber + 1)
129 painter.setPen(self.palette().text().color())
130 painter.drawText(0, top, self.lineNumberArea.width() - 3, self.fontMetrics().height(),
131 Qt.AlignmentFlag.AlignRight, number)
132
133 block = block.next()
134 top = bottom
135 bottom = top + int(self.blockBoundingRect(block).height())
136 blockNumber += 1
137

References KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, KoFontRegistry.fontMetrics(), scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberArea, krita::Palette::Private.palette, KisDlgPaletteEditor.palette(), DlgLayerSplit.palette(), KisFilterPalettizeConfiguration.palette(), KisFilterPalettizeConfiguration.palette(), and palette_docker.palette_sortColors.sortColors.palette().

◆ lineNumberAreaWidth()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberAreaWidth ( self)
The lineNumberAreaWidth is the quatity of decimal places in blockCount

Definition at line 68 of file pythoneditor.py.

68 def lineNumberAreaWidth(self):
69 """The lineNumberAreaWidth is the quatity of decimal places in blockCount"""
70 digits = 1
71 max_ = max(1, self.blockCount())
72 while (max_ >= 10):
73 max_ /= 10
74 digits += 1
75
76 space = 3 + self.fontMetrics().horizontalAdvance('9') * digits + 3
77
78 return space
79

References KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, and KoFontRegistry.fontMetrics().

◆ repaintDebugArea()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.repaintDebugArea ( self)

Definition at line 400 of file pythoneditor.py.

400 def repaintDebugArea(self):
401 self.debugArea.repaint()
402

◆ resizeEvent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.resizeEvent ( self,
event )

Definition at line 80 of file pythoneditor.py.

80 def resizeEvent(self, event):
81 super(CodeEditor, self).resizeEvent(event)
82
83 qRect = self.contentsRect()
84 self.debugArea.setGeometry(QRect(qRect.left(),
85 qRect.top(),
86 self.debugAreaWidth(),
87 qRect.height()))
88 scrollBarHeight = 0
89 if (self.horizontalScrollBar().isVisible()):
90 scrollBarHeight = self.horizontalScrollBar().height()
91
92 self.lineNumberArea.setGeometry(QRect(qRect.left() + self.debugAreaWidth(),
93 qRect.top(),
94 self.lineNumberAreaWidth(),
95 qRect.height() - scrollBarHeight))
96

References scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugArea, scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugAreaWidth(), KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberArea, scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberAreaWidth(), and scripter.ui_scripter.editor.pythoneditor.CodeEditor.resizeEvent().

◆ setDocumentModified()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.setDocumentModified ( self,
changed = False )

Definition at line 404 of file pythoneditor.py.

404 def setDocumentModified(self, changed=False):
405 self._documentModified = changed

◆ setFontSize()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.setFontSize ( self,
size = 10 )

Definition at line 394 of file pythoneditor.py.

394 def setFontSize(self, size=10):
395 self.setFont(QFont(self._font, size))
396

◆ setStepped()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.setStepped ( self,
status )

Definition at line 397 of file pythoneditor.py.

397 def setStepped(self, status):
398 self._stepped = status
399

◆ toggleComment()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.toggleComment ( self)
Toggle lines of selected text to/from either comment or uncomment
selected text is obtained from text cursor
If selected text contains both commented and uncommented text this will
flip the state of each line - which may not be desirable.

Definition at line 341 of file pythoneditor.py.

341 def toggleComment(self):
342 """Toggle lines of selected text to/from either comment or uncomment
343 selected text is obtained from text cursor
344 If selected text contains both commented and uncommented text this will
345 flip the state of each line - which may not be desirable.
346 """
347
348 cursor = self.textCursor()
349 selectionStart = cursor.selectionStart()
350 selectionEnd = cursor.selectionEnd()
351
352 cursor.setPosition(selectionStart)
353 startBlock = cursor.blockNumber()
354 cursor.setPosition(selectionEnd)
355 endBlock = cursor.blockNumber()
356
357 cursor.movePosition(QTextCursor.MoveOperation.Start)
358 cursor.movePosition(QTextCursor.MoveOperation.NextBlock, n=startBlock)
359
360 for _ in range(0, endBlock - startBlock + 1):
361 # Test for empty line (if the line is empty moving the cursor right will overflow
362 # to next line, throwing the line tracking off)
363 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
364 p1 = cursor.position()
365 cursor.movePosition(QTextCursor.MoveOperation.EndOfLine)
366 p2 = cursor.position()
367 if p1 == p2: # empty line - comment it
368 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
369 cursor.insertText(CHAR_COMMENT)
370 cursor.movePosition(QTextCursor.MoveOperation.NextBlock)
371 continue
372
373 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
374 cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor)
375 text = cursor.selectedText()
376
377 if text == CHAR_COMMENT:
378 cursor.removeSelectedText()
379 else:
380 cursor.movePosition(QTextCursor.MoveOperation.StartOfLine)
381 cursor.insertText(CHAR_COMMENT)
382
383 cursor.movePosition(QTextCursor.MoveOperation.NextBlock)
384

◆ updateLineNumberArea()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.updateLineNumberArea ( self,
rect,
dy )
 This slot is invoked when the editors viewport has been scrolled 

Definition at line 100 of file pythoneditor.py.

100 def updateLineNumberArea(self, rect, dy):
101 """ This slot is invoked when the editors viewport has been scrolled """
102
103 if dy:
104 self.lineNumberArea.scroll(0, dy)
105 self.debugArea.scroll(0, dy)
106 else:
107 self.lineNumberArea.update(0, rect.y(), self.lineNumberArea.width(), rect.height())
108
109 if rect.contains(self.viewport().rect()):
110 self.updateMarginsWidth()
111

References scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugArea, KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberArea, scripter.ui_scripter.editor.pythoneditor.CodeEditor.updateMarginsWidth, and scripter.ui_scripter.editor.pythoneditor.CodeEditor.updateMarginsWidth().

◆ updateMarginsWidth()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.updateMarginsWidth ( self)

Definition at line 97 of file pythoneditor.py.

97 def updateMarginsWidth(self):
98 self.setViewportMargins(self.lineNumberAreaWidth() + self.debugAreaWidth(), 0, 0, 0)
99

References scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugAreaWidth(), KisPipeBrushParasite.dim, KisSpinBoxUnitManager.dim, FlattenSpec.dim, xcfLayer.dim, and scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberAreaWidth().

◆ wheelEvent()

scripter.ui_scripter.editor.pythoneditor.CodeEditor.wheelEvent ( self,
e )
When the CTRL is pressed during the wheelEvent, zoomIn and zoomOut
   slots are invoked

Definition at line 171 of file pythoneditor.py.

171 def wheelEvent(self, e):
172 """When the CTRL is pressed during the wheelEvent, zoomIn and zoomOut
173 slots are invoked"""
174 if e.modifiers() == Qt.KeyboardModifier.ControlModifier:
175 delta = e.angleDelta().y()
176 if delta < 0:
177 self.zoomOut()
178 elif delta > 0:
179 self.zoomIn()
180 else:
181 super(CodeEditor, self).wheelEvent(e)
182

Member Data Documentation

◆ _documentChanged

scripter.ui_scripter.editor.pythoneditor.CodeEditor._documentChanged
protected

Definition at line 60 of file pythoneditor.py.

◆ _documentModified

scripter.ui_scripter.editor.pythoneditor.CodeEditor._documentModified
protected

Definition at line 405 of file pythoneditor.py.

◆ _font

scripter.ui_scripter.editor.pythoneditor.CodeEditor._font
protected

Definition at line 391 of file pythoneditor.py.

◆ _stepped

scripter.ui_scripter.editor.pythoneditor.CodeEditor._stepped
protected

Definition at line 57 of file pythoneditor.py.

◆ DEBUG_AREA_WIDTH

int scripter.ui_scripter.editor.pythoneditor.CodeEditor.DEBUG_AREA_WIDTH = 20
static

Definition at line 39 of file pythoneditor.py.

◆ debugArea

scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugArea

Definition at line 48 of file pythoneditor.py.

◆ debugArrow

scripter.ui_scripter.editor.pythoneditor.CodeEditor.debugArrow

Definition at line 58 of file pythoneditor.py.

◆ font

scripter.ui_scripter.editor.pythoneditor.CodeEditor.font

Definition at line 56 of file pythoneditor.py.

◆ highlightCurrentLine

scripter.ui_scripter.editor.pythoneditor.CodeEditor.highlightCurrentLine

Definition at line 52 of file pythoneditor.py.

◆ indent_width

scripter.ui_scripter.editor.pythoneditor.CodeEditor.indent_width

Definition at line 61 of file pythoneditor.py.

◆ lineNumberArea

scripter.ui_scripter.editor.pythoneditor.CodeEditor.lineNumberArea

Definition at line 47 of file pythoneditor.py.

◆ scripter

scripter.ui_scripter.editor.pythoneditor.CodeEditor.scripter

Definition at line 46 of file pythoneditor.py.

◆ setDocumentModified

scripter.ui_scripter.editor.pythoneditor.CodeEditor.setDocumentModified

Definition at line 63 of file pythoneditor.py.

◆ updateLineNumberArea

scripter.ui_scripter.editor.pythoneditor.CodeEditor.updateLineNumberArea

Definition at line 51 of file pythoneditor.py.

◆ updateMarginsWidth

scripter.ui_scripter.editor.pythoneditor.CodeEditor.updateMarginsWidth

Definition at line 50 of file pythoneditor.py.


The documentation for this class was generated from the following file: