• 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
katetextblock.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_TEXTBLOCK_H
22 #define KATE_TEXTBLOCK_H
23 
24 #include <QtCore/QVector>
25 #include <QtCore/QSet>
26 
27 #include "katepartprivate_export.h"
28 #include <ktexteditor/cursor.h>
29 #include "katetextline.h"
30 
31 namespace Kate {
32 
33 class TextBuffer;
34 class TextCursor;
35 class TextRange;
36 
42 class KATEPART_TESTS_EXPORT TextBlock {
43  public:
49  TextBlock (TextBuffer *buffer, int startLine);
50 
54  ~TextBlock ();
55 
60  int startLine () const { return m_startLine; }
61 
66  void setStartLine (int startLine);
67 
73  TextLine line (int line) const;
74 
79  void appendLine (const QString &textOfLine);
80 
84  void clearLines ();
85 
90  int lines () const { return m_lines.size(); }
91 
96  void text (QString &text) const;
97 
103  void wrapLine (const KTextEditor::Cursor &position, int fixStartLinesStartIndex);
104 
111  void unwrapLine (int line, TextBlock *previousBlock, int fixStartLinesStartIndex);
112 
118  void insertText (const KTextEditor::Cursor &position, const QString &text);
119 
125  void removeText (const KTextEditor::Range &range, QString &removedText);
126 
131  void debugPrint (int blockIndex) const;
132 
139  TextBlock *splitBlock (int fromLine);
140 
145  void mergeBlock (TextBlock *targetBlock);
146 
152  void deleteBlockContent ();
153 
159  void clearBlockContent (TextBlock *targetBlock);
160 
166  QList<QSet<TextRange*> > rangesForLine (int line) const {
167  return QList<QSet<TextRange*> >() << m_uncachedRanges << cachedRangesForLine(line);
168  }
169 
175  bool containsRange (TextRange* range) const {
176  return m_cachedLineForRanges.contains(range) || m_uncachedRanges.contains(range);
177  }
178 
182  void markModifiedLinesAsSaved ();
183 
188  void insertCursor (Kate::TextCursor *cursor) { m_cursors.insert (cursor); }
189 
194  void removeCursor (Kate::TextCursor *cursor) { m_cursors.remove (cursor); }
195 
201  void updateRange(TextRange* range);
202 
207  void removeRange (TextRange* range);
208 
215  QSet<TextRange*> cachedRangesForLine (int line) const {
216  line -= m_startLine;
217  if(line >= 0 && line < m_cachedRangesForLine.size())
218  return m_cachedRangesForLine[line];
219  else
220  return QSet<TextRange*>();
221  }
222 
223  private:
227  TextBuffer *m_buffer;
228 
232  QVector<Kate::TextLine> m_lines;
233 
237  int m_startLine;
238 
242  QSet<TextCursor *> m_cursors;
243 
248  QVector<QSet<TextRange *> > m_cachedRangesForLine;
249 
253  QHash<TextRange *, int> m_cachedLineForRanges;
254 
258  QSet<TextRange *> m_uncachedRanges;
259 };
260 
261 }
262 
263 #endif
katetextline.h
Kate::TextBlock::removeCursor
void removeCursor(Kate::TextCursor *cursor)
Remove cursor from this block.
Definition: katetextblock.h:194
Kate::TextBlock::lines
int lines() const
Number of lines in this block.
Definition: katetextblock.h:90
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
Kate::TextBlock::rangesForLine
QList< QSet< TextRange * > > rangesForLine(int line) const
Return all ranges in this block which might intersect the given line.
Definition: katetextblock.h:166
Kate::TextBlock::startLine
int startLine() const
Start line of this block.
Definition: katetextblock.h:60
Kate::TextBlock::insertCursor
void insertCursor(Kate::TextCursor *cursor)
Insert cursor into this block.
Definition: katetextblock.h:188
Kate::TextBlock::cachedRangesForLine
QSet< TextRange * > cachedRangesForLine(int line) const
Return all ranges in this block which might intersect the given line and only span one line...
Definition: katetextblock.h:215
QSharedPointer
QHash
Kate::TextBlock::containsRange
bool containsRange(TextRange *range) const
Is the given range contained in this block?
Definition: katetextblock.h:175
katepartprivate_export.h
QSet
QString
QList
QVector
Kate::TextCursor
Class representing a 'clever' text cursor.
Definition: katetextcursor.h:43
Kate::TextBuffer
Class representing a text buffer.
Definition: katetextbuffer.h:48
Kate::TextRange
Class representing a 'clever' text range.
Definition: katetextrange.h:46
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