File indexing completed on 2024-07-21 12:13:43

0001 /*
0002     This file is part of the Kate project.
0003 
0004     SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
0005     SPDX-License-Identifier: MIT
0006 */
0007 #include <KTextEditor/ConfigInterface>
0008 #include <KTextEditor/Document>
0009 #include <KTextEditor/Editor>
0010 #include <KTextEditor/ModificationInterface>
0011 #include <KTextEditor/View>
0012 
0013 #include <QApplication>
0014 #include <QMainWindow>
0015 #include <QToolBar>
0016 
0017 int main(int argc, char *argv[])
0018 {
0019     QApplication app(argc, argv);
0020 
0021     QMainWindow m;
0022 
0023     auto e = KTextEditor::Editor::instance();
0024     auto doc = e->createDocument(nullptr);
0025 
0026     if (argc > 1) {
0027         doc->openUrl(QUrl::fromLocalFile(app.arguments()[1]));
0028     }
0029 
0030     auto mf = qobject_cast<KTextEditor::ModificationInterface *>(doc);
0031     mf->setModifiedOnDiskWarning(true);
0032 
0033     //     auto docConfig = qobject_cast<KTextEditor::ConfigInterface*>(doc);
0034     //     docConfig->setConfigValue(QStringLiteral("replace-tabs"), false);
0035 
0036     auto v = doc->createView(&m);
0037     v->setContextMenu(v->defaultContextMenu());
0038     //     auto vConfig = qobject_cast<KTextEditor::ConfigInterface*>(v);
0039     //     vConfig->setConfigValue(QStringLiteral("auto-brackets"), true);
0040 
0041     //     v->setCursorPosition({6, 16});
0042 
0043     QToolBar tb(&m);
0044     tb.addAction("Config...", &m, [e, &m] {
0045         e->configDialog(&m);
0046     });
0047 
0048     m.addToolBar(&tb);
0049 
0050     m.setCentralWidget(v);
0051     m.showMaximized();
0052 
0053     return app.exec();
0054 }