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

KTextEditor

range.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_RANGE_H
00024 #define KDELIBS_KTEXTEDITOR_RANGE_H
00025 
00026 #include <ktexteditor/ktexteditor_export.h>
00027 #include <ktexteditor/cursor.h>
00028 
00029 
00030 namespace KTextEditor
00031 {
00032 class SmartRange;
00033 
00053 class KTEXTEDITOR_EXPORT Range
00054 {
00055   friend class Cursor;
00056 
00057   public:
00062     Range();
00063 
00071     Range(const Cursor& start, const Cursor& end);
00072 
00080     Range(const Cursor& start, int width);
00081 
00089     Range(const Cursor& start, int endLine, int endColumn);
00090 
00099     Range(int startLine, int startColumn, int endLine, int endColumn);
00100 
00106     Range(const Range& copy);
00107 
00111     //Do not remove! Needed for inheritance.
00112     virtual ~Range();
00113 
00117     virtual bool isValid() const;
00118 
00122     static Range invalid();
00123 
00127     virtual bool isSmartRange() const;
00128 
00132     virtual SmartRange* toSmartRange() const;
00133 
00157     Cursor& start();
00158 
00166     const Cursor& start() const;
00167 
00187     Cursor& end();
00188 
00196     const Cursor& end() const;
00197 
00203     void setBothLines(int line);
00204 
00210     void setBothColumns(int column);
00211 
00217     virtual void setRange(const Range& range);
00218 
00229     void setRange(const Cursor& start, const Cursor& end);
00230 
00238     virtual bool expandToRange(const Range& range);
00239 
00247     virtual bool confineToRange(const Range& range);
00248 
00256     bool onSingleLine() const;
00257 
00264     int numberOfLines() const;
00265 
00272     int columnWidth() const;
00273 
00280     bool isEmpty() const;
00281 
00282     //BEGIN comparison functions
00299     bool contains(const Range& range) const;
00300 
00308     bool contains(const Cursor& cursor) const;
00309 
00317     bool containsLine(int line) const;
00318 
00326     bool containsColumn(int column) const;
00327 
00335     bool overlaps(const Range& range) const;
00336 
00344     bool overlapsLine(int line) const;
00345 
00356     bool overlapsColumn(int column) const;
00357 
00371     int positionRelativeToCursor(const Cursor& cursor) const;
00372 
00385     int positionRelativeToLine(int line) const;
00386 
00396     bool boundaryAtCursor(const Cursor& cursor) const;
00397 
00407     bool boundaryOnLine(int line) const;
00408 
00418     bool boundaryOnColumn(int column) const;
00420     //END
00421 
00430     Range intersect(const Range& range) const;
00431 
00440     Range encompass(const Range& range) const;
00441 
00451     inline Range& operator=(const Range& rhs)
00452       { setRange(rhs); return *this; }
00453 
00462     inline friend Range operator+(const Range& r1, const Range& r2)
00463       { return Range(r1.start() + r2.start(), r1.end() + r2.end()); }
00464 
00473     inline friend Range& operator+=(Range& r1, const Range& r2)
00474       { r1.setRange(r1.start() + r2.start(), r1.end() + r2.end()); return r1; }
00475 
00485     inline friend Range operator-(const Range& r1, const Range& r2)
00486       { return Range(r1.start() - r2.start(), r1.end() - r2.end()); }
00487 
00496     inline friend Range& operator-=(Range& r1, const Range& r2)
00497       { r1.setRange(r1.start() - r2.start(), r1.end() - r2.end()); return r1; }
00498 
00507     inline friend Range operator&(const Range& r1, const Range& r2)
00508       { return r1.intersect(r2); }
00509 
00518     inline friend Range& operator&=(Range& r1, const Range& r2)
00519       { r1.setRange(r1.intersect(r2)); return r1; }
00520 
00529     inline friend bool operator==(const Range& r1, const Range& r2)
00530       { return r1.start() == r2.start() && r1.end() == r2.end(); }
00531 
00540     inline friend bool operator!=(const Range& r1, const Range& r2)
00541       { return r1.start() != r2.start() || r1.end() != r2.end(); }
00542 
00552     inline friend bool operator>(const Range& r1, const Range& r2)
00553       { return r1.start() > r2.end(); }
00554 
00564     inline friend bool operator<(const Range& r1, const Range& r2)
00565       { return r1.end() < r2.start(); }
00566 
00570     inline friend QDebug operator<< (QDebug s, const Range& range) {
00571       if (&range)
00572         s << "[" << range.start() << " -> " << range.end() << "]";
00573       else
00574         s << "(null range)";
00575       return s;
00576     }
00577 
00578   protected:
00587     Range(Cursor* start, Cursor* end);
00588 
00597     virtual void rangeChanged(Cursor* cursor, const Range& from);
00598 
00604     Cursor* m_start;
00605 
00611     Cursor* m_end;
00612 };
00613 
00614 }
00615 
00616 #endif
00617 
00618 // 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