File indexing completed on 2024-05-12 15:45:40
0001 /* 0002 SPDX-FileCopyrightText: 2010 Christoph Cullmann <cullmann@kde.org> 0003 0004 Based on code of the SmartCursor/Range by: 0005 SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <rodda@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KTEXTEDITOR_MOVINGINTERFACE_H 0011 #define KTEXTEDITOR_MOVINGINTERFACE_H 0012 0013 #include <ktexteditor/movingcursor.h> 0014 #include <ktexteditor/movingrange.h> 0015 #include <ktexteditor/movingrangefeedback.h> 0016 #include <ktexteditor_export.h> 0017 0018 namespace KTextEditor 0019 { 0020 /** 0021 * \class MovingInterface movinginterface.h <KTextEditor/MovingInterface> 0022 * 0023 * \brief Document interface for MovingCursor%s and MovingRange%s. 0024 * 0025 * \ingroup kte_group_doc_extensions 0026 * \ingroup kte_group_moving_classes 0027 * 0028 * This class provides the interface for KTextEditor::Documents to create MovingCursors/Ranges. 0029 * 0030 * \author Christoph Cullmann \<cullmann@kde.org\> 0031 * 0032 * \since 4.5 0033 */ 0034 class KTEXTEDITOR_EXPORT MovingInterface 0035 { 0036 // 0037 // Constructor/Destructor 0038 // 0039 public: 0040 /** 0041 * Default constructor 0042 */ 0043 MovingInterface(); 0044 0045 /** 0046 * Virtual destructor 0047 */ 0048 virtual ~MovingInterface(); 0049 0050 // 0051 // Normal API 0052 // 0053 public: 0054 /** 0055 * Create a new moving cursor for this document. 0056 * @param position position of the moving cursor to create 0057 * @param insertBehavior insertion behavior 0058 * @return new moving cursor for the document 0059 */ 0060 virtual MovingCursor *newMovingCursor(const Cursor &position, MovingCursor::InsertBehavior insertBehavior = MovingCursor::MoveOnInsert) = 0; 0061 0062 /** 0063 * Create a new moving range for this document. 0064 * @param range range of the moving range to create 0065 * @param insertBehaviors insertion behaviors 0066 * @param emptyBehavior behavior on becoming empty 0067 * @return new moving range for the document 0068 */ 0069 virtual MovingRange *newMovingRange(const Range &range, 0070 MovingRange::InsertBehaviors insertBehaviors = MovingRange::DoNotExpand, 0071 MovingRange::EmptyBehavior emptyBehavior = MovingRange::AllowEmpty) = 0; 0072 0073 /** 0074 * Current revision 0075 * @return current revision 0076 */ 0077 virtual qint64 revision() const = 0; 0078 0079 /** 0080 * Last revision the buffer got successful saved 0081 * @return last revision buffer got saved, -1 if none 0082 */ 0083 virtual qint64 lastSavedRevision() const = 0; 0084 0085 /** 0086 * Lock a revision, this will keep it around until released again. 0087 * But all revisions will always be cleared on buffer clear() (and therefor load()) 0088 * @param revision revision to lock 0089 */ 0090 virtual void lockRevision(qint64 revision) = 0; 0091 0092 /** 0093 * Release a revision. 0094 * @param revision revision to release 0095 */ 0096 virtual void unlockRevision(qint64 revision) = 0; 0097 0098 /** 0099 * Transform a cursor from one revision to an other. 0100 * @param cursor cursor to transform 0101 * @param insertBehavior behavior of this cursor on insert of text at its position 0102 * @param fromRevision from this revision we want to transform 0103 * @param toRevision to this revision we want to transform, default of -1 is current revision 0104 */ 0105 virtual void 0106 transformCursor(KTextEditor::Cursor &cursor, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1) = 0; 0107 0108 /** 0109 * Transform a cursor from one revision to an other. 0110 * @param line line number of the cursor to transform 0111 * @param column column number of the cursor to transform 0112 * @param insertBehavior behavior of this cursor on insert of text at its position 0113 * @param fromRevision from this revision we want to transform 0114 * @param toRevision to this revision we want to transform, default of -1 is current revision 0115 */ 0116 virtual void 0117 transformCursor(int &line, int &column, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1) = 0; 0118 0119 /** 0120 * Transform a range from one revision to an other. 0121 * @param range range to transform 0122 * @param insertBehaviors behavior of this range on insert of text at its position 0123 * @param emptyBehavior behavior on becoming empty 0124 * @param fromRevision from this revision we want to transform 0125 * @param toRevision to this revision we want to transform, default of -1 is current revision 0126 */ 0127 virtual void transformRange(KTextEditor::Range &range, 0128 KTextEditor::MovingRange::InsertBehaviors insertBehaviors, 0129 MovingRange::EmptyBehavior emptyBehavior, 0130 qint64 fromRevision, 0131 qint64 toRevision = -1) = 0; 0132 0133 // 0134 // Signals 0135 // 0136 public: 0137 /** 0138 * This signal is emitted before the cursors/ranges/revisions of a document 0139 * are destroyed as the document is deleted. 0140 * @param document the document which the interface belongs to which is in the process of being deleted 0141 */ 0142 void aboutToDeleteMovingInterfaceContent(KTextEditor::Document *document); 0143 0144 /** 0145 * This signal is emitted before the ranges of a document are invalidated 0146 * and the revisions are deleted as the document is cleared (for example on 0147 * load/reload). While this signal is emitted, the old document content is 0148 * still valid and accessible before the clear. 0149 * @param document the document which the interface belongs to which will invalidate its data 0150 */ 0151 void aboutToInvalidateMovingInterfaceContent(KTextEditor::Document *document); 0152 0153 private: 0154 /** 0155 * private d-pointer 0156 */ 0157 class MovingInterfacePrivate *const d = nullptr; 0158 }; 0159 0160 } 0161 0162 Q_DECLARE_INTERFACE(KTextEditor::MovingInterface, "org.kde.KTextEditor.MovingInterface") 0163 0164 #endif