itom  4.1.0
abstractCodeEditorWidget.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef ABSTRACTCODEEDITORWIDGET_H
24 #define ABSTRACTCODEEDITORWIDGET_H
25 
26 #include "../common/sharedStructures.h"
27 #include "../codeEditor/codeEditor.h"
28 
29 #include <qevent.h>
30 #include "../codeEditor/syntaxHighlighter/syntaxHighlighterBase.h"
31 #include "../codeEditor/modes/symbolMatcherMode.h"
32 #include "../codeEditor/modes/caretLineHighlight.h"
33 #include "../codeEditor/modes/pyCalltips.h"
34 #include "../codeEditor/modes/codeCompletion.h"
35 #include "../codeEditor/modes/pyCalltips.h"
36 #include "../codeEditor/modes/pyAutoIndent.h"
37 
38 #include <qstringlist.h>
39 #include <qrect.h>
40 #include <qpixmap.h>
41 #include <qsharedpointer.h>
42 
43 namespace ito {
44 
46 {
47  Q_OBJECT
48 
49 public:
50  AbstractCodeEditorWidget(QWidget* parent = NULL);
52 
53  QString getWordAtPosition(const int &line, const int &index) const;
54 
55 protected:
56 
57  enum tUserSelectionState { selNo, selRange };
58 
59  void init();
60 
61  virtual void loadSettings(); //overwrite this method if you want to load further settings
62 
63  QString formatPythonCodePart(const QString &text, int &lineCount) const;
64  QString formatConsoleCodePart(const QString &text) const;
65 
66  QPixmap loadMarker(const QString &name, int sizeAt96dpi) const;
67 
68  tUserSelectionState m_userSelectionState;
69 
70  QSharedPointer<SyntaxHighlighterBase> m_pythonSyntaxHighlighter;
71  QSharedPointer<CodeEditorStyle> m_editorStyle;
72  QSharedPointer<SymbolMatcherMode> m_symbolMatcher;
73  QSharedPointer<CaretLineHighlighterMode> m_caretLineHighlighter;
74  QSharedPointer<PyCalltipsMode> m_calltipsMode;
75  QSharedPointer<CodeCompletionMode> m_codeCompletionMode;
76  QSharedPointer<PyAutoIndentMode> m_pyAutoIndentMode;
77 
78 private:
79  int getSpaceTabCount(const QString &text) const;
80 
81 public slots:
82  void reloadSettings() { loadSettings(); };
83 
84 signals:
85  void userSelectionChanged(int lineFrom, int indexFrom, int lineTo, int indexTo);
86 
87 };
88 
89 } //end namespace ito
90 
91 #endif
QString formatPythonCodePart(const QString &text, int &lineCount) const
removes parts of the possible indentation of the given text from line 2 until the end and returns the...
Definition: abstractCodeEditorWidget.cpp:389
Definition: codeEditor.h:110
Definition: abstractCodeEditorWidget.h:45
Definition: apiFunctionsGraph.cpp:39
int getSpaceTabCount(const QString &text) const
counts the numbers of leading tabs or spaces of a string
Definition: abstractCodeEditorWidget.cpp:358