eric3.QScintilla.Editor

Module implementing the editor component of the eric3 IDE.

Classes

Editor Class implementing the editor component of the eric3 IDE.

Functions

None

Editor

Class implementing the editor component of the eric3 IDE.

Signals

bookmarkToggled(editor)
emitted when a bookmark is toggled
breakpointToggled(editor)
emitted when a breakpoint is toggled
captionChanged(string, editor)
emitted when the caption is updated. Typically due to a readOnly attribute change.
cursorChanged(string, int, int)
emitted when the cursor position was changed
editorSaved(string)
emitted after the editor has been saved
modificationStatusChanged(boolean, editor)
emitted when the modification status has changed

Derived from

QextScintilla

Methods

Editor Constructor
_updateReadOnly Private method to update the readOnly information for this editor.
autoComplete Public method to perform an autocompletion.
bindLexer Private slot to set the correct lexer depending on language.
boxCommentLine Public slot to box comment the current line.
boxCommentLineOrSelection Public slot to box comment the current line or current selection.
boxCommentSelection Public slot to box comment the current selection.
checkDirty Private method to check dirty status and open a message window.
clearBreakpoint Public method to clear a breakpoint.
close Public method called when the window gets closed.
closeIt Public method called by the viewmanager to finally get rid of us.
colourise Public method to recolourise the given region.
colouriseAll Public method to recolourise the whole document.
commentLine Public slot to comment the current line.
commentLineOrSelection Public slot to comment the current line or current selection.
commentSelection Public slot to comment the current selection.
contextMenuEvent Private method implementing the context menu event.
curLineHasBreakpoint Public method to check for the presence of a breakpoint at the current line.
ensureVisible Public slot to ensure, that the specified line is visible.
eventFilter Private method called to filter an event.
focusInEvent Public method called when the editor receives focus.
focusOutEvent Public method called when the editor loses focus.
getBookmarks Public method to retrieve the bookmarks.
getBreakpoints Public method to retrieve all breakpoints.
getExtension Private method to get the fileextension without a leading '.'.
getFileName Public method to return the name of the file being displayed.
getHighlightPosition Public method to return the position of the highlight bar.
getLexer Public method to retrieve a reference to the lexer object.
getMacroName Private method to select a macro name from the list of macros.
getZoom Public method used to retrieve the current zoom factor.
gotoLine Public slot to jump to the beginning of a line.
handleAutoCompletionEnable Private slot to handle the Enable Autocompletion context menu entry.
handleBookmark Public method to toggle a bookmark.
handleClearBookmarks Private slot to handle the 'Clear all bookmarks' context menu action.
handleClearBreakpoints Private slot to handle the 'Clear all breakpoints' context menu action.
handleCodeCoverage Private method to handle the code coverage context menu action.
handleCodeMetrics Private method to handle the code metrics context menu action.
handleContextClose Private slot handling the close context menu entry.
handleContextSave Private slot handling the save context menu entry.
handleContextSaveAs Private slot handling the save as context menu entry.
handleCursorPositionChanged Private slot to handle the cursorPositionChanged signal.
handleCyclopsReport Private method to handle the Cyclops report context menu action.
handleDeleteMacro Public method to delete a macro.
handleDeselectAll Private slot handling the deselect all context menu action.
handleEditBreakpoint Private slot to handle the 'Edit breakpoint' context menu action.
handleLMBbookmarks Private method to handle the 'LMB toggles bookmark' context menu action.
handleLMBbreakpoints Private method to handle the 'LMB toggles breakpoint' context menu action.
handleLanguage Private method to handle the selection of a lexer language.
handleLoadMacro Public method to load a macro from a file.
handleMarginClicked Private slot to handle the marginClicked signal.
handleModificationChanged Private slot to handle the modificationChanged signal.
handleModificationReadOnly Private slot to handle the modificationAttempted signal.
handleMonospacedEnable Private slot to handle the Use Monospaced Font context menu entry.
handleNextBookmark Private slot to handle the 'Next bookmark' context menu action.
handleNextBreakpoint Private slot to handle the 'Next breakpoint' context menu action.
handlePreviousBookmark Private slot to handle the 'Previous bookmark' context menu action.
handlePreviousBreakpoint Private slot to handle the 'Previous breakpoint' context menu action.
handleProfileData Private method to handle the show profile data context menu action.
handleRunMacro Public method to execute a macro.
handleSaveMacro Public method to save a macro to a file.
handleSelectAll Private slot handling the select all context menu action.
handleShowContextMenu Private slot handling the aboutToShow signal of the context menu.
handleShowMarginContextMenu Private slot handling the aboutToShow signal of the margins context menu.
handleShowShowMenu Private slot called before the show menu is shown.
handleStartMacroRecording Public method to start macro recording.
handleStopMacroRecording Public method to stop macro recording.
handleSyntaxCheck Private method to handle the syntax check context menu action.
handleTabnanny Private method to handle the tabnanny context menu action.
handleTemporaryBreakpoint
handleToggleBookmark Private slot to handle the 'Toggle bookmark' context menu action.
handleToggleBreakpoint Private slot to handle the 'Toggle breakpoint' context menu action.
handleToggleBreakpointEnabled Private slot to handle the 'Enable/Disable breakpoint' context menu action.
hasBookmarks Public method to check for the presence of bookmarks.
hasBreakpoints Public method to check for the presence of breakpoints.
highlight Public method to highlight (or de-highlight) a particular line.
highlightVisible Public method to make sure that the highlight is visible.
indentLine Private method to indent or unindent the current line.
indentLineOrSelection Public slot to indent the current line or current selection
indentSelection Private method to indent or unindent the current selection.
initContextMenu Private method used to setup the context menu
initContextMenuChecks Private method used to setup the Checks context sub menu.
initContextMenuLanguages Private method used to setup the Languages context sub menu.
initContextMenuShow Private method used to setup the Show context sub menu.
initMarginContextMenu Private method used to setup the context menu for the margins
isPyFile Public method to return a flag indicating a Python file.
lineAt Public method to calculate the line at a position.
marginsWidth Private method to determin the width of all margins.
newBreakpointWithProperties Public method to set a new breakpoint and its properties.
printFile Public slot to print the text.
printSelection Public slot to print the selected text.
readFile Public slot to read the text from a file.
readSettings Public slot to read the settings into our lexer.
refresh Public slot to refresh the editor contents.
revertToUnmodified Private method to revert back to the last saved state.
saveFile Public slot to save the text to a file.
saveFileAs Public slot to save a file with a new name.
setAutoCompletion Private method to configure the autocompletion function.
setAutoCompletionEnabled Public method to enable/disable autocompletion.
setBreakpointIgnoreCount Public method to set a breakpoints ignore count.
setBreakpointProperties Public method to set a breakpoints properties.
setCallTips Private method to configure the calltips function.
setCaretForegroundColour Public method to set the foreground color of the caret.
setCaretLineBackgroundColour Public method to set the background color of the caret line.
setCaretLineVisible Public method to enable the highlighting of the caret line.
setCaretWidth Public method to enable the highlighting of the caret line.
setLanguage Private method to set a lexer language.
setLineMarkerColours Private method to set the line marker colours.
setMargin0and2 Private method to configure margins 0 and 2.
setMonospaced Public method to set/reset a monospaced font.
setSelectionBackgroundColour Public method to set the background color of the selection.
setTextDisplay Private method to configure the text display.
streamCommentLine Public slot to stream comment the current line.
streamCommentLineOrSelection Public slot to stream comment the current line or current selection.
streamCommentSelection Public slot to comment the current selection.
toggleBreakpoint Public method to toggle a breakpoint.
toggleBreakpointEnabled Public method to toggle a breakpoints enabled status.
uncommentLine Public slot to uncomment the current line.
uncommentLineOrSelection Public slot to uncomment the current line or current selection.
uncommentSelection Public slot to uncomment the current selection.
unindentLineOrSelection Public slot to unindent the current line or current selection.
writeFile Public slot to write the text to a file.
zoomIn Public method used to increase the zoom factor.
zoomOut Public method used to decrease the zoom factor.
zoomTo Public method used to zoom to a specific zoom factor.

Editor (Constructor)

Editor(dbs, fn=None, parent=None, name=None, flags=0, isPythonFile=0)

Constructor

dbs
reference to the debug server object
flags
window flags
fn
name of the file to be opened (string). If it is None, a new (empty) editor is opened
isPythonFile
flag indicating that this is a Python file even if it doesn't have the .py extension (boolean)
name
name of this editor (string or QString)
parent
parent widget (viewmanager) of this editor (QWidget)

Editor._updateReadOnly

_updateReadOnly(bForce=1)

Private method to update the readOnly information for this editor.

If bForce is True, then updates everything regardless if the attributes have actually changed, such as during initialization time. A signal is emitted after the caption change.

bForce
1 to force change, 0 to only update and emit signal if there was an attribute change.

Editor.autoComplete

autoComplete()

Public method to perform an autocompletion.

Editor.bindLexer

bindLexer(language)

Private slot to set the correct lexer depending on language.

language
language (extension) of the desired lexer (string)

Editor.boxCommentLine

boxCommentLine()

Public slot to box comment the current line.

Editor.boxCommentLineOrSelection

boxCommentLineOrSelection()

Public slot to box comment the current line or current selection.

Editor.boxCommentSelection

boxCommentSelection()

Public slot to box comment the current selection.

Editor.checkDirty

checkDirty()

Private method to check dirty status and open a message window.

Returns:
flag indicating successful reset of the dirty flag (boolean)

Editor.clearBreakpoint

clearBreakpoint(line)

Public method to clear a breakpoint.

Note: This doesn't clear the breakpoint in the debugger, it just deletes it from the editor internal list of breakpoints.

line
linenumber of the breakpoint

Editor.close

close(alsoDelete=0)

Public method called when the window gets closed.

This overwritten method redirects the action to our ViewManager.closeEditor, which in turn calls our closeIt method.

alsoDelete
ignored

Editor.closeIt

closeIt()

Public method called by the viewmanager to finally get rid of us.

Editor.colourise

colourise(start, end)

Public method to recolourise the given region.

end
linenumber where to end recolourisation (integer)
start
linenumber where to start recolourisation (integer)

Editor.colouriseAll

colouriseAll()

Public method to recolourise the whole document.

Editor.commentLine

commentLine()

Public slot to comment the current line.

Editor.commentLineOrSelection

commentLineOrSelection()

Public slot to comment the current line or current selection.

Editor.commentSelection

commentSelection()

Public slot to comment the current selection.

Editor.contextMenuEvent

contextMenuEvent(evt)

Private method implementing the context menu event.

evt
the context menu event (QContextMenuEvent)

Editor.curLineHasBreakpoint

curLineHasBreakpoint()

Public method to check for the presence of a breakpoint at the current line.

Returns:
flag indicating the presence of a breakpoint (boolean)

Editor.ensureVisible

ensureVisible(line)

Public slot to ensure, that the specified line is visible.

line
line number to make visible

Editor.eventFilter

eventFilter(object, event)

Private method called to filter an event.

event
the event, that was generated by object (QEvent)
object
object, that generated the event (QObject)
Returns:
flag indicating if event was filtered out

Editor.focusInEvent

focusInEvent(event)

Public method called when the editor receives focus.

event
the event object (QFocusEvent)

Editor.focusOutEvent

focusOutEvent(event)

Public method called when the editor loses focus.

event
the event object (QFocusEvent)

Editor.getBookmarks

getBookmarks()

Public method to retrieve the bookmarks.

Returns:
sorted list of all lines containing a bookmark (list of integer)

Editor.getBreakpoints

getBreakpoints()

Public method to retrieve all breakpoints.

This method will update the internal list of breakpoints before the list is returned.

Returns:
a list of tuples with linenumber and condition

Editor.getExtension

getExtension(fname)

Private method to get the fileextension without a leading '.'.

fname
filename (string)
Returns:
extension of the filename (string)

Editor.getFileName

getFileName()

Public method to return the name of the file being displayed.

Returns:
filename of the displayed file (string)

Editor.getHighlightPosition

getHighlightPosition()

Public method to return the position of the highlight bar.

Returns:
line number of the highlight bar

Editor.getLexer

getLexer()

Public method to retrieve a reference to the lexer object.

Returns:
the lexer object (Lexer)

Editor.getMacroName

getMacroName()

Private method to select a macro name from the list of macros.

Returns:
Tuple of macro name and a flag, indicating, if the user pressed ok or canceled the operation. (QString, boolean)

Editor.getZoom

getZoom()

Public method used to retrieve the current zoom factor.

Returns:
zoom factor (int)

Editor.gotoLine

gotoLine(line)

Public slot to jump to the beginning of a line.

line
line number to go to

Editor.handleAutoCompletionEnable

handleAutoCompletionEnable()

Private slot to handle the Enable Autocompletion context menu entry.

Editor.handleBookmark

handleBookmark(line)

Public method to toggle a bookmark.

line
line number of the bookmark

Editor.handleClearBookmarks

handleClearBookmarks()

Private slot to handle the 'Clear all bookmarks' context menu action.

Editor.handleClearBreakpoints

handleClearBreakpoints()

Private slot to handle the 'Clear all breakpoints' context menu action.

Editor.handleCodeCoverage

handleCodeCoverage()

Private method to handle the code coverage context menu action.

Editor.handleCodeMetrics

handleCodeMetrics()

Private method to handle the code metrics context menu action.

Editor.handleContextClose

handleContextClose()

Private slot handling the close context menu entry.

Editor.handleContextSave

handleContextSave()

Private slot handling the save context menu entry.

Editor.handleContextSaveAs

handleContextSaveAs()

Private slot handling the save as context menu entry.

Editor.handleCursorPositionChanged

handleCursorPositionChanged(line, pos)

Private slot to handle the cursorPositionChanged signal.

It emits the signal cursorChanged with parameters fileName, line and pos.

line
line number of the cursor
pos
position in line of the cursor

Editor.handleCyclopsReport

handleCyclopsReport()

Private method to handle the Cyclops report context menu action.

Editor.handleDeleteMacro

handleDeleteMacro()

Public method to delete a macro.

Editor.handleDeselectAll

handleDeselectAll()

Private slot handling the deselect all context menu action.

Editor.handleEditBreakpoint

handleEditBreakpoint()

Private slot to handle the 'Edit breakpoint' context menu action.

Editor.handleLMBbookmarks

handleLMBbookmarks()

Private method to handle the 'LMB toggles bookmark' context menu action.

Editor.handleLMBbreakpoints

handleLMBbreakpoints()

Private method to handle the 'LMB toggles breakpoint' context menu action.

Editor.handleLanguage

handleLanguage(idx)

Private method to handle the selection of a lexer language.

idx
index of the lexer language (int)

Editor.handleLoadMacro

handleLoadMacro()

Public method to load a macro from a file.

Editor.handleMarginClicked

handleMarginClicked(margin, line, state)

Private slot to handle the marginClicked signal.

line
line number pf the click
margin
id of the clicked margin
state
mouse button state

Editor.handleModificationChanged

handleModificationChanged(m)

Private slot to handle the modificationChanged signal.

It emits the signal modificationStatusChanged with parameters m and self.

m
modification status

Editor.handleModificationReadOnly

handleModificationReadOnly()

Private slot to handle the modificationAttempted signal.

Editor.handleMonospacedEnable

handleMonospacedEnable()

Private slot to handle the Use Monospaced Font context menu entry.

Editor.handleNextBookmark

handleNextBookmark()

Private slot to handle the 'Next bookmark' context menu action.

Editor.handleNextBreakpoint

handleNextBreakpoint()

Private slot to handle the 'Next breakpoint' context menu action.

Editor.handlePreviousBookmark

handlePreviousBookmark()

Private slot to handle the 'Previous bookmark' context menu action.

Editor.handlePreviousBreakpoint

handlePreviousBreakpoint()

Private slot to handle the 'Previous breakpoint' context menu action.

Editor.handleProfileData

handleProfileData()

Private method to handle the show profile data context menu action.

Editor.handleRunMacro

handleRunMacro()

Public method to execute a macro.

Editor.handleSaveMacro

handleSaveMacro()

Public method to save a macro to a file.

Editor.handleSelectAll

handleSelectAll()

Private slot handling the select all context menu action.

Editor.handleShowContextMenu

handleShowContextMenu()

Private slot handling the aboutToShow signal of the context menu.

Editor.handleShowMarginContextMenu

handleShowMarginContextMenu()

Private slot handling the aboutToShow signal of the margins context menu.

Editor.handleShowShowMenu

handleShowShowMenu()

Private slot called before the show menu is shown.

Editor.handleStartMacroRecording

handleStartMacroRecording()

Public method to start macro recording.

Editor.handleStopMacroRecording

handleStopMacroRecording()

Public method to stop macro recording.

Editor.handleSyntaxCheck

handleSyntaxCheck()

Private method to handle the syntax check context menu action.

Editor.handleTabnanny

handleTabnanny()

Private method to handle the tabnanny context menu action.

Editor.handleTemporaryBreakpoint

handleTemporaryBreakpoint()

Editor.handleToggleBookmark

handleToggleBookmark()

Private slot to handle the 'Toggle bookmark' context menu action.

Editor.handleToggleBreakpoint

handleToggleBreakpoint()

Private slot to handle the 'Toggle breakpoint' context menu action.

Editor.handleToggleBreakpointEnabled

handleToggleBreakpointEnabled()

Private slot to handle the 'Enable/Disable breakpoint' context menu action.

Editor.hasBookmarks

hasBookmarks()

Public method to check for the presence of bookmarks.

Returns:
flag indicating the presence of bookmarks (boolean)

Editor.hasBreakpoints

hasBreakpoints()

Public method to check for the presence of breakpoints.

Returns:
flag indicating the presence of breakpoints (boolean)

Editor.highlight

highlight(line=None, error=0)

Public method to highlight (or de-highlight) a particular line.

error
flag indicating whether the error highlight should be used
line
line number to highlight

Editor.highlightVisible

highlightVisible()

Public method to make sure that the highlight is visible.

Editor.indentLine

indentLine(indent = 1)

Private method to indent or unindent the current line.

indent
flag indicating an indent operation
If the flag is true, an indent operation is performed. Otherwise the current line is unindented.

Editor.indentLineOrSelection

indentLineOrSelection()

Public slot to indent the current line or current selection

Editor.indentSelection

indentSelection(indent = 1)

Private method to indent or unindent the current selection.

indent
flag indicating an indent operation
If the flag is true, an indent operation is performed. Otherwise the current line is unindented.

Editor.initContextMenu

initContextMenu()

Private method used to setup the context menu

Editor.initContextMenuChecks

initContextMenuChecks()

Private method used to setup the Checks context sub menu.

Editor.initContextMenuLanguages

initContextMenuLanguages()

Private method used to setup the Languages context sub menu.

Editor.initContextMenuShow

initContextMenuShow()

Private method used to setup the Show context sub menu.

Editor.initMarginContextMenu

initMarginContextMenu()

Private method used to setup the context menu for the margins

Editor.isPyFile

isPyFile()

Public method to return a flag indicating a Python file.

Returns:
flag indicating a Python file (boolean)

Editor.lineAt

lineAt(pos)

Public method to calculate the line at a position.

This variant is able to calculate the line for positions in the margins and for empty lines.

pos
position to calculate the line for (QPoint)
Returns:
linenumber at position or -1, if there is no line at pos (integer, zero based)

Editor.marginsWidth

marginsWidth()

Private method to determin the width of all margins.

Returns:
width of all margins in pixels (integer)

Editor.newBreakpointWithProperties

newBreakpointWithProperties(line, properties)

Public method to set a new breakpoint and its properties.

line
line number of the breakpoint
properties
properties for the breakpoint (tuple) (condition, temporary flag, enabled flag, ignore count)

Editor.printFile

printFile()

Public slot to print the text.

Editor.printSelection

printSelection()

Public slot to print the selected text.

Editor.readFile

readFile(fn)

Public slot to read the text from a file.

fn
filename to read from (string or QString)

Editor.readSettings

readSettings()

Public slot to read the settings into our lexer.

Editor.refresh

refresh()

Public slot to refresh the editor contents.

Editor.revertToUnmodified

revertToUnmodified()

Private method to revert back to the last saved state.

Editor.saveFile

saveFile(saveas = 0, path = None)

Public slot to save the text to a file.

path
directory to save the file in (string or QString)
saveas
flag indicating a 'save as' action
Returns:
tuple of two values (boolean, string) giving a success indicator and the name of the saved file

Editor.saveFileAs

saveFileAs(path = None)

Public slot to save a file with a new name.

path
directory to save the file in (string or QString)
Returns:
tuple of two values (boolean, string) giving a success indicator and the name of the saved file

Editor.setAutoCompletion

setAutoCompletion()

Private method to configure the autocompletion function.

Editor.setAutoCompletionEnabled

setAutoCompletionEnabled(enable)

Public method to enable/disable autocompletion.

enable
flag indicating the desired autocompletion status

Editor.setBreakpointIgnoreCount

setBreakpointIgnoreCount(line, count)

Public method to set a breakpoints ignore count.

count
ignore count for the breakpoint (integer)
line
line number of the breakpoint

Editor.setBreakpointProperties

setBreakpointProperties(line, properties)

Public method to set a breakpoints properties.

line
line number of the breakpoint
properties
properties for the breakpoint (tuple) (condition, temporary flag, enabled flag, ignore count)

Editor.setCallTips

setCallTips()

Private method to configure the calltips function.

Editor.setCaretForegroundColour

setCaretForegroundColour(colour)

Public method to set the foreground color of the caret.

colour
colour to be set (QColor)

Editor.setCaretLineBackgroundColour

setCaretLineBackgroundColour(colour)

Public method to set the background color of the caret line.

colour
colour to be set (QColor)

Editor.setCaretLineVisible

setCaretLineVisible(enable)

Public method to enable the highlighting of the caret line.

enable
flag indicating the highlighting state to be set (boolean)

Editor.setCaretWidth

setCaretWidth(width)

Public method to enable the highlighting of the caret line.

width
width of the caret (integer - 1, 2 or 3)

Editor.setLanguage

setLanguage(language)

Private method to set a lexer language.

language
language (extension) of the desired lexer (string)

Editor.setLineMarkerColours

setLineMarkerColours()

Private method to set the line marker colours.

Editor.setMargin0and2

setMargin0and2()

Private method to configure margins 0 and 2.

Editor.setMonospaced

setMonospaced(on)

Public method to set/reset a monospaced font.

on
flag to indicate usage of a monospace font (boolean)

Editor.setSelectionBackgroundColour

setSelectionBackgroundColour(colour)

Public method to set the background color of the selection.

colour
colour to be set (QColor)

Editor.setTextDisplay

setTextDisplay()

Private method to configure the text display.

Editor.streamCommentLine

streamCommentLine()

Public slot to stream comment the current line.

Editor.streamCommentLineOrSelection

streamCommentLineOrSelection()

Public slot to stream comment the current line or current selection.

Editor.streamCommentSelection

streamCommentSelection()

Public slot to comment the current selection.

Editor.toggleBreakpoint

toggleBreakpoint(line, temporary = 0)

Public method to toggle a breakpoint.

line
line number of the breakpoint
temporary
flag indicating a temporary breakpoint

Editor.toggleBreakpointEnabled

toggleBreakpointEnabled(line)

Public method to toggle a breakpoints enabled status.

line
line number of the breakpoint

Editor.uncommentLine

uncommentLine()

Public slot to uncomment the current line.

This happens only, if it was commented by using the commentLine() or commentSelection() slots

Editor.uncommentLineOrSelection

uncommentLineOrSelection()

Public slot to uncomment the current line or current selection.

This happens only, if it was commented by using the commentLine() or commentSelection() slots

Editor.uncommentSelection

uncommentSelection()

Public slot to uncomment the current selection.

This happens only, if it was commented by using the commentLine() or commentSelection() slots

Editor.unindentLineOrSelection

unindentLineOrSelection()

Public slot to unindent the current line or current selection.

Editor.writeFile

writeFile(fn)

Public slot to write the text to a file.

fn
filename to write to (string or QString)
Returns:
flag indicating success

Editor.zoomIn

zoomIn(zoom = 1)

Public method used to increase the zoom factor.

zoom
zoom factor increment

Editor.zoomOut

zoomOut(zoom = 1)

Public method used to decrease the zoom factor.

zoom
zoom factor decrement

Editor.zoomTo

zoomTo(zoom)

Public method used to zoom to a specific zoom factor.

zoom
zoom factor

Up