QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
QgsCodeEditor Class Reference

A text editor based on QScintilla2. More...

#include <qgscodeeditor.h>

Inheritance diagram for QgsCodeEditor:
Inheritance graph
[legend]

Public Types

enum class  Flag : int { CodeFolding = 1 << 0 , ImmediatelyUpdateHistory = 1 << 1 }
 Flags controlling behavior of code editor. More...
 
typedef QFlags< FlagFlags
 Flags controlling behavior of code editor.
 
enum class  MarginRole : int { LineNumbers = 0 , ErrorIndicators = 1 , FoldingControls = 2 }
 Margin roles. More...
 
enum class  Mode { ScriptEditor , OutputDisplay , CommandInput }
 Code editor modes. More...
 

Public Slots

virtual bool checkSyntax ()
 Applies syntax checking to the editor.
 
void clearPersistentHistory ()
 Clears the entire persistent history of commands run in the editor.
 
void clearSessionHistory ()
 Clears the history of commands run in the current session.
 
virtual void moveCursorToEnd ()
 Moves the cursor to the end of the document and scrolls to ensure it is visible.
 
virtual void moveCursorToStart ()
 Moves the cursor to the start of the document and scrolls to ensure it is visible.
 
void reformatCode ()
 Applies code reformatting to the editor.
 
void removeHistoryCommand (int index)
 Removes the command at the specified index from the history of the code editor.
 
void runCommand (const QString &command, bool skipHistory=false)
 Runs a command in the editor.
 
void showHistory ()
 Shows the command history dialog.
 
void showNextCommand ()
 Shows the next command from the session in the editor.
 
void showPreviousCommand ()
 Shows the previous command from the session in the editor.
 
virtual void toggleComment ()
 Toggle comment for the selected text.
 
bool writeHistoryFile ()
 Stores the commands executed in the editor to the persistent history file.
 

Signals

void helpRequested (const QString &word)
 Emitted when documentation was requested for the specified word.
 
void persistentHistoryCleared ()
 Emitted when the persistent history of commands run in the editor is cleared.
 
void sessionHistoryCleared ()
 Emitted when the history of commands run in the current session is cleared.
 

Public Member Functions

 QgsCodeEditor (QWidget *parent=nullptr, const QString &title=QString(), bool folding=false, bool margin=false, QgsCodeEditor::Flags flags=QgsCodeEditor::Flags(), QgsCodeEditor::Mode mode=QgsCodeEditor::Mode::ScriptEditor)
 Construct a new code editor.
 
void addWarning (int lineNumber, const QString &warning)
 Adds a warning message and indicator to the specified a lineNumber.
 
virtual void callTip () override
 
void clearWarnings ()
 Clears all warning messages from the editor.
 
bool foldingVisible ()
 Returns true if the folding controls are visible in the editor.
 
QStringList history () const
 Returns the list of commands previously executed in the editor.
 
void insertText (const QString &text)
 Insert text at cursor position, or replace any selected text if user has made a selection.
 
QgsCodeInterpreterinterpreter () const
 Returns the attached code interpreter, or nullptr if not set.
 
bool isCursorOnLastLine () const
 Returns true if the cursor is on the last line of the document.
 
virtual Qgis::ScriptLanguage language () const
 Returns the associated scripting language.
 
virtual Qgis::ScriptLanguageCapabilities languageCapabilities () const
 Returns the associated scripting language capabilities.
 
int linearPosition () const
 Convenience function to return the cursor position as a linear index.
 
bool lineNumbersVisible () const
 Returns whether line numbers are visible in the editor.
 
Q_DECL_DEPRECATED bool marginVisible ()
 Returns whether margins are in a visible state.
 
QgsCodeEditor::Mode mode () const
 Returns the code editor mode.
 
int selectionEnd () const
 Convenience function to return the end of the selection as a linear index Contrary to the getSelection method, this method returns the cursor position if no selection is made.
 
int selectionStart () const
 Convenience function to return the start of the selection as a linear index Contrary to the getSelection method, this method returns the cursor position if no selection is made.
 
void setCustomAppearance (const QString &scheme=QString(), const QMap< QgsCodeEditorColorScheme::ColorRole, QColor > &customColors=QMap< QgsCodeEditorColorScheme::ColorRole, QColor >(), const QString &fontFamily=QString(), int fontSize=0)
 Sets a custom appearance for the widget, disconnecting it from using the standard appearance taken from QSettings.
 
void setFoldingVisible (bool folding)
 Set whether the folding controls are visible in the editor.
 
void setHistoryFilePath (const QString &path)
 Sets the file path to use for recording and retrieving previously executed commands.
 
void setInterpreter (QgsCodeInterpreter *newInterpreter)
 Sets an attached code interpreter for executing commands when the editor is in the QgsCodeEditor::Mode::CommandInput mode.
 
void setLinearPosition (int position)
 Convenience function to set the cursor position as a linear index.
 
void setLinearSelection (int start, int end)
 Convenience function to set the selection using linear indexes.
 
void setLineNumbersVisible (bool visible)
 Sets whether line numbers should be visible in the editor.
 
Q_DECL_DEPRECATED void setMarginVisible (bool margin)
 Set margin visible state.
 
void setTitle (const QString &title)
 Set the widget title.
 
int wrapPosition (int line=-1)
 Returns the linear position of the start of the last wrapped part for the specified line, or for the current line if line = -1 If wrapping is disabled, returns -1 instead.
 

Static Public Member Functions

static QColor color (QgsCodeEditorColorScheme::ColorRole role)
 Returns the color to use in the editor for the specified role.
 
static QColor defaultColor (QgsCodeEditorColorScheme::ColorRole role, const QString &theme=QString())
 Returns the default color for the specified role.
 
static QFont getMonospaceFont ()
 Returns the monospaced font to use for code editors.
 
static QString languageToString (Qgis::ScriptLanguage language)
 Returns a user-friendly, translated name of the specified script language.
 
static void setColor (QgsCodeEditorColorScheme::ColorRole role, const QColor &color)
 Sets the color to use in the editor for the specified role.
 

Static Public Attributes

static constexpr int SEARCH_RESULT_INDICATOR = QsciScintilla::INDIC_MAX - 1
 Indicator index for search results.
 
static const QgsSettingsEntryBoolsettingContextHelpHover
 
static QgsSettingsTreeNodesTreeCodeEditor = QgsSettingsTree::sTreeGui->createChildNode( QStringLiteral( "code-editor" ) )
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event) override
 
bool eventFilter (QObject *watched, QEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
virtual void initializeLexer ()
 Called when the dialect specific code lexer needs to be initialized (or reinitialized).
 
void keyPressEvent (QKeyEvent *event) override
 
QColor lexerColor (QgsCodeEditorColorScheme::ColorRole role) const
 Returns the color to use in the lexer for the specified role.
 
QFont lexerFont () const
 Returns the font to use in the lexer.
 
virtual void populateContextMenu (QMenu *menu)
 Called when the context menu for the widget is about to be shown, after it has been fully populated with the standard actions created by the base class.
 
virtual QString reformatCodeString (const QString &string)
 Applies code reformatting to a string and returns the result.
 
void runPostLexerConfigurationTasks ()
 Performs tasks which must be run after a lexer has been set for the widget.
 
virtual void showMessage (const QString &title, const QString &message, Qgis::MessageLevel level)
 Shows a user facing message (eg a warning message).
 
void updatePrompt ()
 Triggers an update of the interactive prompt part of the editor.
 
void updateSoftHistory ()
 Updates the soft history by storing the current editor text in the history.
 

Static Protected Member Functions

static bool isFixedPitch (const QFont &font)
 Returns true if a font is a fixed pitch font.
 

Detailed Description

A text editor based on QScintilla2.

Note
may not be available in Python bindings, depending on platform support

Definition at line 101 of file qgscodeeditor.h.

Member Typedef Documentation

◆ Flags

typedef QFlags< Flag > QgsCodeEditor::Flags

Flags controlling behavior of code editor.

Since
QGIS 3.28

Definition at line 159 of file qgscodeeditor.h.

Member Enumeration Documentation

◆ Flag

enum class QgsCodeEditor::Flag : int
strong

Flags controlling behavior of code editor.

Since
QGIS 3.28
Enumerator
CodeFolding 

Indicates that code folding should be enabled for the editor.

ImmediatelyUpdateHistory 

Indicates that the history file should be immediately updated whenever a command is executed, instead of the default behavior of only writing the history on widget close.

Since
QGIS 3.32

Definition at line 147 of file qgscodeeditor.h.

◆ MarginRole

enum class QgsCodeEditor::MarginRole : int
strong

Margin roles.

This enum contains the roles which the different numbered margins are used for.

Since
QGIS 3.16
Enumerator
LineNumbers 

Line numbers.

ErrorIndicators 

Error indicators.

FoldingControls 

Folding controls.

Definition at line 134 of file qgscodeeditor.h.

◆ Mode

enum class QgsCodeEditor::Mode
strong

Code editor modes.

Since
QGIS 3.30
Enumerator
ScriptEditor 

Standard mode, allows for display and edit of entire scripts.

OutputDisplay 

Read only mode for display of command outputs.

CommandInput 

Command input mode.

Definition at line 119 of file qgscodeeditor.h.

Constructor & Destructor Documentation

◆ QgsCodeEditor()

QgsCodeEditor::QgsCodeEditor ( QWidget *  parent = nullptr,
const QString &  title = QString(),
bool  folding = false,
bool  margin = false,
QgsCodeEditor::Flags  flags = QgsCodeEditor::Flags(),
QgsCodeEditor::Mode  mode = QgsCodeEditor::Mode::ScriptEditor 
)

Construct a new code editor.

Parameters
parentThe parent QWidget
titleThe title to show in the code editor dialog
foldingfalse: Enable folding for code editor (deprecated, use flags instead)
marginfalse: Enable margin for code editor (deprecated)
flagsflags controlling behavior of code editor (since QGIS 3.28)
modecode editor mode (since QGIS 3.30)

Definition at line 88 of file qgscodeeditor.cpp.

Member Function Documentation

◆ addWarning()

void QgsCodeEditor::addWarning ( int  lineNumber,
const QString &  warning 
)

Adds a warning message and indicator to the specified a lineNumber.

See also
clearWarnings()
Since
QGIS 3.16

Definition at line 1102 of file qgscodeeditor.cpp.

◆ callTip()

void QgsCodeEditor::callTip ( )
overridevirtual

Definition at line 1245 of file qgscodeeditor.cpp.

◆ checkSyntax

bool QgsCodeEditor::checkSyntax ( )
virtualslot

Applies syntax checking to the editor.

This is only supported for editors which return the Qgis::ScriptLanguageCapability::CheckSyntax capability from languageCapabilities().

Since
QGIS 3.32

Reimplemented in QgsCodeEditorPython.

Definition at line 820 of file qgscodeeditor.cpp.

◆ clearPersistentHistory

void QgsCodeEditor::clearPersistentHistory ( )
slot

Clears the entire persistent history of commands run in the editor.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 860 of file qgscodeeditor.cpp.

◆ clearSessionHistory

void QgsCodeEditor::clearSessionHistory ( )
slot

Clears the history of commands run in the current session.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 851 of file qgscodeeditor.cpp.

◆ clearWarnings()

void QgsCodeEditor::clearWarnings ( )

Clears all warning messages from the editor.

See also
addWarning()
Since
QGIS 3.16

Definition at line 1117 of file qgscodeeditor.cpp.

◆ color()

QColor QgsCodeEditor::color ( QgsCodeEditorColorScheme::ColorRole  role)
static

Returns the color to use in the editor for the specified role.

This color will be the default theme color for the role, unless the user has manually selected a custom color scheme for the editor.

See also
setColor()
Since
QGIS 3.16

Definition at line 1023 of file qgscodeeditor.cpp.

◆ contextMenuEvent()

void QgsCodeEditor::contextMenuEvent ( QContextMenuEvent *  event)
overrideprotected

Definition at line 283 of file qgscodeeditor.cpp.

◆ defaultColor()

QColor QgsCodeEditor::defaultColor ( QgsCodeEditorColorScheme::ColorRole  role,
const QString &  theme = QString() 
)
static

Returns the default color for the specified role.

The optional theme argument can be used to specify a color theme. A blank theme indicates the default color scheme.

Available themes are stored in QgsCodeEditorColorSchemeRegistry, and can be retrieved via QgsGui::codeEditorColorSchemeRegistry().

Since
QGIS 3.16

Definition at line 953 of file qgscodeeditor.cpp.

◆ eventFilter()

bool QgsCodeEditor::eventFilter ( QObject *  watched,
QEvent *  event 
)
overrideprotected

Definition at line 361 of file qgscodeeditor.cpp.

◆ focusOutEvent()

void QgsCodeEditor::focusOutEvent ( QFocusEvent *  event)
overrideprotected

Definition at line 158 of file qgscodeeditor.cpp.

◆ foldingVisible()

bool QgsCodeEditor::foldingVisible ( )

Returns true if the folding controls are visible in the editor.

See also
setFoldingVisible()

Definition at line 612 of file qgscodeeditor.cpp.

◆ getMonospaceFont()

QFont QgsCodeEditor::getMonospaceFont ( )
static

Returns the monospaced font to use for code editors.

Since
QGIS 3.16

Definition at line 1057 of file qgscodeeditor.cpp.

◆ helpRequested

void QgsCodeEditor::helpRequested ( const QString &  word)
signal

Emitted when documentation was requested for the specified word.

Since
QGIS 3.42

◆ history()

QStringList QgsCodeEditor::history ( ) const

Returns the list of commands previously executed in the editor.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 830 of file qgscodeeditor.cpp.

◆ initializeLexer()

void QgsCodeEditor::initializeLexer ( )
protectedvirtual

Called when the dialect specific code lexer needs to be initialized (or reinitialized).

The default implementation does nothing.

Since
QGIS 3.16

Reimplemented in QgsCodeEditorCSS, QgsCodeEditorExpression, QgsCodeEditorHTML, QgsCodeEditorJavascript, QgsCodeEditorJson, QgsCodeEditorPython, QgsCodeEditorR, QgsCodeEditorShell, and QgsCodeEditorSQL.

Definition at line 376 of file qgscodeeditor.cpp.

◆ insertText()

void QgsCodeEditor::insertText ( const QString &  text)

Insert text at cursor position, or replace any selected text if user has made a selection.

Parameters
textThe text to be inserted

Definition at line 937 of file qgscodeeditor.cpp.

◆ interpreter()

QgsCodeInterpreter * QgsCodeEditor::interpreter ( ) const

Returns the attached code interpreter, or nullptr if not set.

See also
setInterpreter()
Since
QGIS 3.30

Definition at line 727 of file qgscodeeditor.cpp.

◆ isCursorOnLastLine()

bool QgsCodeEditor::isCursorOnLastLine ( ) const

Returns true if the cursor is on the last line of the document.

Since
QGIS 3.28

Definition at line 1128 of file qgscodeeditor.cpp.

◆ isFixedPitch()

bool QgsCodeEditor::isFixedPitch ( const QFont &  font)
staticprotected

Returns true if a font is a fixed pitch font.

Definition at line 1052 of file qgscodeeditor.cpp.

◆ keyPressEvent()

void QgsCodeEditor::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 188 of file qgscodeeditor.cpp.

◆ language()

Qgis::ScriptLanguage QgsCodeEditor::language ( ) const
virtual

Returns the associated scripting language.

Since
QGIS 3.30

Reimplemented in QgsCodeEditorCSS, QgsCodeEditorExpression, QgsCodeEditorHTML, QgsCodeEditorJavascript, QgsCodeEditorJson, QgsCodeEditorPython, QgsCodeEditorR, QgsCodeEditorShell, and QgsCodeEditorSQL.

Definition at line 514 of file qgscodeeditor.cpp.

◆ languageCapabilities()

Qgis::ScriptLanguageCapabilities QgsCodeEditor::languageCapabilities ( ) const
virtual

Returns the associated scripting language capabilities.

Since
QGIS 3.32

Reimplemented in QgsCodeEditorHTML, and QgsCodeEditorPython.

Definition at line 519 of file qgscodeeditor.cpp.

◆ languageToString()

QString QgsCodeEditor::languageToString ( Qgis::ScriptLanguage  language)
static

Returns a user-friendly, translated name of the specified script language.

Since
QGIS 3.30

Definition at line 524 of file qgscodeeditor.cpp.

◆ lexerColor()

QColor QgsCodeEditor::lexerColor ( QgsCodeEditorColorScheme::ColorRole  role) const
protected

Returns the color to use in the lexer for the specified role.

Since
QGIS 3.16

Definition at line 381 of file qgscodeeditor.cpp.

◆ lexerFont()

QFont QgsCodeEditor::lexerFont ( ) const
protected

Returns the font to use in the lexer.

Since
QGIS 3.16

Definition at line 397 of file qgscodeeditor.cpp.

◆ linearPosition()

int QgsCodeEditor::linearPosition ( ) const

Convenience function to return the cursor position as a linear index.

Since
QGIS 3.36

Definition at line 1164 of file qgscodeeditor.cpp.

◆ lineNumbersVisible()

bool QgsCodeEditor::lineNumbersVisible ( ) const

Returns whether line numbers are visible in the editor.

See also
setLineNumbersVisible()
Since
QGIS 3.16

Definition at line 594 of file qgscodeeditor.cpp.

◆ marginVisible()

Q_DECL_DEPRECATED bool QgsCodeEditor::marginVisible ( )
inline

Returns whether margins are in a visible state.

Deprecated:
QGIS 3.40. Use base class methods for individual margins instead, or lineNumbersVisible().

Definition at line 215 of file qgscodeeditor.h.

◆ mode()

QgsCodeEditor::Mode QgsCodeEditor::mode ( ) const
inline

Returns the code editor mode.

Since
QGIS 3.30

Definition at line 328 of file qgscodeeditor.h.

◆ moveCursorToEnd

void QgsCodeEditor::moveCursorToEnd ( )
virtualslot

Moves the cursor to the end of the document and scrolls to ensure it is visible.

Since
QGIS 3.28

Definition at line 1152 of file qgscodeeditor.cpp.

◆ moveCursorToStart

void QgsCodeEditor::moveCursorToStart ( )
virtualslot

Moves the cursor to the start of the document and scrolls to ensure it is visible.

Since
QGIS 3.28

Definition at line 1142 of file qgscodeeditor.cpp.

◆ persistentHistoryCleared

void QgsCodeEditor::persistentHistoryCleared ( )
signal

Emitted when the persistent history of commands run in the editor is cleared.

Since
QGIS 3.30

◆ populateContextMenu()

void QgsCodeEditor::populateContextMenu ( QMenu *  menu)
protectedvirtual

Called when the context menu for the widget is about to be shown, after it has been fully populated with the standard actions created by the base class.

This method provides an opportunity for subclasses to add additional non-standard actions to the context menu.

Since
QGIS 3.30

Reimplemented in QgsCodeEditorPython.

Definition at line 688 of file qgscodeeditor.cpp.

◆ reformatCode

void QgsCodeEditor::reformatCode ( )
slot

Applies code reformatting to the editor.

This is only supported for editors which return the Qgis::ScriptLanguageCapability::Reformat capability from languageCapabilities().

Since
QGIS 3.32

Definition at line 795 of file qgscodeeditor.cpp.

◆ reformatCodeString()

QString QgsCodeEditor::reformatCodeString ( const QString &  string)
protectedvirtual

Applies code reformatting to a string and returns the result.

This is only supported for editors which return the Qgis::ScriptLanguageCapability::Reformat capability from languageCapabilities().

Since
QGIS 3.32

Reimplemented in QgsCodeEditorHTML, and QgsCodeEditorPython.

Definition at line 693 of file qgscodeeditor.cpp.

◆ removeHistoryCommand

void QgsCodeEditor::removeHistoryCommand ( int  index)
slot

Removes the command at the specified index from the history of the code editor.

Since
QGIS 3.30

Definition at line 924 of file qgscodeeditor.cpp.

◆ runCommand

void QgsCodeEditor::runCommand ( const QString &  command,
bool  skipHistory = false 
)
slot

Runs a command in the editor.

An interpreter() must be set.

Since QGIS 3.32, if skipHistory is true then the command will not be automatically added to the widget's history.

Since
QGIS 3.30

Definition at line 835 of file qgscodeeditor.cpp.

◆ runPostLexerConfigurationTasks()

void QgsCodeEditor::runPostLexerConfigurationTasks ( )
protected

Performs tasks which must be run after a lexer has been set for the widget.

Since
QGIS 3.16

Definition at line 430 of file qgscodeeditor.cpp.

◆ selectionEnd()

int QgsCodeEditor::selectionEnd ( ) const

Convenience function to return the end of the selection as a linear index Contrary to the getSelection method, this method returns the cursor position if no selection is made.

Since
QGIS 3.36

Definition at line 1187 of file qgscodeeditor.cpp.

◆ selectionStart()

int QgsCodeEditor::selectionStart ( ) const

Convenience function to return the start of the selection as a linear index Contrary to the getSelection method, this method returns the cursor position if no selection is made.

Since
QGIS 3.36

Definition at line 1176 of file qgscodeeditor.cpp.

◆ sessionHistoryCleared

void QgsCodeEditor::sessionHistoryCleared ( )
signal

Emitted when the history of commands run in the current session is cleared.

Since
QGIS 3.30

◆ setColor()

void QgsCodeEditor::setColor ( QgsCodeEditorColorScheme::ColorRole  role,
const QColor &  color 
)
static

Sets the color to use in the editor for the specified role.

This color will be stored as the new default color for the role, to be used for all code editors.

Set color to an invalid QColor in order to clear the stored color value and reset it to the default color.

See also
color()
Since
QGIS 3.16

Definition at line 1038 of file qgscodeeditor.cpp.

◆ setCustomAppearance()

void QgsCodeEditor::setCustomAppearance ( const QString &  scheme = QString(),
const QMap< QgsCodeEditorColorScheme::ColorRole, QColor > &  customColors = QMap< QgsCodeEditorColorScheme::ColorRole, QColor >(),
const QString &  fontFamily = QString(),
int  fontSize = 0 
)

Sets a custom appearance for the widget, disconnecting it from using the standard appearance taken from QSettings.

Note
Not available in Python bindings
Since
QGIS 3.16

Definition at line 1089 of file qgscodeeditor.cpp.

◆ setFoldingVisible()

void QgsCodeEditor::setFoldingVisible ( bool  folding)

Set whether the folding controls are visible in the editor.

See also
foldingVisible()

Definition at line 599 of file qgscodeeditor.cpp.

◆ setHistoryFilePath()

void QgsCodeEditor::setHistoryFilePath ( const QString &  path)

Sets the file path to use for recording and retrieving previously executed commands.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 1136 of file qgscodeeditor.cpp.

◆ setInterpreter()

void QgsCodeEditor::setInterpreter ( QgsCodeInterpreter newInterpreter)

Sets an attached code interpreter for executing commands when the editor is in the QgsCodeEditor::Mode::CommandInput mode.

See also
interpreter()
Since
QGIS 3.30

Definition at line 732 of file qgscodeeditor.cpp.

◆ setLinearPosition()

void QgsCodeEditor::setLinearPosition ( int  position)

Convenience function to set the cursor position as a linear index.

Since
QGIS 3.36

Definition at line 1169 of file qgscodeeditor.cpp.

◆ setLinearSelection()

void QgsCodeEditor::setLinearSelection ( int  start,
int  end 
)

Convenience function to set the selection using linear indexes.

Since
QGIS 3.36

Definition at line 1198 of file qgscodeeditor.cpp.

◆ setLineNumbersVisible()

void QgsCodeEditor::setLineNumbersVisible ( bool  visible)

Sets whether line numbers should be visible in the editor.

Defaults to false.

See also
lineNumbersVisible()
Since
QGIS 3.16

Definition at line 575 of file qgscodeeditor.cpp.

◆ setMarginVisible()

void QgsCodeEditor::setMarginVisible ( bool  margin)

Set margin visible state.

Parameters
marginSet margin in the editor
Deprecated:
QGIS 3.40. Use base class methods for individual margins instead, or setLineNumbersVisible().

Definition at line 554 of file qgscodeeditor.cpp.

◆ setTitle()

void QgsCodeEditor::setTitle ( const QString &  title)

Set the widget title.

Parameters
titlewidget title

Definition at line 509 of file qgscodeeditor.cpp.

◆ showHistory

void QgsCodeEditor::showHistory ( )
slot

Shows the command history dialog.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 915 of file qgscodeeditor.cpp.

◆ showMessage()

void QgsCodeEditor::showMessage ( const QString &  title,
const QString &  message,
Qgis::MessageLevel  level 
)
protectedvirtual

Shows a user facing message (eg a warning message).

The default implementation uses QMessageBox.

Since
QGIS 3.32

Definition at line 698 of file qgscodeeditor.cpp.

◆ showNextCommand

void QgsCodeEditor::showNextCommand ( )
slot

Shows the next command from the session in the editor.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 905 of file qgscodeeditor.cpp.

◆ showPreviousCommand

void QgsCodeEditor::showPreviousCommand ( )
slot

Shows the previous command from the session in the editor.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 895 of file qgscodeeditor.cpp.

◆ toggleComment

void QgsCodeEditor::toggleComment ( )
virtualslot

Toggle comment for the selected text.

This is only supported for editors which return the Qgis::ScriptLanguageCapability::ToggleComment capability from languageCapabilities().

Since
QGIS 3.32

Definition at line 825 of file qgscodeeditor.cpp.

◆ updatePrompt()

void QgsCodeEditor::updatePrompt ( )
protected

Triggers an update of the interactive prompt part of the editor.

Note
Applies to code editors in the QgsCodeEditor::Mode::CommandInput mode only.
Since
QGIS 3.30

Definition at line 718 of file qgscodeeditor.cpp.

◆ updateSoftHistory()

void QgsCodeEditor::updateSoftHistory ( )
protected

Updates the soft history by storing the current editor text in the history.

Since
QGIS 3.30

Definition at line 666 of file qgscodeeditor.cpp.

◆ wrapPosition()

int QgsCodeEditor::wrapPosition ( int  line = -1)

Returns the linear position of the start of the last wrapped part for the specified line, or for the current line if line = -1 If wrapping is disabled, returns -1 instead.

Since
QGIS 3.40

Definition at line 1215 of file qgscodeeditor.cpp.

◆ writeHistoryFile

bool QgsCodeEditor::writeHistoryFile ( )
slot

Stores the commands executed in the editor to the persistent history file.

Since
QGIS 3.30

Definition at line 873 of file qgscodeeditor.cpp.

Member Data Documentation

◆ SEARCH_RESULT_INDICATOR

constexpr int QgsCodeEditor::SEARCH_RESULT_INDICATOR = QsciScintilla::INDIC_MAX - 1
staticconstexpr

Indicator index for search results.

Definition at line 163 of file qgscodeeditor.h.

◆ settingContextHelpHover

const QgsSettingsEntryBool* QgsCodeEditor::settingContextHelpHover
static

Definition at line 111 of file qgscodeeditor.h.

◆ sTreeCodeEditor

QgsSettingsTreeNode* QgsCodeEditor::sTreeCodeEditor = QgsSettingsTree::sTreeGui->createChildNode( QStringLiteral( "code-editor" ) )
inlinestatic

Definition at line 110 of file qgscodeeditor.h.


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