1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "texteditcpp.h"
6#include "stylelspcpp.h"
7#include "stylescicpp.h"
8#include "textedittabwidget/style/stylejsonfile.h"
9
10class TextEditCppPrivate
11{
12 friend class TextEditCpp;
13 StyleLsp *styleLsp {nullptr};
14 StyleSci *styleSci {nullptr};
15 StyleJsonFile *styleFile {nullptr};
16};
17
18TextEditCpp::TextEditCpp(QWidget *parent)
19 : TextEdit (parent)
20 , d (new TextEditCppPrivate)
21{
22 d->styleFile = new StyleJsonFile(this);
23 d->styleFile->setLanguage(this->supportLanguage());
24 d->styleFile->setTheme(StyleJsonFile::Theme::get()->Dark);
25 d->styleSci = new StyleSciCpp(this);
26 d->styleLsp = new StyleLspCpp(this);
27}
28
29TextEditCpp::~TextEditCpp()
30{
31 if (d) {
32 if (d->styleLsp)
33 delete d->styleLsp;
34 if (d->styleSci)
35 delete d->styleSci;
36 if (d->styleFile)
37 delete d->styleFile;
38 }
39}
40
41QString TextEditCpp::supportLanguage()
42{
43 return "cpp"; // 向上兼容Scintilla中Lexer
44}
45
46QString TextEditCpp::implLanguage()
47{
48 return "cpp"; // 界面调用兼容
49}
50
51StyleLsp *TextEditCpp::getStyleLsp() const
52{
53 return d->styleLsp;
54}
55
56StyleSci *TextEditCpp::getStyleSci() const
57{
58 return d->styleSci;
59}
60
61StyleJsonFile *TextEditCpp::getStyleFile() const
62{
63 return d->styleFile;
64}
65