KTextEditor

movinginterface.h
1 /*
2  SPDX-FileCopyrightText: 2010 Christoph Cullmann <[email protected]>
3 
4  Based on code of the SmartCursor/Range by:
5  SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #ifndef KTEXTEDITOR_MOVINGINTERFACE_H
11 #define KTEXTEDITOR_MOVINGINTERFACE_H
12 
13 #include <ktexteditor/movingcursor.h>
14 #include <ktexteditor/movingrange.h>
15 #include <ktexteditor/movingrangefeedback.h>
16 #include <ktexteditor_export.h>
17 
18 namespace KTextEditor
19 {
20 /**
21  * \class MovingInterface movinginterface.h <KTextEditor/MovingInterface>
22  *
23  * \brief Document interface for MovingCursor%s and MovingRange%s.
24  *
25  * \ingroup kte_group_doc_extensions
26  * \ingroup kte_group_moving_classes
27  *
28  * This class provides the interface for KTextEditor::Documents to create MovingCursors/Ranges.
29  *
30  * \author Christoph Cullmann <[email protected]>
31  *
32  * \since 4.5
33  */
34 class KTEXTEDITOR_EXPORT MovingInterface
35 {
36  //
37  // Constructor/Destructor
38  //
39 public:
40  /**
41  * Default constructor
42  */
44 
45  /**
46  * Virtual destructor
47  */
48  virtual ~MovingInterface();
49 
50  //
51  // Normal API
52  //
53 public:
54  /**
55  * Create a new moving cursor for this document.
56  * @param position position of the moving cursor to create
57  * @param insertBehavior insertion behavior
58  * @return new moving cursor for the document
59  */
60  virtual MovingCursor *newMovingCursor(const Cursor &position, MovingCursor::InsertBehavior insertBehavior = MovingCursor::MoveOnInsert) = 0;
61 
62  /**
63  * Create a new moving range for this document.
64  * @param range range of the moving range to create
65  * @param insertBehaviors insertion behaviors
66  * @param emptyBehavior behavior on becoming empty
67  * @return new moving range for the document
68  */
69  virtual MovingRange *newMovingRange(const Range &range,
72 
73  /**
74  * Current revision
75  * @return current revision
76  */
77  virtual qint64 revision() const = 0;
78 
79  /**
80  * Last revision the buffer got successful saved
81  * @return last revision buffer got saved, -1 if none
82  */
83  virtual qint64 lastSavedRevision() const = 0;
84 
85  /**
86  * Lock a revision, this will keep it around until released again.
87  * But all revisions will always be cleared on buffer clear() (and therefor load())
88  * @param revision revision to lock
89  */
90  virtual void lockRevision(qint64 revision) = 0;
91 
92  /**
93  * Release a revision.
94  * @param revision revision to release
95  */
96  virtual void unlockRevision(qint64 revision) = 0;
97 
98  /**
99  * Transform a cursor from one revision to an other.
100  * @param cursor cursor to transform
101  * @param insertBehavior behavior of this cursor on insert of text at its position
102  * @param fromRevision from this revision we want to transform
103  * @param toRevision to this revision we want to transform, default of -1 is current revision
104  */
105  virtual void
106  transformCursor(KTextEditor::Cursor &cursor, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1) = 0;
107 
108  /**
109  * Transform a cursor from one revision to an other.
110  * @param line line number of the cursor to transform
111  * @param column column number of the cursor to transform
112  * @param insertBehavior behavior of this cursor on insert of text at its position
113  * @param fromRevision from this revision we want to transform
114  * @param toRevision to this revision we want to transform, default of -1 is current revision
115  */
116  virtual void
117  transformCursor(int &line, int &column, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1) = 0;
118 
119  /**
120  * Transform a range from one revision to an other.
121  * @param range range to transform
122  * @param insertBehaviors behavior of this range on insert of text at its position
123  * @param emptyBehavior behavior on becoming empty
124  * @param fromRevision from this revision we want to transform
125  * @param toRevision to this revision we want to transform, default of -1 is current revision
126  */
127  virtual void transformRange(KTextEditor::Range &range,
129  MovingRange::EmptyBehavior emptyBehavior,
130  qint64 fromRevision,
131  qint64 toRevision = -1) = 0;
132 
133  //
134  // Signals
135  //
136 public:
137  /**
138  * This signal is emitted before the cursors/ranges/revisions of a document
139  * are destroyed as the document is deleted.
140  * @param document the document which the interface belongs to which is in the process of being deleted
141  */
143 
144  /**
145  * This signal is emitted before the ranges of a document are invalidated
146  * and the revisions are deleted as the document is cleared (for example on
147  * load/reload). While this signal is emitted, the old document content is
148  * still valid and accessible before the clear.
149  * @param document the document which the interface belongs to which will invalidate its data
150  */
152 
153 private:
154  /**
155  * private d-pointer
156  */
157  class MovingInterfacePrivate *const d = nullptr;
158 };
159 
160 }
161 
162 Q_DECLARE_INTERFACE(KTextEditor::MovingInterface, "org.kde.KTextEditor.MovingInterface")
163 
164 #endif
qint64 lastSavedRevision() const override
Last revision the buffer got successful saved.
@ AllowEmpty
allow range to be empty
Definition: movingrange.h:167
void transformRange(KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors, KTextEditor::MovingRange::EmptyBehavior emptyBehavior, qint64 fromRevision, qint64 toRevision=-1) override
Transform a range from one revision to an other.
KTextEditor::MovingRange * newMovingRange(const KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors=KTextEditor::MovingRange::DoNotExpand, KTextEditor::MovingRange::EmptyBehavior emptyBehavior=KTextEditor::MovingRange::AllowEmpty) override
Create a new moving range for this document.
InsertBehavior
Insert behavior of this cursor, should it stay if text is insert at its position or should it move.
Definition: movingcursor.h:64
An object representing a section of text, from one Cursor to another.
MovingInterface()
Default constructor.
Document interface for MovingCursors and MovingRanges.
void aboutToDeleteMovingInterfaceContent(KTextEditor::Document *document)
This signal is emitted before the cursors/ranges/revisions of a document are destroyed as the documen...
void unlockRevision(qint64 revision) override
Release a revision.
The Cursor represents a position in a Document.
Definition: cursor.h:71
void transformCursor(KTextEditor::Cursor &cursor, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision=-1) override
Transform a cursor from one revision to an other.
@ DoNotExpand
Don't expand to encapsulate new characters in either direction. This is the default.
Definition: movingrange.h:154
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:22
void aboutToInvalidateMovingInterfaceContent(KTextEditor::Document *document)
This signal is emitted before the ranges of a document are invalidated and the revisions are deleted ...
EmptyBehavior
Behavior of range if it becomes empty.
Definition: movingrange.h:166
@ MoveOnInsert
move on insert
Definition: movingcursor.h:66
virtual ~MovingInterface()
Virtual destructor.
A range that is bound to a specific Document, and maintains its position.
Definition: movingrange.h:144
KTextEditor::MovingCursor * newMovingCursor(const KTextEditor::Cursor &position, KTextEditor::MovingCursor::InsertBehavior insertBehavior=KTextEditor::MovingCursor::MoveOnInsert) override
Create a new moving cursor for this document.
qint64 revision() const override
Current revision.
A Cursor which is bound to a specific Document, and maintains its position.
Definition: movingcursor.h:54
void lockRevision(qint64 revision) override
Lock a revision, this will keep it around until released again.
A KParts derived class representing a text document.
Definition: document.h:185
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 6 2023 03:55:37 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.