pqPythonSyntaxHighlighter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqPythonSyntaxHighlighter_h
5 #define pqPythonSyntaxHighlighter_h
6 
7 #undef slots
8 #include "vtkPython.h"
9 #define slots Q_SLOTS
10 
11 #include "pqPythonModule.h"
12 
13 #include <QObject>
14 
15 #include "vtkPythonCompatibility.h"
16 #include "vtkPythonInterpreter.h"
17 #include "vtkSmartPyObject.h"
18 
19 class QTextEdit;
20 class QUndoStack;
21 
23 
38 {
39  Q_OBJECT
40 public:
41  typedef QObject Superclass;
47  explicit pqPythonSyntaxHighlighter(QObject* p, QTextEdit& textEdit);
48  ~pqPythonSyntaxHighlighter() override = default;
49 
54  bool isReplacingTabs() const;
59  void setReplaceTabs(bool replaceTabs);
60 
64  QString Highlight(const QString& src) const;
65 
71  void ConnectHighligter() const;
72 
73 protected:
78  bool eventFilter(QObject*, QEvent*) override;
79 
80 private:
81  QTextEdit& TextEdit;
82 
83  vtkSmartPyObject PygmentsModule;
84 
85  vtkSmartPyObject HighlightFunction;
86 
87  vtkSmartPyObject PythonLexer;
88 
89  vtkSmartPyObject HtmlFormatter;
90 
95  bool ReplaceTabs = true;
96 
97  Q_DISABLE_COPY(pqPythonSyntaxHighlighter);
98 };
99 
100 #endif
#define PQPYTHON_EXPORT
This class is a helper object to attach to a QTextEdit to add Python syntax highlighting to the text ...