• 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
  • buffer
katetexthistory.h
Go to the documentation of this file.
1 /* This file is part of the Kate project.
2  *
3  * Copyright (C) 2010 Christoph Cullmann <cullmann@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) any later version.
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 
21 #ifndef KATE_TEXTHISTORY_H
22 #define KATE_TEXTHISTORY_H
23 
24 #include <QtCore/QList>
25 
26 #include <ktexteditor/range.h>
27 
28 #include "katepartprivate_export.h"
29 #include "katetextcursor.h"
30 #include "katetextrange.h"
31 
32 namespace Kate {
33 
34 class TextBuffer;
35 
39 class KATEPART_TESTS_EXPORT TextHistory {
40  friend class TextBuffer;
41  friend class TextBlock;
42 
43  public:
48  qint64 revision () const;
49 
54  qint64 lastSavedRevision () const { return m_lastSavedRevision; }
55 
61  void lockRevision (qint64 revision);
62 
67  void unlockRevision (qint64 revision);
68 
77  void transformCursor (int& line, int& column, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1);
78 
87  void transformRange (KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors, KTextEditor::MovingRange::EmptyBehavior emptyBehavior, qint64 fromRevision, qint64 toRevision = -1);
88 
89  private:
93  class Entry {
94  public:
101  void transformCursor (int &line, int &column, bool moveOnInsert) const;
102 
109  void reverseTransformCursor (int &line, int &column, bool moveOnInsert) const;
110 
114  enum Type {
115  NoChange
116  , WrapLine
117  , UnwrapLine
118  , InsertText
119  , RemoveText
120  };
121 
125  Entry ()
126  : referenceCounter (0), type (NoChange), line (-1), column (-1), length (-1), oldLineLength (-1)
127  {
128  }
129 
133  unsigned int referenceCounter;
134 
138  Type type;
139 
143  int line;
144 
148  int column;
149 
153  int length;
154 
158  int oldLineLength;
159  };
160 
165  TextHistory (TextBuffer &buffer);
166 
170  ~TextHistory ();
171 
175  void clear ();
176 
180  void setLastSavedRevision ();
181 
186  void wrapLine (const KTextEditor::Cursor &position);
187 
193  void unwrapLine (int line, int oldLineLength);
194 
201  void insertText (const KTextEditor::Cursor &position, int length, int oldLineLength);
202 
208  void removeText (const KTextEditor::Range &range, int oldLineLength);
209 
214  void addEntry (const Entry &entry);
215 
216  private:
220  TextBuffer &m_buffer;
221 
225  qint64 m_lastSavedRevision;
226 
230  QList<Entry> m_historyEntries;
231 
235  qint64 m_firstHistoryEntryRevision;
236 };
237 
238 }
239 
240 #endif
Kate::TextHistory::lastSavedRevision
qint64 lastSavedRevision() const
Last revision the buffer got successful saved.
Definition: katetexthistory.h:54
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
katetextrange.h
katepartprivate_export.h
QList< Entry >
Kate::TextHistory
Class representing the editing history of a TextBuffer.
Definition: katetexthistory.h:39
Kate::TextBuffer
Class representing a text buffer.
Definition: katetextbuffer.h:48
katetextcursor.h
Kate::TextBlock
Class representing a text block.
Definition: katetextblock.h:42
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