• 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
katetextrange.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  * Based on code of the SmartCursor/Range by:
6  * Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef KATE_TEXTRANGE_H
25 #define KATE_TEXTRANGE_H
26 
27 #include <ktexteditor/view.h>
28 #include <ktexteditor/movingrange.h>
29 #include <ktexteditor/movingrangefeedback.h>
30 
31 #include "katepartprivate_export.h"
32 #include "katetextcursor.h"
33 
34 namespace Kate {
35 
36 class TextBuffer;
37 
46 class KATEPART_TESTS_EXPORT TextRange : public KTextEditor::MovingRange {
47  // this is a friend, block changes might invalidate ranges...
48  friend class TextBlock;
49 
50  public:
60  TextRange (TextBuffer &buffer, const KTextEditor::Range &range, InsertBehaviors insertBehavior, EmptyBehavior emptyBehavior = AllowEmpty);
61 
65  ~TextRange ();
66 
71  void setInsertBehaviors (InsertBehaviors insertBehaviors);
72 
77  InsertBehaviors insertBehaviors () const;
78 
83  void setEmptyBehavior (EmptyBehavior emptyBehavior);
84 
89  EmptyBehavior emptyBehavior () const { return m_invalidateIfEmpty ? InvalidateIfEmpty : AllowEmpty; }
90 
95  KTextEditor::Document *document () const;
96 
103  void setRange (const KTextEditor::Range &range);
104 
113  void setRange (const KTextEditor::Cursor &start, const KTextEditor::Cursor &end) { KTextEditor::MovingRange::setRange (start, end); }
114 
119  const KTextEditor::MovingCursor &start () const { return m_start; }
120 
125  const TextCursor &startInternal() const { return m_start; }
126 
131  const KTextEditor::MovingCursor &end () const { return m_end; }
132 
137  const TextCursor &endInternal () const { return m_end; }
138 
143  const KTextEditor::Range toRange () const { return KTextEditor::Range (start().toCursor(), end().toCursor()); }
144 
149  operator const KTextEditor::Range () const { return KTextEditor::Range (start().toCursor(), end().toCursor()); }
150 
156  KTextEditor::View *view () const { return m_view; }
157 
166  void setView (KTextEditor::View *view);
167 
173  KTextEditor::Attribute::Ptr attribute () const { return m_attribute; }
174 
179  bool hasAttribute() const { return !m_attribute.isNull(); }
180 
188  void setAttribute (KTextEditor::Attribute::Ptr attribute);
189 
195  KTextEditor::MovingRangeFeedback *feedback () const { return m_feedback; }
196 
204  void setFeedback (KTextEditor::MovingRangeFeedback *feedback);
205 
211  bool attributeOnlyForViews () const { return m_attributeOnlyForViews; }
212 
217  void setAttributeOnlyForViews (bool onlyForViews);
218 
226  qreal zDepth () const { return m_zDepth; }
227 
237  void setZDepth (qreal zDepth);
238 
239  private:
243  TextRange (const TextRange &);
244 
248  TextRange &operator= (const TextRange &);
249 
258  void checkValidity (int oldStartLine = -1, int oldEndLine = -1, bool notifyAboutChange = true);
259 
267  void fixLookup (int oldStartLine, int oldEndLine, int startLine, int endLine);
268 
269  private:
274  TextBuffer &m_buffer;
275 
279  TextCursor m_start;
280 
284  TextCursor m_end;
285 
289  KTextEditor::View *m_view;
290 
294  KTextEditor::Attribute::Ptr m_attribute;
295 
299  KTextEditor::MovingRangeFeedback *m_feedback;
300 
304  qreal m_zDepth;
305 
309  bool m_attributeOnlyForViews;
310 
314  bool m_invalidateIfEmpty;
315 };
316 
317 }
318 
319 #endif
Kate::TextRange::feedback
KTextEditor::MovingRangeFeedback * feedback() const
Gets the active MovingRangeFeedback for this range.
Definition: katetextrange.h:195
Kate::TextRange::startInternal
const TextCursor & startInternal() const
Non-virtual version of start(), which is faster.
Definition: katetextrange.h:125
Kate::TextRange::start
const KTextEditor::MovingCursor & start() const
Retrieve start cursor of this range, read-only.
Definition: katetextrange.h:119
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
Kate::TextRange::endInternal
const TextCursor & endInternal() const
Nonvirtual version of end(), which is faster.
Definition: katetextrange.h:137
Kate::TextRange::emptyBehavior
EmptyBehavior emptyBehavior() const
Will this range invalidate itself if it becomes empty?
Definition: katetextrange.h:89
katepartprivate_export.h
Kate::TextRange::toRange
const KTextEditor::Range toRange() const
Convert this clever range into a dumb one.
Definition: katetextrange.h:143
Kate::TextRange::zDepth
qreal zDepth() const
Gets the current Z-depth of this range.
Definition: katetextrange.h:226
Kate::TextRange::hasAttribute
bool hasAttribute() const
Definition: katetextrange.h:179
Kate::TextRange::end
const KTextEditor::MovingCursor & end() const
Retrieve end cursor of this range, read-only.
Definition: katetextrange.h:131
Kate::TextCursor
Class representing a 'clever' text cursor.
Definition: katetextcursor.h:43
Kate::TextRange::attributeOnlyForViews
bool attributeOnlyForViews() const
Is this range's attribute only visible in views, not for example prints? Default is false...
Definition: katetextrange.h:211
Kate::TextRange::setRange
void setRange(const KTextEditor::Cursor &start, const KTextEditor::Cursor &end)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: katetextrange.h:113
Kate::TextRange::attribute
KTextEditor::Attribute::Ptr attribute() const
Gets the active Attribute for this range.
Definition: katetextrange.h:173
Kate::TextBuffer
Class representing a text buffer.
Definition: katetextbuffer.h:48
Kate::TextRange::view
KTextEditor::View * view() const
Gets the active view for this range.
Definition: katetextrange.h:156
katetextcursor.h
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