• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • script
katescriptdocument.h
Go to the documentation of this file.
1 // This file is part of the KDE libraries
2 // Copyright (C) 2008 Paul Giannaros <paul@giannaros.org>
3 // Copyright (C) 2009 Dominik Haumann <dhaumann kde org>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) version 3.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // You should have received a copy of the GNU Library General Public License
16 // along with this library; see the file COPYING.LIB. If not, write to
17 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 // Boston, MA 02110-1301, USA.
19 
20 #ifndef KATE_SCRIPT_DOCUMENT_H
21 #define KATE_SCRIPT_DOCUMENT_H
22 
23 #include <QObject>
24 #include <QStringList>
25 #include <QtScript/QScriptable>
26 
27 #include "katepartprivate_export.h"
28 
29 #include <QtScript/QScriptValue>
30 
31 #include <ktexteditor/cursor.h>
32 #include <ktexteditor/range.h>
33 
34 class KateDocument;
35 
46 class KATEPART_TESTS_EXPORT KateScriptDocument : public QObject, protected QScriptable
47 {
48  Q_OBJECT
49  // Note: we have no Q_PROPERTIES due to consistency: everything is a function.
50 
51  public:
52  KateScriptDocument(QObject *parent=0);
53  void setDocument(KateDocument *document);
54  KateDocument *document();
55 
56  //BEGIN
57  Q_INVOKABLE QString fileName();
58  Q_INVOKABLE QString url();
59  Q_INVOKABLE QString mimeType();
60  Q_INVOKABLE QString encoding();
61  Q_INVOKABLE QString highlightingMode();
62  Q_INVOKABLE QStringList embeddedHighlightingModes();
63  Q_INVOKABLE QString highlightingModeAt(const KTextEditor::Cursor& pos);
64  Q_INVOKABLE bool isModified();
65  Q_INVOKABLE QString text();
66  Q_INVOKABLE QString text(int fromLine, int fromColumn, int toLine, int toColumn);
67  Q_INVOKABLE QString text(const KTextEditor::Cursor& from, const KTextEditor::Cursor& to);
68  Q_INVOKABLE QString text(const KTextEditor::Range& range);
69  Q_INVOKABLE QString line(int line);
70  Q_INVOKABLE QString wordAt(int line, int column);
71  Q_INVOKABLE QString wordAt(const KTextEditor::Cursor& cursor);
72  Q_INVOKABLE KTextEditor::Range wordRangeAt(int line, int column);
73  Q_INVOKABLE KTextEditor::Range wordRangeAt(const KTextEditor::Cursor& cursor);
74  Q_INVOKABLE QString charAt(int line, int column);
75  Q_INVOKABLE QString charAt(const KTextEditor::Cursor& cursor);
76  Q_INVOKABLE QString firstChar(int line);
77  Q_INVOKABLE QString lastChar(int line);
78  Q_INVOKABLE bool isSpace(int line, int column);
79  Q_INVOKABLE bool isSpace(const KTextEditor::Cursor& cursor);
80  Q_INVOKABLE bool matchesAt(int line, int column, const QString &s);
81  Q_INVOKABLE bool matchesAt(const KTextEditor::Cursor& cursor, const QString &s);
82  Q_INVOKABLE bool setText(const QString &s);
83  Q_INVOKABLE bool clear();
84  Q_INVOKABLE bool truncate(int line, int column);
85  Q_INVOKABLE bool truncate(const KTextEditor::Cursor& cursor);
86  Q_INVOKABLE bool insertText(int line, int column, const QString &s);
87  Q_INVOKABLE bool insertText(const KTextEditor::Cursor& cursor, const QString &s);
88  Q_INVOKABLE bool removeText(int fromLine, int fromColumn, int toLine, int toColumn);
89  Q_INVOKABLE bool removeText(const KTextEditor::Cursor& from, const KTextEditor::Cursor& to);
90  Q_INVOKABLE bool removeText(const KTextEditor::Range& range);
91  Q_INVOKABLE bool insertLine(int line, const QString &s);
92  Q_INVOKABLE bool removeLine(int line);
93  Q_INVOKABLE bool wrapLine(int line, int column);
94  Q_INVOKABLE bool wrapLine(const KTextEditor::Cursor& cursor);
95  Q_INVOKABLE void joinLines(int startLine, int endLine);
96  Q_INVOKABLE int lines();
97  Q_INVOKABLE int length();
98  Q_INVOKABLE int lineLength(int line);
99  Q_INVOKABLE void editBegin();
100  Q_INVOKABLE void editEnd();
101  Q_INVOKABLE int firstColumn(int line);
102  Q_INVOKABLE int lastColumn(int line);
103  Q_INVOKABLE int prevNonSpaceColumn(int line, int column);
104  Q_INVOKABLE int prevNonSpaceColumn(const KTextEditor::Cursor& cursor);
105  Q_INVOKABLE int nextNonSpaceColumn(int line, int column);
106  Q_INVOKABLE int nextNonSpaceColumn(const KTextEditor::Cursor& cursor);
107  Q_INVOKABLE int prevNonEmptyLine(int line);
108  Q_INVOKABLE int nextNonEmptyLine(int line);
109  Q_INVOKABLE bool isInWord(const QString &character, int attribute);
110  Q_INVOKABLE bool canBreakAt(const QString &character, int attribute);
111  Q_INVOKABLE bool canComment(int startAttribute, int endAttribute);
112  Q_INVOKABLE QString commentMarker(int attribute);
113  Q_INVOKABLE QString commentStart(int attribute);
114  Q_INVOKABLE QString commentEnd(int attribute);
115 
116  Q_INVOKABLE KTextEditor::Range documentRange();
117  Q_INVOKABLE KTextEditor::Cursor documentEnd();
118 
122  Q_INVOKABLE int attribute(int line, int column);
123  Q_INVOKABLE int attribute(const KTextEditor::Cursor& cursor);
124 
128  Q_INVOKABLE bool isAttribute(int line, int column, int attr);
129  Q_INVOKABLE bool isAttribute(const KTextEditor::Cursor& cursor, int attr);
130 
134  Q_INVOKABLE QString attributeName(int line, int column);
135  Q_INVOKABLE QString attributeName(const KTextEditor::Cursor& cursor);
136 
140  Q_INVOKABLE bool isAttributeName(int line, int column, const QString &name);
141  Q_INVOKABLE bool isAttributeName(const KTextEditor::Cursor& cursor, const QString &name);
142 
143  Q_INVOKABLE QString variable(const QString &s);
144  Q_INVOKABLE QString setVariable(const QString &s, const QString &v);
145  //END
146 
147  Q_INVOKABLE int firstVirtualColumn(int line);
148  Q_INVOKABLE int lastVirtualColumn(int line);
149  Q_INVOKABLE int toVirtualColumn(int line, int column);
150  Q_INVOKABLE int toVirtualColumn(const KTextEditor::Cursor& cursor);
151  Q_INVOKABLE KTextEditor::Cursor toVirtualCursor(const KTextEditor::Cursor& cursor);
152  Q_INVOKABLE int fromVirtualColumn(int line, int virtualColumn);
153  Q_INVOKABLE int fromVirtualColumn(const KTextEditor::Cursor& virtualCursor);
154  Q_INVOKABLE KTextEditor::Cursor fromVirtualCursor(const KTextEditor::Cursor& virtualCursor);
155 
156  Q_INVOKABLE KTextEditor::Cursor anchor(int line, int column, QChar character);
157  Q_INVOKABLE KTextEditor::Cursor anchor(const KTextEditor::Cursor& cursor, QChar character);
158  Q_INVOKABLE KTextEditor::Cursor rfind(int line, int column, const QString& text, int attribute = -1);
159  Q_INVOKABLE KTextEditor::Cursor rfind(const KTextEditor::Cursor& cursor, const QString& text, int attribute = -1);
160 
161  Q_INVOKABLE int defStyleNum(int line, int column);
162  Q_INVOKABLE int defStyleNum(const KTextEditor::Cursor& cursor);
163  Q_INVOKABLE bool isCode(int line, int column);
164  Q_INVOKABLE bool isCode(const KTextEditor::Cursor& cursor);
165  Q_INVOKABLE bool isComment(int line, int column);
166  Q_INVOKABLE bool isComment(const KTextEditor::Cursor& cursor);
167  Q_INVOKABLE bool isString(int line, int column);
168  Q_INVOKABLE bool isString(const KTextEditor::Cursor& cursor);
169  Q_INVOKABLE bool isRegionMarker(int line, int column);
170  Q_INVOKABLE bool isRegionMarker(const KTextEditor::Cursor& cursor);
171  Q_INVOKABLE bool isChar(int line, int column);
172  Q_INVOKABLE bool isChar(const KTextEditor::Cursor& cursor);
173  Q_INVOKABLE bool isOthers(int line, int column);
174  Q_INVOKABLE bool isOthers(const KTextEditor::Cursor& cursor);
175 
176 
177  Q_INVOKABLE bool startsWith (int line, const QString &pattern, bool skipWhiteSpaces);
178  Q_INVOKABLE bool endsWith (int line, const QString &pattern, bool skipWhiteSpaces);
179 
180  Q_INVOKABLE void indent(KTextEditor::Range range, int change);
181  Q_INVOKABLE void align(const KTextEditor::Range& range);
182 
183  private:
184  bool _isCode(int defaultStyle);
185 
186  KateDocument *m_document;
187 };
188 
189 
190 #endif
191 
192 // kate: space-indent on; indent-width 2; replace-tabs on;
QChar
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
QObject
katepartprivate_export.h
KateScriptDocument
Thinish wrapping around KateDocument, exposing the methods we want exposed and adding some helper met...
Definition: katescriptdocument.h:46
QString
QStringList
isInWord
static bool isInWord(const KTextEditor::View *view, const KTextEditor::Cursor &position, QChar c)
Definition: katekeywordcompletion.cpp:118
KateDocument
Definition: katedocument.h:74
firstColumn
QModelIndex firstColumn(const QModelIndex &index)
Definition: expandingwidgetmodel.cpp:40
QScriptable
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal