| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef DOCUMENTVIEW_H |
| 24 |
#define DOCUMENTVIEW_H |
| 25 |
|
| 26 |
#include <QtWidgets> |
| 27 |
#include <QtPrintSupport/QPrinter> |
| 28 |
#include <QtPrintSupport/QPrintDialog> |
| 29 |
|
| 30 |
#include "baseview.h" |
| 31 |
|
| 32 |
#include <QKeyEvent> |
| 33 |
#include <QPair> |
| 34 |
|
| 35 |
class MySyntaxMenu: public QMenu |
| 36 |
{ |
| 37 |
Q_OBJECT |
| 38 |
public: |
| 39 |
MySyntaxMenu(QWidget * parent); |
| 40 |
~MySyntaxMenu(); |
| 41 |
|
| 42 |
bool insertComplete; |
| 43 |
|
| 44 |
protected: |
| 45 |
virtual void keyPressEvent(QKeyEvent * event); |
| 46 |
|
| 47 |
signals: |
| 48 |
void keyPressed(QString text); |
| 49 |
}; |
| 50 |
|
| 51 |
class HoverWidget : |
| 52 |
public QWidget |
| 53 |
{ |
| 54 |
Q_OBJECT |
| 55 |
public: |
| 56 |
HoverWidget(QWidget *parent); |
| 57 |
~HoverWidget() {} |
| 58 |
|
| 59 |
protected: |
| 60 |
void mousePressEvent(QMouseEvent *ev); |
| 61 |
|
| 62 |
}; |
| 63 |
|
| 64 |
class DocumentView : public BaseView |
| 65 |
{ |
| 66 |
Q_OBJECT |
| 67 |
public: |
| 68 |
DocumentView(QWidget * parent, OpEntryParser *opcodeTree = 0); |
| 69 |
~DocumentView(); |
| 70 |
|
| 71 |
void insertText(QString text, int section = -1); |
| 72 |
void setAutoComplete(bool autoComplete, int delay = 0); |
| 73 |
void setAutoParameterMode(bool autoParameterMode); |
| 74 |
void setViewMode(int mode); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
QString getSelectedText(int section = -1); |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
QString getMacWidgetsText(); |
| 84 |
QString getWidgetsText(); |
| 85 |
int getViewMode(); |
| 86 |
|
| 87 |
QString wordUnderCursor(); |
| 88 |
QString lineUnderCursor(); |
| 89 |
QString getActiveSection(); |
| 90 |
QString getActiveText(); |
| 91 |
int currentLineNumber(); |
| 92 |
bool isModified(); |
| 93 |
bool childHasFocus(); |
| 94 |
void print(QPrinter *printer); |
| 95 |
|
| 96 |
|
| 97 |
bool matchLeftParenthesis(QTextBlock currentBlock, int i, int numLeftParentheses); |
| 98 |
bool matchRightParenthesis(QTextBlock currentBlock, int index, int numRightParentheses); |
| 99 |
void createParenthesisSelection(int pos, bool paired=true); |
| 100 |
void setParsedUDOs(QStringList udos); |
| 101 |
Highlighter* getHighlighter() { return &m_highlighter; } |
| 102 |
void gotoLineDialog(); |
| 103 |
void markCurrentPosition(); |
| 104 |
const QStringList getAllWords(); |
| 105 |
|
| 106 |
|
| 107 |
public slots: |
| 108 |
void setModified(bool mod = true); |
| 109 |
void syntaxCheck(); |
| 110 |
void textChanged(); |
| 111 |
void escapePressed(); |
| 112 |
void finishParameterMode(); |
| 113 |
void exitParameterMode(); |
| 114 |
void indentNewLine(); |
| 115 |
void findReplace(); |
| 116 |
void getToIn(); |
| 117 |
void inToGet(); |
| 118 |
void insertAutoCompleteText(); |
| 119 |
void findString(QString query = QString()); |
| 120 |
void evaluate(); |
| 121 |
void updateContext(); |
| 122 |
void updateOrcContext(QString orc); |
| 123 |
void nextParameter(); |
| 124 |
void prevParameter(); |
| 125 |
void showHoverText(); |
| 126 |
void hideHoverText(); |
| 127 |
void updateHoverText(int x, int y, QString text); |
| 128 |
void createContextMenu(QPoint pos); |
| 129 |
void autoCompleteAtCursor(); |
| 130 |
|
| 131 |
void showOrc(bool); |
| 132 |
void showScore(bool); |
| 133 |
void showOptions(bool); |
| 134 |
void showFileB(bool); |
| 135 |
void showOther(bool); |
| 136 |
void showOtherCsd(bool); |
| 137 |
void showWidgetEdit(bool); |
| 138 |
void showAppEdit(bool); |
| 139 |
|
| 140 |
void cut(); |
| 141 |
void copy(); |
| 142 |
void paste(); |
| 143 |
void undo(); |
| 144 |
void redo(); |
| 145 |
void comment(); |
| 146 |
void uncomment(); |
| 147 |
void indent(); |
| 148 |
void unindent(); |
| 149 |
void killLine(); |
| 150 |
void killToEnd(); |
| 151 |
|
| 152 |
void markErrorLines(QList<QPair<int, QString> > lines); |
| 153 |
void unmarkErrorLines(); |
| 154 |
void jumpToLine(int line, bool mark=true); |
| 155 |
void goBackToPreviousPosition(); |
| 156 |
void gotoNextLine(); |
| 157 |
void opcodeFromMenu(); |
| 158 |
|
| 159 |
|
| 160 |
void insertChn_k(QString channel); |
| 161 |
|
| 162 |
|
| 163 |
protected: |
| 164 |
virtual void contextMenuEvent(QContextMenuEvent *event); |
| 165 |
|
| 166 |
private: |
| 167 |
QString changeToChnget(QString text); |
| 168 |
QString changeToInvalue(QString text); |
| 169 |
|
| 170 |
MySyntaxMenu *syntaxMenu; |
| 171 |
|
| 172 |
HoverWidget *m_hoverWidget; |
| 173 |
QLabel *m_hoverText; |
| 174 |
QString m_currentOpcodeText; |
| 175 |
|
| 176 |
|
| 177 |
bool m_isModified; |
| 178 |
bool m_autoComplete; |
| 179 |
int m_autoCompleteDelay = 150; |
| 180 |
QTimer* m_autoCompleteTimer = nullptr; |
| 181 |
bool m_autoParameterMode; |
| 182 |
bool errorMarked; |
| 183 |
bool internalChange; |
| 184 |
QTextEdit * m_currentEditor; |
| 185 |
|
| 186 |
bool lastCaseSensitive; |
| 187 |
QString lastSearch; |
| 188 |
QString lastReplace; |
| 189 |
QStringList m_localVariables; |
| 190 |
QStringList m_globalVariables; |
| 191 |
QTime m_lastWordsUpdate; |
| 192 |
QStringList m_allWords; |
| 193 |
int m_lastCursorPosition; |
| 194 |
QStringList m_longOptions = { |
| 195 |
"syntax-check-only", "control-rate=", "messagelevel=", |
| 196 |
"env:", "dither", "sched", "omacro:", "smacro:", |
| 197 |
"verbose", "sample-accurate", "realtime", |
| 198 |
"nchnls=", "nchnls_i=", "sinesize", "daemon", |
| 199 |
"port=", "use-system-sr", "ksmps=", |
| 200 |
"limiter", "udp-echo", "opcode-dir=" |
| 201 |
}; |
| 202 |
QStringList m_longOptions2 = {"rtmidi", "rtaudio"}; |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
QList<int> cursorPositions; |
| 207 |
|
| 208 |
enum { |
| 209 |
ORC_CONTEXT = 0, |
| 210 |
SCO_CONTEXT, |
| 211 |
OPTIONS_CONTEXT, |
| 212 |
PYTHON_CONTEXT, |
| 213 |
NO_CONTEXT |
| 214 |
}; |
| 215 |
int m_currentContext; |
| 216 |
int m_oldCursorPosition; |
| 217 |
|
| 218 |
private slots: |
| 219 |
void destroySyntaxMenu(); |
| 220 |
void opcodeHelp(); |
| 221 |
void restoreCursorPosition(); |
| 222 |
|
| 223 |
signals: |
| 224 |
void opcodeSyntaxSignal(QString syntax); |
| 225 |
void setHelp(); |
| 226 |
void contentsChanged(); |
| 227 |
void closeExtraPanels(); |
| 228 |
void evaluate(QString code); |
| 229 |
void newLineAndColumn(int line, int column); |
| 230 |
|
| 231 |
}; |
| 232 |
|
| 233 |
#endif |