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 #include <qextscintillamacro.h>
00022 #include <qcolor.h>
00023 #include <qfile.h>
00024 #include <qaction.h>
00025 #include <qmap.h>
00026 #include <qprocess.h>
00027 #include <qvaluelist.h>
00028 #include <list>
00029
00030 #include "cutescintilla.h"
00031
00032 namespace Config{ class Lexer; }
00033
00035 class ScintillaAction
00036 {
00037 public:
00038 ScintillaAction(unsigned int msg, unsigned long wParam, long lParam);
00039 ScintillaAction(const ScintillaAction& a);
00040 ~ScintillaAction(){
00041 delete[] lParam;
00042 }
00043 unsigned int msg;
00044 unsigned long wParam;
00045 char *lParam;
00046 ScintillaAction &operator=(const ScintillaAction& a);
00047 };
00048
00052 class CUTEView : public QWidget
00053 {
00054 Q_OBJECT
00055 public:
00056 enum { CUTE_MARGIN = 0, CUTE_LINENUMBER_MARGIN = 1, CUTE_FOLD_MARGIN = 2 };
00057 CUTEView(QWidget *parent=0, QString title = "Document", tagFile *tags=0);
00058 ~CUTEView();
00060 void configure();
00062 void sendEditor(unsigned int msg, unsigned long wParam=0, long lParam=0);
00064 bool loadFile(const char *file);
00066 bool reloadFile();
00068 bool saveFile(const char *file=0, bool force=false);
00070 void toggleBookmark(int line);
00072 void addError(int line );
00074 int addBookmark(int line );
00076 void deleteAllErrors();
00078 void findNextBookmark();
00080 void findPrevBookmark();
00082 void insertCommand(QString);
00084 void filter(QString);
00086 void startMacroRecording();
00088 void stopMacroRecording();
00090 void runMacro();
00092 void loadMacro(QString &file);
00094 void saveMacro(QString &file);
00096 bool setMacro(QString);
00098 QString macroString();
00100 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);
00102 bool findNext();
00104 bool findPrev();
00106 void setupLexer(const QString&);
00108 void replaceAll(const QString &expr, const QString &replaceStr, bool re, bool cs, bool wo, bool wrap, bool forward=TRUE, bool confirm=false);
00110 bool edited();
00112 bool canUndo();
00114 bool canRedo();
00116 void undo();
00118 void redo();
00120 QString line(int l) { return view->line(l); }
00122 CUTEScintilla* scintilla();
00124 void setActions(QMap<int, QAction*>);
00126 char *fileName() { return filename; }
00128 Config::Lexer *lexer() { return _lexer; }
00130 void setLexer( Config::Lexer *l ) { _lexer = l; }
00132 void getCursorPosition( int &line, int &index );
00134 void getSelection(int &lineFrom,int &indexFrom, int &lineTo,int &indexTo);
00136 void clear();
00138 QValueList<int> bookmarks();
00140 void removeAllBookmarks();
00142 QString langName();
00144 void setFocus() { view->setFocus(); }
00145 protected:
00147 void closeEvent(QCloseEvent *e);
00148 protected slots:
00150 void slotDocumentChanged();
00152 void slotMarginClicked(int margin, int line, Qt::ButtonState state);
00154 void insertStdout();
00156 void processExited();
00158 void recordMacro(unsigned int, unsigned long, long);
00160 void slotCharAdded(int);
00161 signals:
00162 void save();
00163 void closed(CUTEView *view=0);
00164 void setTabCaption(QWidget *view, QString name);
00165 private:
00166 CUTEScintilla *view;
00167 Config::Lexer *_lexer;
00169 QProcess *proc;
00170 char *filename;
00171 int bookmark, error;
00172 bool recording;
00173 std::list<ScintillaAction> macro;
00174 QString searchString;
00175 bool searchRegExp;
00176 bool searchCaseSensitive;
00177 bool searchWholeWord;
00178 bool searchLineWrap;
00179 bool searchDirection;
00180 bool searching;
00181 QValueList<int> handles;
00182 };
00183
00184 #endif