-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.h
63 lines (60 loc) · 1.83 KB
/
editor.h
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
#ifndef EDITOR_H
#define EDITOR_H
#include<QPlainTextEdit>
#include<QFile>
#include<QTextCodec>
#include"searchhistory.h"
#include"highlighter.h"
#include<string>
using namespace std;
class LineNumberArea;
class Editor:public QPlainTextEdit{
Q_OBJECT
public:
Editor(QWidget *parent=nullptr);
QString curFilePath;
void loadFile(QString filePath); //load the specific file
void loadFile(); //load the file named by curFilePath
QString getName();
QTextCodec *code;
void codeFormatChange(const QString &format);
int formatIndex=0;
int tabIndex;
int currentColumn=1;
void lineNumberPaint(QPaintEvent *event);
void setLineNumberFont(Qt::GlobalColor);
void setCurFilePath(QString);
void launchFontDialog();
void loadFont(QString family, QFont::StyleHint styleHint, bool fixedPitch, int pointSize, int tabStopWidth);
void langChanged(QString);
QString getLang();
QString language;
bool find(QString,bool,bool);
bool replace(QString,QString,bool,bool);
void replaceAll(QString,QString,bool,bool);
private:
void highlightCurrentLine();
int getLineNumberWidth();
void moveCursorTo(int position);
QTextDocument::FindFlags getSearchOptions(bool,bool);
LineNumberArea *lineNumber;
int lineNumberPadding=25;
SearchHistory searchHistory;
QFont font;
HighLighter *genHighlighterFor(QString language);
HighLighter *syntaxHighLighter;
protected:
void resizeEvent(QResizeEvent *event) override;
public slots:
void on_cursorPositionChanged();
void updateLineNumberWidth();
void updateLineNumberArea(const QRect&,int);
void toggleRedo(bool);
void toggleUndo(bool);
void on_textChange();
signals:
void columnChanged(int);
void tabNameChange(int,QString);
void textedit(int linenum,const string& str);
};
#endif // EDITOR_H