| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
асть SASM. |
| 23 |
|
| 24 |
ерераспространять ее и/или |
| 25 |
ественной лицензии GNU в том виде, |
| 26 |
бодного программного обеспечения; |
| 27 |
у выбору) любой более поздней |
| 28 |
ии. |
| 29 |
|
| 30 |
что она будет полезной, |
| 31 |
явной гарантии ТОВАРНОГО ВИДА |
| 32 |
ЕЙ. Подробнее см. в Стандартной |
| 33 |
ицензии GNU. |
| 34 |
|
| 35 |
ртной общественной лицензии GNU |
| 36 |
Если это не так, см. |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifndef CODEEDITOR_H |
| 42 |
#define CODEEDITOR_H |
| 43 |
|
| 44 |
#include <QPainter> |
| 45 |
#include <QTextBlock> |
| 46 |
#include <QScrollBar> |
| 47 |
#include <QDragEnterEvent> |
| 48 |
#include <QDropEvent> |
| 49 |
#include <QMimeData> |
| 50 |
#include "ruqplaintextedit.h" |
| 51 |
#include <QUrl> |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
QT_BEGIN_NAMESPACE |
| 59 |
class QPaintEvent; |
| 60 |
class QResizeEvent; |
| 61 |
class QSize; |
| 62 |
class QWidget; |
| 63 |
QT_END_NAMESPACE |
| 64 |
|
| 65 |
class LineNumberArea; |
| 66 |
|
| 67 |
|
| 68 |
class CodeEditor : public RuQPlainTextEdit |
| 69 |
{ |
| 70 |
Q_OBJECT |
| 71 |
|
| 72 |
public: |
| 73 |
CodeEditor(QWidget *parent = 0, bool withBeakpoints = true); |
| 74 |
~CodeEditor(); |
| 75 |
|
| 76 |
void lineNumberAreaPaintEvent(QPaintEvent *event); |
| 77 |
void lineNumberAreaMousePressEvent(QMouseEvent *event); |
| 78 |
int lineNumberAreaWidth(); |
| 79 |
void repaintLineNumberArea(); |
| 80 |
bool isMacroOnCurrentDebugLine(); |
| 81 |
int currentDebugLine; |
| 82 |
bool debugMode; |
| 83 |
|
| 84 |
public slots: |
| 85 |
void updateDebugLine(int number); |
| 86 |
void putTab(); |
| 87 |
void deleteTab(); |
| 88 |
void highlightCurrentLine(); |
| 89 |
void highlightDebugLine(int lineNumber, bool moveCursor); |
| 90 |
void setDebugMode(bool mode); |
| 91 |
QList<int> *getBreakpoints(); |
| 92 |
void setBreakpointOnCurrentLine(); |
| 93 |
|
| 94 |
protected: |
| 95 |
void resizeEvent(QResizeEvent *event); |
| 96 |
void keyPressEvent(QKeyEvent *e); |
| 97 |
|
| 98 |
void dragEnterEvent(QDragEnterEvent *event); |
| 99 |
void dropEvent(QDropEvent *event); |
| 100 |
|
| 101 |
private slots: |
| 102 |
void updateLineNumberAreaWidth(int newBlockCount); |
| 103 |
void updateLineNumberArea(const QRect &, int); |
| 104 |
void shiftBreakpoints(int blockCount); |
| 105 |
|
| 106 |
private: |
| 107 |
QWidget *lineNumberArea; |
| 108 |
int debugAreaWidth; |
| 109 |
QPixmap debugImage; |
| 110 |
QPixmap breakpointImage; |
| 111 |
|
| 112 |
QList<int> breakpoints; |
| 113 |
int firstTopMargin; |
| 114 |
bool hasBreakpoints; |
| 115 |
int prevBlockCount; |
| 116 |
QSettings settings; |
| 117 |
QColor lineNumberPanelColor; |
| 118 |
|
| 119 |
signals: |
| 120 |
void breakpointsChanged(quint64 lineNumber, bool isAdded); |
| 121 |
void fileOpened(QString path); |
| 122 |
}; |
| 123 |
|
| 124 |
|
| 125 |
class LineNumberArea : public QWidget |
| 126 |
{ |
| 127 |
public: |
| 128 |
LineNumberArea(CodeEditor *editor) : QWidget(editor) { |
| 129 |
codeEditor = editor; |
| 130 |
} |
| 131 |
|
| 132 |
QSize sizeHint() const { |
| 133 |
return QSize(codeEditor->lineNumberAreaWidth(), 0); |
| 134 |
} |
| 135 |
|
| 136 |
protected: |
| 137 |
void paintEvent(QPaintEvent *event) { |
| 138 |
codeEditor->lineNumberAreaPaintEvent(event); |
| 139 |
} |
| 140 |
void mousePressEvent(QMouseEvent *event) { |
| 141 |
codeEditor->lineNumberAreaMousePressEvent(event); |
| 142 |
} |
| 143 |
|
| 144 |
private: |
| 145 |
CodeEditor *codeEditor; |
| 146 |
}; |
| 147 |
|
| 148 |
#endif |