summaryrefslogtreecommitdiffstats
path: root/objects/basetexteditor.h
blob: 983e6b016e45d3346b87845b0cdf8101ccea6070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/**************************************************************************
**
** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company.
** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

#ifndef TEXTEDITORWRAPPER_H
#define TEXTEDITORWRAPPER_H

#include "texteditor.h"
#include <QTextDocument>
#include "utils/position.h"

namespace TextEditor {
    class BaseTextEditor;
    class BaseTextEditorWidget;
}

namespace Scripting {
namespace Internal {

class Mark;

class BaseTextEditor : public TextEditor
{
    Q_OBJECT
public:
    explicit BaseTextEditor(QObject *parent=0);
    ::TextEditor::BaseTextEditorWidget *textEditorWidget();

public slots:
    void copy();
    void paste();
    void cut();
    void cutLine();
    void copyLine();

    void deleteSelection();
    void deleteLine(int count=1);
    void deleteEndOfWord(int count=1);
    void deleteEndOfWordCamelCase(int count=1);
    void deleteStartOfWord(int count=1);
    void deleteStartOfWordCamelCase(int count=1);

    void gotoBlockStart(int count=1);
    void gotoBlockEnd(int count=1);
    void gotoLineStart(int count=1);
    void gotoLineEnd(int count=1);
    void gotoNextLine(int count=1);
    void gotoPreviousLine(int count=1);
    void gotoPreviousCharacter(int count=1);
    void gotoNextCharacter(int count=1);
    void gotoPreviousWord(int count=1);
    void gotoNextWord(int count=1);
    void gotoPreviousWordCamelCase(int count=1);
    void gotoNextWordCamelCase(int count=1);

    void clearSelection();
    bool hasSelection();
    void selectAll();

    void selectBlockStart(int count=1);
    void selectBlockEnd(int count=1);
    void selectLineStart(int count=1);
    void selectLineEnd(int count=1);
    void selectNextLine(int count=1);
    void selectPreviousLine(int count=1);
    void selectPreviousCharacter(int count=1);
    void selectNextCharacter(int count=1);
    void selectPreviousWord(int count=1);
    void selectNextWord(int count=1);
    void selectPreviousWordCamelCase(int count=1);
    void selectNextWordCamelCase(int count=1);
    void selectBlockUp(int count=1);
    void selectBlockDown(int count=1);

    void moveLineUp(int count=1);
    void moveLineDown(int count=1);
    void copyLineUp(int count=1);
    void copyLineDown(int count=1);
    void joinLines(int count=1);

    void insertLineAbove(int count=1);
    void insertLineBelow(int count=1);

    void uppercaseSelection();
    void lowercaseSelection();

    void cleanWhitespace();

    void insertText(const QString &text);
    QString selectedText();
    QString text();

    // Own implementation - ie. not in the interface of ::TextEditor::BaseTextEditorWidget
    Mark* createMark(int line=-1, int column=-1);
    void gotoMark(Mark*);

    bool find(const QString& text, bool backward = false, bool caseSensitively = false, bool wholeWords = false);
    bool findRegexp(const QString& regexp, bool backward = false, bool caseSensitively = false, bool wholeWords = false);
    void indent();
    void deleteRegion( const Position& from, const Position& to);

private:
    QTextDocument::FindFlags flags(bool backward, bool caseSensitively, bool wholeWords) const;
};

} // namespace Internal
} // namespace Scripting

Q_DECLARE_METATYPE(Scripting::Internal::BaseTextEditor*)

#endif // TEXTEDITORWRAPPER_H