itom
Loading...
Searching...
No Matches
abstractCodeEditorWidget.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität 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#include "../codeEditor/pyCodeReferenceRenamer.h"
38
39#include <qstringlist.h>
40#include <qrect.h>
41#include <qpixmap.h>
42#include <qsharedpointer.h>
43
44namespace ito {
45
47{
48 Q_OBJECT
49
50public:
51 AbstractCodeEditorWidget(QWidget* parent = NULL);
53
54 QString getWordAtPosition(const int &line, const int &index) const;
55
56protected:
57
58 enum tUserSelectionState { selNo, selRange };
59
60 void init();
61
62 virtual void loadSettings(); //overwrite this method if you want to load further settings
63
64 QString formatCodeBeforeInsertion(const QString &text, int &lineCount, bool trimText = false, const QString &newIndent = "") const;
65 QString formatCodeForClipboard(const QString &code, const QString &prependedTextInFirstLine) const;
66
67 QPixmap loadMarker(const QString &name, int sizeAt96dpi) const;
68
69 tUserSelectionState m_userSelectionState;
70
71 QSharedPointer<SyntaxHighlighterBase> m_pythonSyntaxHighlighter;
72 QSharedPointer<CodeEditorStyle> m_editorStyle;
73 QSharedPointer<SymbolMatcherMode> m_symbolMatcher;
74 QSharedPointer<CaretLineHighlighterMode> m_caretLineHighlighter;
75 QSharedPointer<PyCalltipsMode> m_calltipsMode;
76 QSharedPointer<CodeCompletionMode> m_codeCompletionMode;
77 QSharedPointer<PyAutoIndentMode> m_pyAutoIndentMode;
78 QSharedPointer<PyCodeReferenceRenamer> m_pyCodeReferenceRenamer;
79
80 virtual int startLineOffset(int lineIdx) const { return 0; }
81
82private:
83 int getSpaceTabCount(const QString &text) const;
84
85public slots:
86 void reloadSettings() { loadSettings(); };
87
88 virtual void copy();
89
90 virtual void paste();
91
92 virtual void cut();
93
94signals:
95 void userSelectionChanged(int lineFrom, int indexFrom, int lineTo, int indexTo);
96
97};
98
99} //end namespace ito
100
101#endif
Definition abstractCodeEditorWidget.h:47
virtual void copy()
copy selected code to the clipboard
Definition abstractCodeEditorWidget.cpp:585
QString formatCodeForClipboard(const QString &code, const QString &prependedTextInFirstLine) const
this method modifies a code string such before copying it to the clipboard or a mimedata.
Definition abstractCodeEditorWidget.cpp:556
int getSpaceTabCount(const QString &text) const
counts the numbers of leading tabs or spaces of a string
Definition abstractCodeEditorWidget.cpp:399
virtual void cut()
cut selected code and puts it into the clipboard
Definition abstractCodeEditorWidget.cpp:737
virtual void paste()
paste code from the clipboard at the current cursor position
Definition abstractCodeEditorWidget.cpp:653
QString formatCodeBeforeInsertion(const QString &text, int &lineCount, bool trimText=false, const QString &newIndent="") const
Definition abstractCodeEditorWidget.cpp:436
Definition codeEditor.h:110
Definition apiFunctionsGraph.cpp:40