• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katetextcursor.h

Go to the documentation of this file.
00001 /*  This file is part of the Kate project.
00002  *
00003  *  Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
00004  *
00005  *  Based on code of the SmartCursor/Range by:
00006  *  Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org>
00007  *
00008  *  This library is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU Library General Public
00010  *  License as published by the Free Software Foundation; either
00011  *  version 2 of the License, or (at your option) any later version.
00012  *
00013  *  This library is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  *  Library General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Library General Public License
00019  *  along with this library; see the file COPYING.LIB.  If not, write to
00020  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  *  Boston, MA 02110-1301, USA.
00022  */
00023 
00024 #ifndef KATE_TEXTCURSOR_H
00025 #define KATE_TEXTCURSOR_H
00026 
00027 #include <ktexteditor/movingcursor.h>
00028 
00029 #include "katepartprivate_export.h"
00030 #include "katetextblock.h"
00031 
00032 namespace Kate {
00033 
00034 class TextBuffer;
00035 class TextBlock;
00036 class TextRange;
00037 
00043 class KATEPART_TESTS_EXPORT TextCursor : public KTextEditor::MovingCursor {
00044   // range wants direct access to some internals
00045   friend class TextRange;
00046 
00047   // this is a friend, because this is needed to efficiently transfer cursors from on to an other block
00048   friend class TextBlock;
00049 
00050   private:
00058     TextCursor (TextBuffer &buffer, TextRange *range, const KTextEditor::Cursor &position, InsertBehavior insertBehavior);
00059 
00060   public:
00067     TextCursor (TextBuffer &buffer, const KTextEditor::Cursor &position, InsertBehavior insertBehavior);
00068 
00072     ~TextCursor ();
00073 
00078     void setInsertBehavior (InsertBehavior insertBehavior) { m_moveOnInsert = insertBehavior == MoveOnInsert; }
00079 
00084     InsertBehavior insertBehavior () const { return m_moveOnInsert ? MoveOnInsert : StayOnInsert; }
00085 
00090     KTextEditor::Document *document () const;
00091 
00097     void setPosition (const TextCursor& position);
00098 
00104     void setPosition (const KTextEditor::Cursor& position);
00105 
00114     void setPosition (int line, int column) { KTextEditor::MovingCursor::setPosition (line, column); }
00115 
00120     int line() const;
00121 
00127     int lineInternal() const
00128     {
00129       // invalid cursor have no block
00130       if (!m_block)
00131         return -1;
00132 
00133       // else, calculate real line
00134       return m_block->startLine () + m_line;
00135     }
00136 
00141     int column() const { return m_column; }
00142 
00147     int columnInternal() const { return m_column; }
00148 
00153     KTextEditor::MovingRange *range () const;
00154 
00159     Kate::TextRange *kateRange () const { return m_range; }
00160 
00165     TextBlock *block () const { return m_block; }
00166 
00171     int lineInBlock () const { if (m_block) return m_line; return -1; }
00172 
00173   private:
00182     void setPosition (const KTextEditor::Cursor& position, bool init);
00183 
00184   private:
00189     TextBuffer &m_buffer;
00190 
00196     TextRange * const m_range;
00197 
00201     TextBlock *m_block;
00202 
00206     int m_line;
00207 
00211     int m_column;
00212 
00216     bool m_moveOnInsert;
00217 };
00218 
00219 }
00220 
00221 #endif

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal