Move codeeditor to folder
This commit is contained in:
parent
91ac77a058
commit
d266882927
5 changed files with 4 additions and 4 deletions
55
pglab/codeeditor/CodeEditor.h
Normal file
55
pglab/codeeditor/CodeEditor.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef CODEEDITOR_H
|
||||
#define CODEEDITOR_H
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <set>
|
||||
|
||||
/** This class adds some capabilities to QPlainTextEdit that are useful
|
||||
* in code editor scenarios.
|
||||
*/
|
||||
class CodeEditor : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CodeEditor(QWidget *parent = nullptr);
|
||||
|
||||
void gutterAreaPaintEvent(QPaintEvent *event);
|
||||
int gutterAreaWidth();
|
||||
|
||||
void addErrorMarker(int position, int length);
|
||||
void clearErrorMarkers();
|
||||
void setFont(const QFont &);
|
||||
void setTabSize(int chars);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void updateGutterAreaWidth(int newBlockCount);
|
||||
void highlightCurrentLine();
|
||||
void updateGutterArea(const QRect &, int);
|
||||
void onTextChanged();
|
||||
|
||||
|
||||
private:
|
||||
QWidget *gutterArea;
|
||||
|
||||
QTextEdit::ExtraSelection currentLine;
|
||||
QList<QTextEdit::ExtraSelection> errorMarkers;
|
||||
|
||||
std::set<int> errorLines;
|
||||
|
||||
// Settings
|
||||
int m_tabSize = 0; // tabSize in characters
|
||||
bool m_useTab = false;
|
||||
|
||||
void updateExtraSelections();
|
||||
bool indentSelection(bool indent);
|
||||
|
||||
};
|
||||
|
||||
#endif // CODEEDITOR_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue