• 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
katetextcursor.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_TEXTCURSOR_H
25 #define KATE_TEXTCURSOR_H
26 
27 #include <ktexteditor/movingcursor.h>
28 
29 #include "katepartprivate_export.h"
30 #include "katetextblock.h"
31 
32 namespace Kate {
33 
34 class TextBuffer;
35 class TextBlock;
36 class TextRange;
37 
43 class KATEPART_TESTS_EXPORT TextCursor : public KTextEditor::MovingCursor {
44  // range wants direct access to some internals
45  friend class TextRange;
46 
47  // this is a friend, because this is needed to efficiently transfer cursors from on to an other block
48  friend class TextBlock;
49 
50  private:
58  TextCursor (TextBuffer &buffer, TextRange *range, const KTextEditor::Cursor &position, InsertBehavior insertBehavior);
59 
60  public:
67  TextCursor (TextBuffer &buffer, const KTextEditor::Cursor &position, InsertBehavior insertBehavior);
68 
72  ~TextCursor ();
73 
78  void setInsertBehavior (InsertBehavior insertBehavior) { m_moveOnInsert = insertBehavior == MoveOnInsert; }
79 
84  InsertBehavior insertBehavior () const { return m_moveOnInsert ? MoveOnInsert : StayOnInsert; }
85 
90  KTextEditor::Document *document () const;
91 
97  void setPosition (const TextCursor& position);
98 
104  void setPosition (const KTextEditor::Cursor& position);
105 
114  void setPosition (int line, int column) { KTextEditor::MovingCursor::setPosition (line, column); }
115 
120  int line() const;
121 
127  int lineInternal() const
128  {
129  // invalid cursor have no block
130  if (!m_block)
131  return -1;
132 
133  // else, calculate real line
134  return m_block->startLine () + m_line;
135  }
136 
141  int column() const { return m_column; }
142 
147  int columnInternal() const { return m_column; }
148 
153  KTextEditor::MovingRange *range () const;
154 
159  Kate::TextRange *kateRange () const { return m_range; }
160 
165  TextBlock *block () const { return m_block; }
166 
171  int lineInBlock () const { if (m_block) return m_line; return -1; }
172 
173  private:
177  TextCursor (const TextCursor &);
178 
182  TextCursor &operator= (const TextCursor &);
183 
192  void setPosition (const KTextEditor::Cursor& position, bool init);
193 
194  private:
199  TextBuffer &m_buffer;
200 
206  TextRange * const m_range;
207 
211  TextBlock *m_block;
212 
216  int m_line;
217 
221  int m_column;
222 
226  bool m_moveOnInsert;
227 };
228 
229 }
230 
231 #endif
katetextblock.h
Kate::TextCursor::setPosition
void setPosition(int line, int column)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: katetextcursor.h:114
Kate::TextCursor::column
int column() const
Retrieve the column on which this cursor is situated.
Definition: katetextcursor.h:141
Kate::TextCursor::block
TextBlock * block() const
Get block this cursor belongs to, if any.
Definition: katetextcursor.h:165
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
Kate::TextCursor::lineInternal
int lineInternal() const
Non-virtual version of line(), which is faster.
Definition: katetextcursor.h:127
katepartprivate_export.h
Kate::TextCursor::lineInBlock
int lineInBlock() const
Get offset into block this cursor belongs to, if any.
Definition: katetextcursor.h:171
Kate::TextCursor::kateRange
Kate::TextRange * kateRange() const
Get range this cursor belongs to, if any.
Definition: katetextcursor.h:159
Kate::TextCursor
Class representing a 'clever' text cursor.
Definition: katetextcursor.h:43
Kate::TextCursor::insertBehavior
InsertBehavior insertBehavior() const
Get current insert behavior.
Definition: katetextcursor.h:84
Kate::TextBuffer
Class representing a text buffer.
Definition: katetextbuffer.h:48
Kate::TextCursor::setInsertBehavior
void setInsertBehavior(InsertBehavior insertBehavior)
Set insert behavior.
Definition: katetextcursor.h:78
Kate::TextCursor::columnInternal
int columnInternal() const
Non-virtual version of column(), which is faster.
Definition: katetextcursor.h:147
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