• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KTextEditor

cursor.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org>
00003    Copyright (C) 2001-2005 Christoph Cullmann <cullmann@kde.org>
00004    Copyright (C) 2002 Christian Couder <christian@kdevelop.org>
00005    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00006    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
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 version 2 as published by the Free Software Foundation.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef KDELIBS_KTEXTEDITOR_CURSOR_H
00024 #define KDELIBS_KTEXTEDITOR_CURSOR_H
00025 
00026 #include <ktexteditor/ktexteditor_export.h>
00027 #include <kdebug.h>
00028 
00029 namespace KTextEditor
00030 {
00031 class Document;
00032 class Range;
00033 class SmartCursor;
00034 
00060 class KTEXTEDITOR_EXPORT Cursor
00061 {
00062   friend class Range;
00063 
00064   public:
00068     Cursor();
00069 
00076     Cursor(int line, int column);
00077 
00084     Cursor(const Cursor& copy);
00085 
00089     //Do not remove! Needed for inheritance.
00090     virtual ~Cursor();
00091 
00099     virtual bool isValid() const;
00100 
00104     virtual bool isSmartCursor() const;
00105 
00109     virtual SmartCursor* toSmartCursor() const;
00110 
00114     static Cursor invalid();
00115 
00119     static Cursor start();
00120 
00134     virtual void setPosition(const Cursor& position);
00135 
00144     void setPosition(int line, int column);
00145 
00150     virtual int line() const;
00151 
00156     virtual void setLine(int line);
00157 
00162     int column() const;
00163 
00168     virtual void setColumn(int column);
00169 
00174     bool atStartOfLine() const;
00175 
00180     bool atStartOfDocument() const;
00181 
00187     void position (int &line, int &column) const;
00189 
00193     Range* range() const;
00194 
00201     inline Cursor& operator=(const Cursor& cursor)
00202       { setPosition(cursor); return *this; }
00203 
00210     inline friend Cursor operator+(const Cursor& c1, const Cursor& c2)
00211       { return Cursor(c1.line() + c2.line(), c1.column() + c2.column()); }
00212 
00219     inline friend Cursor& operator+=(Cursor& c1, const Cursor& c2)
00220       { c1.setPosition(c1.line() + c2.line(), c1.column() + c2.column()); return c1; }
00221 
00230     inline friend Cursor operator-(const Cursor& c1, const Cursor& c2)
00231       { return Cursor(c1.line() - c2.line(), c1.column() - c2.column()); }
00232 
00239     inline friend Cursor& operator-=(Cursor& c1, const Cursor& c2)
00240       { c1.setPosition(c1.line() - c2.line(), c1.column() - c2.column()); return c1; }
00241 
00252     inline friend bool operator==(const Cursor& c1, const Cursor& c2)
00253       { return c1.line() == c2.line() && c1.column() == c2.column(); }
00254 
00261     inline friend bool operator!=(const Cursor& c1, const Cursor& c2)
00262       { return !(c1 == c2); }
00263 
00271     inline friend bool operator>(const Cursor& c1, const Cursor& c2)
00272       { return c1.line() > c2.line() || (c1.line() == c2.line() && c1.m_column > c2.m_column); }
00273 
00281     inline friend bool operator>=(const Cursor& c1, const Cursor& c2)
00282       { return c1.line() > c2.line() || (c1.line() == c2.line() && c1.m_column >= c2.m_column); }
00283 
00291     inline friend bool operator<(const Cursor& c1, const Cursor& c2)
00292       { return !(c1 >= c2); }
00293 
00301     inline friend bool operator<=(const Cursor& c1, const Cursor& c2)
00302       { return !(c1 > c2); }
00303 
00307     inline friend QDebug operator<< (QDebug s, const Cursor& cursor) {
00308       if (&cursor)
00309         s.nospace() << "(" << cursor.line() << ", " << cursor.column() << ")";
00310       else
00311         s.nospace() << "(null cursor)";
00312       return s.space();
00313     }
00314 
00315    protected:
00323     virtual void setRange(Range* range);
00324 
00330     void cursorChangedDirectly(const Cursor& from);
00331 
00337     int m_line;
00338 
00344     int m_column;
00345 
00351     Range* m_range;
00352 };
00353 
00354 }
00355 
00356 #endif
00357 
00358 // kate: space-indent on; indent-width 2; replace-tabs on;

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Modules
  • 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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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