itom
Loading...
Searching...
No Matches
indenter.h
1
2
3/* ********************************************************************
4 itom software
5 URL: http://www.uni-stuttgart.de/ito
6 Copyright (C) 2020, Institut für Technische Optik (ITO),
7 Universität Stuttgart, Germany
8
9 This file is part of itom.
10
11 itom is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Library General Public Licence as published by
13 the Free Software Foundation; either version 2 of the Licence, or (at
14 your option) any later version.
15
16 itom is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
19 General Public Licence for more details.
20
21 You should have received a copy of the GNU Library General Public License
22 along with itom. If not, see <http://www.gnu.org/licenses/>.
23
24 Further hints:
25 ------------------------
26
27 This file belongs to the code editor of itom. The code editor is
28 in major parts a fork / rewritten version of the python-based source
29 code editor PyQode from Colin Duquesnoy and others
30 (see https://github.com/pyQode). PyQode itself is licensed under
31 the MIT License (MIT).
32
33 Some parts of the code editor of itom are also inspired by the
34 source code editor of the Spyder IDE (https://github.com/spyder-ide),
35 also licensed under the MIT License and developed by the Spyder Project
36 Contributors.
37
38*********************************************************************** */
39
40#ifndef INDENTER_H
41#define INDENTER_H
42
43/*
44Contains the default indenter.
45*/
46
47#include "../mode.h"
48#include <qobject.h>
49#include <qstring.h>
50#include <qtextcursor.h>
51
52namespace ito {
53
54/*
55Implements classic indentation/tabulation (Tab/Shift+Tab)
56
57It inserts/removes tabulations (a series of spaces defined by the
58tabLength settings) at the cursor position if there is no selection,
59otherwise it fully indents/un-indents selected lines.
60
61To trigger an indentation/un-indentation programmatically, you must emit
62:attr:`pyqode.core.api.CodeEdit.indent_requested` or
63:attr:`pyqode.core.api.CodeEdit.unindent_requested`.
64*/
65class IndenterMode : public QObject, public Mode
66{
67 Q_OBJECT
68public:
69 IndenterMode(const QString &description = "", QObject *parent = NULL);
70 virtual ~IndenterMode();
71
72 virtual void onStateChanged(bool state);
73
74 void indentSelection(QTextCursor cursor) const;
75 QTextCursor unindentSelection(QTextCursor cursor) const;
76
77 int countDeletableSpaces(const QTextCursor &cursor, int maxSpaces) const;
78
79private slots:
80 void indent() const;
81 void unindent() const;
82
83protected:
84
85
86};
87
88} //end namespace ito
89
90#endif
Definition indenter.h:66
Definition mode.h:70
Definition apiFunctionsGraph.cpp:40