Debian Codegraph @

src/Gui/PythonEditor.h

raw
1 /***************************************************************************
2 * Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23 #ifndef GUI_PYTHONEDITOR_H
24 #define GUI_PYTHONEDITOR_H
25
26 #include "SyntaxHighlighter.h"
27 #include "TextEdit.h"
28
29
30 namespace Gui
31 {
32
33 class PythonSyntaxHighlighter;
34 class PythonSyntaxHighlighterP;
35
36 /**
37 * Python text editor with syntax highlighting.
38 * \author Werner Mayer
39 */
40 class GuiExport PythonEditor: public PythonTextEditor
41 {
42 Q_OBJECT
43
44 public:
45 explicit PythonEditor(QWidget* parent = nullptr);
46 ~PythonEditor() override;
47
48 void OnChange(Base::Subject<const char*>& rCaller, const char* rcReason) override;
49 void toggleBreakpoint();
50 void showDebugMarker(int line);
51 void hideDebugMarker();
52
53 public Q_SLOTS:
54 /** Inserts a '#' at the beginning of each selected line or the current line if
55 * nothing is selected
56 */
57 void onComment();
58 /**
59 * Removes the leading '#' from each selected line or the current line if
60 * nothing is selected. In case a line hasn't a leading '#' then
61 * this line is skipped.
62 */
63 void onUncomment();
64 void onExecuteInConsole();
65 void setFileName(const QString&);
66 void startDebug();
67
68 protected:
69 /** Pops up the context menu with some extensions */
70 void contextMenuEvent(QContextMenuEvent* e) override;
71 void drawMarker(int line, int x, int y, QPainter*) override;
72 void keyPressEvent(QKeyEvent*) override;
73
74 private:
75 // PythonSyntaxHighlighter* pythonSyntax;
76 struct PythonEditorP* d;
77 };
78
79 /**
80 * Syntax highlighter for Python.
81 * \author Werner Mayer
82 */
83 class GuiExport PythonSyntaxHighlighter: public SyntaxHighlighter
84 {
85 public:
86 explicit PythonSyntaxHighlighter(QObject* parent);
87 ~PythonSyntaxHighlighter() override;
88
89 void highlightBlock(const QString& text) override;
90
91 private:
92 PythonSyntaxHighlighterP* d;
93 };
94
95 } // namespace Gui
96
97 #endif // GUI_PYTHONEDITOR_H