00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CUTEVIEW_H__
00019 #define __CUTEVIEW_H__
00020
00021
00022 #include <qextmdichildview.h>
00023
00024 #include <qextscintilla.h>
00025 #include <qextscintillamacro.h>
00026 #include <qcolor.h>
00027 #include <qfile.h>
00028 #include <qaction.h>
00029 #include <qmap.h>
00030 #include <qprocess.h>
00031
00032 #include <list>
00033
00034 class CUTEScintilla;
00035 namespace Config{ class Lexer; }
00036
00038 class ScintillaAction
00039 {
00040 public:
00041 ScintillaAction(unsigned int msg, unsigned long wParam, long lParam);
00042 ScintillaAction(const ScintillaAction& a);
00043 ~ScintillaAction(){
00044 delete[] lParam;
00045 }
00046 unsigned int msg;
00047 unsigned long wParam;
00048 char *lParam;
00049 ScintillaAction &operator=(const ScintillaAction& a);
00050 };
00051
00055 class CUTEView : public QextMdiChildView
00056 {
00057 Q_OBJECT
00058 public:
00059 enum { CUTE_MARGIN = 0, CUTE_LINENUMBER_MARGIN = 1, CUTE_FOLD_MARGIN = 2 };
00060 CUTEView(QWidget *parent=0, QString title = "Document");
00061 ~CUTEView();
00063 void configure();
00065 void sendEditor(unsigned int msg, unsigned long wParam=0, long lParam=0);
00067 bool loadFile(const char *file);
00069 bool reloadFile();
00071 bool saveFile(const char *file=0, bool force=false);
00073 void toggleBookmark(int line);
00075 void addError(int line );
00077 void deleteAllErrors();
00079 void findNextBookmark();
00081 void findPrevBookmark();
00083 void insertCommand(QString);
00085 void filter(QString);
00087 void startMacroRecording();
00089 void stopMacroRecording();
00091 void runMacro();
00093 void loadMacro(QString &file);
00095 void saveMacro(QString &file);
00097 bool setMacro(QString);
00099 QString macroString();
00101 bool findFirst(const QString &expr, bool re=false, bool cs=false, bool wo=false, bool wrap=true, bool forward=TRUE, int line=-1, int index=-1);
00103 bool findNext();
00105 bool findPrev();
00107 QString line(int);
00109 void setupLexer(const QString&);
00111 void replaceAll(const QString &expr, const QString &replaceStr, bool re, bool cs, bool wo, bool wrap, bool forward=TRUE, bool confirm=false);
00113 bool edited();
00115 bool canUndo();
00117 bool canRedo();
00119 void undo();
00121 void redo();
00123 QextScintilla* scintilla();
00125 void setActions(QMap<int, QAction*>);
00127 char *fileName() { return filename; }
00129 Config::Lexer *lexer() { return _lexer; }
00131 void setLexer( Config::Lexer *l ) { _lexer = l; }
00132 protected:
00134 void closeEvent(QCloseEvent *e);
00136 void removeAllBookmarks();
00137 protected slots:
00139 void slotDocumentChanged();
00141 void slotMarginClicked(int margin, int line, Qt::ButtonState state);
00143 void insertStdout();
00145 void processExited();
00147 void recordMacro(unsigned int, unsigned long, long);
00149 void slotCharAdded(int);
00150 signals:
00151 void save();
00152 private:
00153 CUTEScintilla *view;
00154 Config::Lexer *_lexer;
00156 QProcess *proc;
00157 char *filename;
00158 int bookmark, error;
00159 bool recording;
00160 std::list<ScintillaAction> macro;
00161 QString searchString;
00162 bool searchRegExp;
00163 bool searchCaseSensitive;
00164 bool searchWholeWord;
00165 bool searchLineWrap;
00166 bool searchDirection;
00167 bool searching;
00168 };
00169
00170 #endif