-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (43 loc) · 1.41 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (43 loc) · 1.41 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
// Copyright (c) 2026, Ioannis Makris
// Licensed under the BSD 2-Clause License, see LICENSE file for details.
#include <scintillaquick/scintillaquick_item.h>
#include <QGuiApplication>
#include <QQuickWindow>
#include "scintillaquick_font.h"
#include "scintillaquick_window_binding.h"
#include "Scintilla.h"
namespace
{
QString sample_text()
{
QStringList lines;
lines.reserve(200);
lines << "// ScintillaQuick minimal editor";
lines << "";
for (int i = 0; i < 197; ++i) {
lines << QString("Line %1: the editor is running inside a QQuickWindow.").arg(i + 1, 3, 10, QChar('0'));
}
return lines.join('\n');
}
} // namespace
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
QString font_error;
if (!scintillaquick::shared::ensure_bundled_test_fonts_loaded(&font_error)) {
qFatal("%s", qPrintable(font_error));
}
QQuickWindow window;
window.setTitle(QStringLiteral("ScintillaQuick Minimal Editor"));
window.resize(1100, 720);
window.setColor(Qt::white);
ScintillaQuick_item editor;
scintillaquick::examples::bind_item_to_window(editor, window);
editor.setProperty("font", scintillaquick::shared::deterministic_test_font(11));
editor.setProperty("text", sample_text());
editor.send(SCI_SETWRAPMODE, SC_WRAP_NONE);
editor.send(SCI_STYLECLEARALL);
window.show();
editor.forceActiveFocus();
return app.exec();
}