Repository navigation
Expand file tree
/
Copy pathsqriptor.h
More file actions
131 lines (116 loc) · 3.71 KB
/
Copy pathsqriptor.h
File metadata and controls
131 lines (116 loc) · 3.71 KB
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
/*
* Sqriptor text editor for Qt5
* Copyright 2021 by Thomas Lübking <thomas.luebking@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SQRIPTOR_H
#define SQRIPTOR_H
#include <QMainWindow>
class QAction;
class QActionGroup;
class QLineEdit;
class QMenu;
class QTabWidget;
class QsciScintilla;
namespace Syntax {
enum Lexer {
None = 0, Auto, AVS, AWK, Bash, Batch, CMake, CoffeeScript, CPP, CSS,
D, Diff, EDIFACT, Fortran77, HTML, JSON, Lua, Makefile,
Markdown2, Matlab, Pascal, Perl, PO, PostScript, POV, Properties,
Python, Ruby, Spice, SQL, TCL, TeX, Verilog, VHDL, YAML,
CSharp, IDL, Java, JavaScript, Fortran, XML, Octave, Xorg, Journal,
XorgLog, PkgBuild, NIM, LISP, FontConfig, QtPro, GLSL, Rust, KDL, Count
};
};
namespace Size { enum Mode { Relative = 0, Absolute, Remember }; };
typedef struct Config
{
Size::Mode sizeMode;
QSize size;
QFont font;
struct wrap {
bool words;
bool indicator;
int indicatorPos;
} wrap;
struct tab {
bool isTab;
int width;
} tab;
struct color {
QColor bg, fg, string, character, comment, preproc,
number, operateur, keyword, error;
} color;
bool changed;
QStringList recentFiles;
QString markdownProcessor;
QString previewCSS;
} Config;
class Sqriptor : public QMainWindow
{
Q_OBJECT
public:
Sqriptor();
void open(QString fileName, bool forceNewTab = false);
QsciScintilla *textEdit(int idx = -1) const;
void newFile(QString name = QString(), bool forceNewTab = false);
void readStdin();
typedef Syntax::Lexer Syntax;
static Config config;
protected:
void closeEvent(QCloseEvent *event);
signals:
void copyAvailable(bool);
private slots:
bool save();
bool saveAs();
void toggleBookmark();
void nextBookmark();
void prevBookmark();
void setSyntax(Syntax syntax = Syntax::Auto, QsciScintilla *document = nullptr, bool updateColorsOnly = false);
int addTab();
bool closeTab(int idx = -1);
bool toggleComment();
void showSettings();
void checkTimestamp();
void analyzeSyntaxOnce();
void copy();
void togglePreview(int idx = -1, Qt::CheckState state = Qt::PartiallyChecked);
private:
QRect availableGeometry() const;
QMap<int, QString> bookmarks() const;
void createUI();
void readSettings();
void writeSettings();
bool maybeSave(int idx = -1);
void loadFile(const QString &fileName);
bool saveFile(const QString &fileName);
void setCurrentFile(const QString &fileName);
Syntax syntax(QString suffix) const;
void indicateCurrentSyntax();
void indicateCurrentEOL();
void updateTimestamp(QObject *o);
void updatePalette();
void renderIcon(QPixmap &pix);
void findAll(QString text, bool rx, bool cs, bool wo);
QString ask4Codec(const QString &codec, const QString &fileName);
QTabWidget *m_documents;
QActionGroup *m_syntaxActions;
QMenu *m_eolMenu;
QAction *m_tabMenu;
QAction *m_EolVis, *m_wrapped, *m_folds, *m_filterBookmarks, *m_previewAction;
QLineEdit *m_filterLine;
};
#endif