• 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
katetextfolding.h
Go to the documentation of this file.
1 /* This file is part of the Kate project.
2  *
3  * Copyright (C) 2013 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_TEXTFOLDING_H
22 #define KATE_TEXTFOLDING_H
23 
24 #include "katepartprivate_export.h"
25 
26 #include "ktexteditor/range.h"
27 
28 #include <QObject>
29 #include <QFlags>
30 
31 namespace Kate {
32 
33 class TextBuffer;
34 class TextCursor;
35 
42 class KATEPART_TESTS_EXPORT TextFolding : public QObject {
43  Q_OBJECT
44 
45  public:
50  TextFolding (TextBuffer &buffer);
51 
55  ~TextFolding ();
56 
60  enum FoldingRangeFlag {
64  Persistent = 0x1,
65 
69  Folded = 0x2
70  };
71  Q_DECLARE_FLAGS(FoldingRangeFlags, FoldingRangeFlag)
72 
73 
80  qint64 newFoldingRange (const KTextEditor::Range &range, FoldingRangeFlags flags = FoldingRangeFlags());
81 
90  KTextEditor::Range foldingRange(qint64 id) const;
91 
97  bool foldRange (qint64 id);
98 
106  bool unfoldRange (qint64 id, bool remove = false);
107 
116  bool isLineVisible (int line, qint64 *foldedRangeId = 0) const;
117 
123  void ensureLineIsVisible (int line);
124 
130  int visibleLines () const;
131 
139  int lineToVisibleLine (int line) const;
140 
148  int visibleLineToLine (int visibleLine) const;
149 
156  QVector<QPair<qint64, FoldingRangeFlags> > foldingRangesStartingOnLine (int line) const;
157 
162  QVariantList exportFoldingRanges () const;
163 
168  void importFoldingRanges (const QVariantList &folds);
169 
174  QString debugDump () const;
175 
179  void debugPrint (const QString &title) const;
180 
181  public Q_SLOTS:
186  void clear ();
187 
188  Q_SIGNALS:
193  void foldingRangesChanged ();
194 
195  private:
199  class FoldingRange {
200  public:
207  FoldingRange (TextBuffer &buffer, const KTextEditor::Range &range, FoldingRangeFlags flags);
208 
212  ~FoldingRange ();
213 
217  typedef QVector<FoldingRange*> Vector;
218 
223  Kate::TextCursor *start;
224 
229  Kate::TextCursor *end;
230 
234  FoldingRange *parent;
235 
241  FoldingRange::Vector nestedRanges;
242 
246  FoldingRangeFlags flags;
247 
251  qint64 id;
252  };
253 
259  static void exportFoldingRanges (const TextFolding::FoldingRange::Vector &ranges, QVariantList &folds);
260 
268  static QString debugDump (const TextFolding::FoldingRange::Vector &ranges, bool recurse);
269 
280  bool insertNewFoldingRange (FoldingRange *parent, TextFolding::FoldingRange::Vector &existingRanges, TextFolding::FoldingRange *newRange);
281 
287  bool updateFoldedRangesForNewRange (TextFolding::FoldingRange *newRange);
288 
294  bool updateFoldedRangesForRemovedRange (TextFolding::FoldingRange *oldRange);
295 
301  void appendFoldedRanges (TextFolding::FoldingRange::Vector &newFoldedFoldingRanges, const TextFolding::FoldingRange::Vector &ranges) const;
302 
308  static bool compareRangeByStart (FoldingRange *a, FoldingRange *b);
309 
315  static bool compareRangeByEnd (FoldingRange *a, FoldingRange *b);
316 
322  static bool compareRangeByStartWithLine (int line, FoldingRange *range);
323 
329  static bool compareRangeByLineWithStart (FoldingRange *range, int line);
330 
338  void foldingRangesStartingOnLine (QVector<QPair<qint64, FoldingRangeFlags> > &results, const TextFolding::FoldingRange::Vector &ranges, int line) const;
339 
340  private:
346  TextBuffer &m_buffer;
347 
353  FoldingRange::Vector m_foldingRanges;
354 
360  FoldingRange::Vector m_foldedFoldingRanges;
361 
365  qint64 m_idCounter;
366 
370  QHash<qint64, FoldingRange *> m_idToFoldingRange;
371 };
372 
373 }
374 
375 Q_DECLARE_OPERATORS_FOR_FLAGS(Kate::TextFolding::FoldingRangeFlags)
376 
377 #endif
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
QHash< qint64, FoldingRange * >
QObject
katepartprivate_export.h
Kate::TextFolding
Class representing the folding information for a TextBuffer.
Definition: katetextfolding.h:42
QString
QPair
Kate::TextFolding::FoldingRangeFlag
FoldingRangeFlag
Folding state of a range.
Definition: katetextfolding.h:60
QVector
Kate::TextCursor
Class representing a 'clever' text cursor.
Definition: katetextcursor.h:43
Kate::TextBuffer
Class representing a text buffer.
Definition: katetextbuffer.h:48
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