1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
|
/*
* Copyright (c) 2002-2006 Samit Basu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __Editor_hpp__
#define __Editor_hpp__
#include <QTextDocument>
#include <QTextEdit>
#include <QMainWindow>
#include <QTabWidget>
#include <QLabel>
#include <QComboBox>
#include <QDialog>
#include <QCheckBox>
#include <QGroupBox>
#include "highlighter.hpp"
#include "findform.ui.h"
#include "replaceform.ui.h"
#include "Interpreter.hpp"
#include "synlightconf.ui.h"
#include "indentconf.ui.h"
#include "Context.hpp"
class FMFindDialog : public QDialog {
Q_OBJECT
public:
FMFindDialog(QWidget *parent = 0);
void found();
void notfound();
void setFindText(QString text);
signals:
void doFind(QString text, bool backwards, bool sensitive);
private slots:
void find();
private:
Ui::FMFindDialog ui;
};
class FMReplaceDialog : public QDialog {
Q_OBJECT
public:
FMReplaceDialog(QWidget *parent = 0);
void setReplaceText(QString text);
void found();
void notfound();
void showrepcount(int cnt);
signals:
void doFind(QString text, bool backwards, bool sensitive);
void doReplace(QString text, QString replace, bool backwards,
bool sensitive);
void doReplaceAll(QString text, QString replace, bool backwards,
bool sensitive);
private slots:
void replace();
void replaceAll();
void find();
private:
Ui::FMReplaceDialog ui;
};
class FMTextEdit : public QTextEdit {
Q_OBJECT
int indentSize;
bool indentActive;
bool matchActive;
long matchingBegin, matchingEnd;
QColor matchingColor;
QString plainText, simpleCodes;
QString Key, matchKey;
public:
FMTextEdit();
virtual ~FMTextEdit();
void keyPressEvent(QKeyEvent *e);
bool findmatch();
int priorMatchedKeyWordPosition();
void paintEvent(QPaintEvent *event);
void contextMenuEvent(QContextMenuEvent *e);
void comment();
void uncomment();
void increaseIndent();
void decreaseIndent();
void smartIndent();
bool replace(QString text, QString replace, QTextDocument::FindFlags flags);
int replaceAll(QString text, QString replace, QTextDocument::FindFlags flags);
void fontUpdate();
QTextCursor getLineCursor( int lineNumber ) const;
protected:
bool event(QEvent *event);
private slots:
void slotCursorOrTextChanged();
void setMatchBracket(bool flag);
void gotoLine(int lineNumber);
signals:
void indent();
void smart_Indent();
void showDataTips(QPoint pos, QString textSelected);
};
class FMIndent : public QObject {
Q_OBJECT
FMTextEdit *m_te;
int indentSize;
public:
FMIndent();
virtual ~FMIndent();
void setDocument(FMTextEdit *te);
FMTextEdit *document() const;
private slots:
void update();
void updateSelection();
};
class FMEditPane;
class BreakPointIndicator : public QWidget {
Q_OBJECT
public:
BreakPointIndicator(FMTextEdit *editor, FMEditPane* pane);
protected:
virtual void paintEvent(QPaintEvent *);
virtual void mousePressEvent(QMouseEvent *);
// virtual void mouseReleaseEvent(QMouseEvent *);
private:
FMTextEdit *tEditor;
FMEditPane *tPane;
};
class FMLineNumber : public QWidget {
Q_OBJECT
public:
FMLineNumber(FMTextEdit *editor);
protected:
virtual void paintEvent(QPaintEvent *);
private:
FMTextEdit *tEditor;
};
class FMEditPane : public QWidget {
Q_OBJECT
FMTextEdit *tEditor;
QString curFile;
int curLine;
Interpreter *m_eval;
public:
FMEditPane(Interpreter* eval);
FMTextEdit* getEditor();
void setFileName(QString filename);
QString getFileName();
int getLineNumber();
Interpreter* getInterpreter();
void setCurrentLine(int n);
int currentLine();
signals:
void gotoLine(int lineNumber);
};
class FMIndentConf : public QDialog {
Q_OBJECT
public:
FMIndentConf(QWidget *parent = 0);
private slots:
void save();
private:
Ui::FMIndentConf ui;
};
class FMSynLightConf : public QDialog {
Q_OBJECT
public:
FMSynLightConf(QWidget *parent = 0);
private slots:
void setKeywordColor();
void setCommentColor();
void setStringColor();
void setUntermStringColor();
void save();
private:
void setLabelColor(QLabel *l, QColor c);
QColor getColor(QLabel *l);
void querySetLabelColor(QLabel *l);
Ui::FMSynLightConf ui;
};
class FMEditor : public QMainWindow {
Q_OBJECT
QMenu *fileMenu, *editMenu, *toolsMenu, *debugMenu, *helpMenu;
QToolBar *editToolBar, *fileToolBar, *debugToolBar;
QAction *newAct, *saveAct, *quitAct, *copyAct, *pasteAct;
QAction *cutAct, *fontAct, *openAct, *saveAsAct, *closeAct, *closeAllAct;
QAction *openNewAct, *findAct, *replaceAct, *commentAct, *uncommentAct;
QAction *increaseIndentAct, *decreaseIndentAct, *smartIndentAct;
QAction *helpWinAct, *helpOnSelectionAct, *openSelectionAct;
QAction *dbStepAct, *dbTraceAct, *dbContinueAct;
QAction *dbSetClearBPAct, *dbStopAct;
QAction *redoAct, *undoAct, *colorConfigAct, *indentConfigAct;
QAction *executeSelectionAct, *executeCurrentAct;
QAction *separatorAct;
enum { MaxRecentFiles = 5 };
QAction *recentFileActs[MaxRecentFiles];
QAction *dataTipConfigAct;
QAction *bracketMatchConfigAct;
QAction *saveBeforeRunConfigAct;
QAction *saveLastSessionConfigAct;
QTabWidget *tab;
FMTextEdit *prevEdit;
QFont m_font;
FMFindDialog *m_find;
FMReplaceDialog *m_replace;
QMenu *m_popup;
Interpreter *m_eval;
QMap<QString, QString> varTips;
bool isShowToolTip;
bool isMatchBracket;
bool isSaveBeforeRun;
bool isSaveLastSession;
QStringList lastSessionList;
QStringList pathList;
public:
FMEditor(Interpreter* eval);
virtual ~FMEditor();
void loadFile(const QString& filename);
void loadOrCreateFile(const QString& filename);
QString getFullFileName(QString fname);
void loadLastSession();
private:
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
bool maybeSave();
bool saveFile(const QString& filename);
void setCurrentFile(const QString& filename);
QString strippedName(const QString& fullfilename);
FMTextEdit *currentEditor();
FMEditPane *currentPane();
void setCurrentFilename(QString filename);
QString currentFilename();
QString shownName();
QString shownPath();
void updateTitles();
void readSettings();
void writeSettings();
void updateFont();
void updateRecentFileActions();
bool isFileOpened(const QString &fileName);
signals:
void EvaluateText(QString);
void setMatchBracket(bool flag);
void checkEditorExist(bool isExist);
protected:
void contextMenuEvent(QContextMenuEvent *e);
private slots:
bool save();
bool saveAs();
void open();
void font();
void addTab();
void closeTab();
void closeAllTabs();
void tabChanged(int);
void documentWasModified();
void find();
void replace();
void doFind(QString text, bool backwards, bool sensitive);
void doReplace(QString text, QString replace,
bool backwards, bool sensitive);
void doReplaceAll(QString text, QString replace,
bool backwards, bool sensitive);
void comment();
void uncomment();
void increaseIndent();
void decreaseIndent();
void smartIndent();
void undo();
void redo();
void RefreshBPLists();
void IllegalLineOrCurrentPath(QString name, int line);
void dbstep();
void dbtrace();
void dbcontinue();
void dbsetclearbp();
void dbstop();
void configcolors();
void configindent();
void execSelected();
void execCurrent();
void openRecentFile();
void showDataTips(QPoint pos, QString textSelected);
void configDataTip();
void configBracketMatch();
void configSaveBeforeRun();
void configSaveLastSession();
void helpWin();
void helpOnSelection();
void openSelection();
public:
void closeEvent(QCloseEvent *event);
void addTabIfEmpty();
void addTabUntitled();
public slots:
void ShowActiveLine(QString name, int line);
void updateVarView(QVariant);
};
#endif
|