17#ifndef QGSCODEEDITOR_H
18#define QGSCODEEDITOR_H
28#include <Qsci/qsciapis.h>
56 int exec(
const QString &command );
144 CodeFolding = 1 << 0,
145 ImmediatelyUpdateHistory = 1 << 1,
176 void setTitle( const QString &title );
220 void setLineNumbersVisible(
bool visible );
228 bool lineNumbersVisible()
const;
234 void setFoldingVisible(
bool folding );
240 bool foldingVisible();
247 void insertText(
const QString &text );
291 static QFont getMonospaceFont();
300 void setCustomAppearance(
const QString &scheme = QString(),
const QMap<QgsCodeEditorColorScheme::ColorRole, QColor> &customColors = QMap<QgsCodeEditorColorScheme::ColorRole, QColor>(),
const QString &fontFamily = QString(),
int fontSize = 0 )
SIP_SKIP;
308 void addWarning(
int lineNumber, const QString &warning );
316 void clearWarnings();
330 bool isCursorOnLastLine()
const;
340 void setHistoryFilePath(
const QString &path );
349 QStringList history()
const;
373 int linearPosition()
const;
380 void setLinearPosition(
int position );
389 int selectionStart()
const;
398 int selectionEnd()
const;
405 void setLinearSelection(
int start,
int end );
408 void callTip()
override;
417 int wrapPosition(
int line = -1 );
428 int editingTimeoutInterval()
const;
443 void runCommand(
const QString &command,
bool skipHistory =
false );
451 virtual void moveCursorToStart();
459 virtual void moveCursorToEnd();
468 void showPreviousCommand();
477 void showNextCommand();
493 void removeHistoryCommand(
int index );
502 void clearSessionHistory();
511 void clearPersistentHistory();
518 bool writeHistoryFile();
536 virtual bool checkSyntax();
545 virtual void toggleComment();
552 void adjustScrollWidth();
555 void setText(
const QString &text )
override;
566 void setEditingTimeoutInterval(
int timeout );
701 void onLastEditTimeout();
705 void updateFolding();
706 bool readHistoryFile();
707 void syncSoftHistory();
708 void updateHistory(
const QStringList &commands,
bool skipSoftHistory =
false );
709 char getCharacter(
int &pos )
const;
711 QString mWidgetTitle;
712 bool mMargin =
false;
716 bool mUseDefaultSettings =
true;
718 bool mOverrideColors =
false;
719 QString mColorScheme;
720 QMap<QgsCodeEditorColorScheme::ColorRole, QColor> mCustomColors;
724 QVector<int> mWarningLines;
727 QStringList mHistory;
728 QStringList mSoftHistory;
729 int mSoftHistoryIndex = 0;
730 QString mHistoryFilePath;
734 static QMap<QgsCodeEditorColorScheme::ColorRole, QString> sColorRoleToSettingsKey;
736 static constexpr int MARKER_NUMBER = 6;
738 QTimer *mLastEditTimer =
nullptr;
Provides global constants and enumerations for use throughout the application.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
bool eventFilter(QObject *watched, QEvent *event) override
void sessionHistoryCleared()
Emitted when the history of commands run in the current session is cleared.
static const QgsSettingsEntryBool * settingContextHelpHover
QgsCodeEditor::Mode mode() const
Returns the code editor mode.
@ ScriptEditor
Standard mode, allows for display and edit of entire scripts.
void contextMenuEvent(QContextMenuEvent *event) override
static constexpr int SEARCH_RESULT_INDICATOR
Indicator index for search results.
void keyPressEvent(QKeyEvent *event) override
virtual void populateContextMenu(QMenu *menu)
Called when the context menu for the widget is about to be shown, after it has been fully populated w...
QFlags< Flag > Flags
Flags controlling behavior of code editor.
void persistentHistoryCleared()
Emitted when the persistent history of commands run in the editor is cleared.
static QgsSettingsTreeNode * sTreeCodeEditor
virtual Qgis::ScriptLanguageCapabilities languageCapabilities() const
Returns the associated scripting language capabilities.
void runPostLexerConfigurationTasks()
Performs tasks which must be run after a lexer has been set for the widget.
bool event(QEvent *event) override
virtual void showMessage(const QString &title, const QString &message, Qgis::MessageLevel level)
Shows a user facing message (eg a warning message).
virtual void initializeLexer()
Called when the dialect specific code lexer needs to be initialized (or reinitialized).
void setTitle(const QString &title)
Set the widget title.
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 focusOutEvent(QFocusEvent *event) override
Flag
Flags controlling behavior of code editor.
void helpRequested(const QString &word)
Emitted when documentation was requested for the specified word.
static bool isFixedPitch(const QFont &font)
Returns true if a font is a fixed pitch font.
void updateSoftHistory()
Updates the soft history by storing the current editor text in the history.
Q_DECL_DEPRECATED bool marginVisible()
Returns whether margins are in a visible state.
static QString languageToString(Qgis::ScriptLanguage language)
Returns a user-friendly, translated name of the specified script language.
virtual Qgis::ScriptLanguage language() const
Returns the associated scripting language.
QFont lexerFont() const
Returns the font to use in the lexer.
void toggleLineComments(const QString &commentPrefix)
Toggles comment for selected lines with the given comment prefix.
virtual QString reformatCodeString(const QString &string)
Applies code reformatting to a string and returns the result.
QColor lexerColor(QgsCodeEditorColorScheme::ColorRole role) const
Returns the color to use in the lexer for the specified role.
Q_DECL_DEPRECATED void setMarginVisible(bool margin)
Set margin visible state.
void updatePrompt()
Triggers an update of the interactive prompt part of the editor.
void editingTimeout()
Emitted when either:
An interface for code interpreters.
virtual int execCommandImpl(const QString &command)=0
Pure virtual method for executing commands in the interpreter.
virtual int currentState() const
Returns the current interpreter state.
virtual QString promptForState(int state) const =0
Returns the interactive prompt string to use for the interpreter, given a state.
int exec(const QString &command)
Executes a command in the interpreter.
virtual ~QgsCodeInterpreter()
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A boolean settings entry.
A tree node for the settings tree to help organizing and introspecting the tree.
static QgsSettingsTreeNode * sTreeGui
#define SIP_IF_MODULE(condition)
#define SIP_ENUM_BASETYPE(type)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)