-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditorinfo.h
87 lines (75 loc) · 1.72 KB
/
editorinfo.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef EDITORINFO_H
#define EDITORINFO_H
#include <QDateTime>
#include <QLabel>
#include <Qsci/qsciscintilla.h>
#include <Qsci/qscilexer.h>
#include "editorconfig.h"
#include "language.h"
namespace Ui {
class MainWindow;
}
class CoreEditor : public QsciScintilla {
Q_OBJECT
protected:
virtual void wheelEvent(QWheelEvent* );
virtual void focusInEvent(QFocusEvent* );
virtual void keyPressEvent(QKeyEvent* );
public:
using QsciScintilla::QsciScintilla;
class EditorInfo* info = nullptr;
int justCompleteBrace = 0;
};
//typedef QsciScintilla Editor;
class EditorInfo : public QObject {
Q_OBJECT
friend class FindReplace;
friend class MainWindow;
CoreEditor* editor;
Language* language = nullptr;
Ui::MainWindow* ui;
QString path;
bool modified = false;
bool canUndo;
bool canRedo;
QDateTime whenOpen;
static int untitled_next;
static QList<int> untitled_rest;
private slots:
void modificationChanged(bool m);
public slots:
void updateUndoRedoState();
void updateLineNumber();
void updateSelectionState();
void updateStatusInfo();
public:
EditorInfo(CoreEditor* e, Ui::MainWindow* ui);
virtual ~EditorInfo();
QString getPath() const {
return path;
}
bool isUntitled() const {
return path[0] == '#';
}
bool isAtSavePoint() const {
return !modified;
}
void generateUntitled();
QString generateName() const;
QString generateTitle() const {
return generateName() + (isAtSavePoint() ? "" : " *");
}
void updateEditorConfig();
bool open(const QString& cpath);
bool write(const QString& cpath);
bool saveas();
bool save();
bool askSave();
bool compile() const;
void run();
bool isModifiedByOthers() const;
void reload();
signals:
void pathChange(QString cpath, QString ppath);
};
#endif // EDITORINFO_H