1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "texteditpython.h" |
6 | #include "stylelsppython.h" |
7 | #include "stylescipython.h" |
8 | #include "textedittabwidget/style/stylejsonfile.h" |
9 | |
10 | class TextEditPythonPrivate |
11 | { |
12 | friend class TextEditPython; |
13 | StyleLsp *styleLsp {nullptr}; |
14 | StyleSci *styleSci {nullptr}; |
15 | StyleJsonFile *styleFile {nullptr}; |
16 | }; |
17 | |
18 | TextEditPython::TextEditPython(QWidget *parent) |
19 | : TextEdit (parent) |
20 | , d (new TextEditPythonPrivate) |
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 StyleSciPython(this); |
26 | d->styleLsp = new StyleLspPython(this); |
27 | } |
28 | |
29 | TextEditPython::~TextEditPython() |
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 | |
41 | QString TextEditPython::supportLanguage() |
42 | { |
43 | return "python"; // 向上兼容Scintilla中Lexer |
44 | } |
45 | |
46 | QString TextEditPython::implLanguage() |
47 | { |
48 | return "python"; // 界面调用兼容 |
49 | } |
50 | |
51 | StyleLsp *TextEditPython::getStyleLsp() const |
52 | { |
53 | return d->styleLsp; |
54 | } |
55 | |
56 | StyleSci *TextEditPython::getStyleSci() const |
57 | { |
58 | return d->styleSci; |
59 | } |
60 | |
61 | StyleJsonFile *TextEditPython::getStyleFile() const |
62 | { |
63 | return d->styleFile; |
64 | } |
65 | |
66 |