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

KTextEditor

cursor.cpp

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 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "cursor.h"
00020 
00021 #include "range.h"
00022 
00023 using namespace KTextEditor;
00024 
00025 Cursor::Cursor( )
00026   : m_line(0)
00027   , m_column(0)
00028   , m_range(0L)
00029 {
00030 }
00031 
00032 Cursor::Cursor( int _line, int _column )
00033   : m_line(_line)
00034   , m_column(_column)
00035   , m_range(0L)
00036 {
00037 }
00038 
00039 Cursor::Cursor(const Cursor& copy)
00040   : m_line(copy.line())
00041   , m_column(copy.column())
00042   , m_range(0L)
00043 {
00044 }
00045 
00046 bool Cursor::isValid() const
00047 {
00048   return m_line >= 0 && m_column >= 0;
00049 }
00050 
00051 Cursor Cursor::invalid( )
00052 {
00053   return Cursor (-1,-1);
00054 }
00055 
00056 Cursor Cursor::start()
00057 {
00058   return Cursor (0, 0);
00059 }
00060 
00061 int Cursor::line() const
00062 {
00063   return m_line;
00064 }
00065 
00066 void Cursor::setLine( int line )
00067 {
00068   if (line == this->line())
00069     return;
00070 
00071   Cursor old = *this;
00072 
00073   m_line = line;
00074 
00075   cursorChangedDirectly(old);
00076 }
00077 
00078 int Cursor::column() const
00079 {
00080     return m_column;
00081 }
00082 
00083 void Cursor::setColumn( int column )
00084 {
00085   if (column == this->column())
00086     return;
00087 
00088   Cursor old = *this;
00089 
00090   m_column = column;
00091 
00092   cursorChangedDirectly(old);
00093 }
00094 
00095 void Cursor::setPosition( const Cursor & pos )
00096 {
00097   if (pos == *this)
00098     return;
00099 
00100   Cursor old = *this;
00101 
00102   m_line = pos.line();
00103   m_column = pos.column();
00104 
00105   cursorChangedDirectly(old);
00106 }
00107 
00108 bool Cursor::isSmartCursor( ) const
00109 {
00110   return false;
00111 }
00112 
00113 void Cursor::setPosition(int line, int column)
00114 {
00115     setPosition(Cursor(line, column));
00116 }
00117 
00118 void Cursor::position (int &_line, int &_column) const
00119 {
00120   _line = line(); _column = column();
00121 }
00122 
00123 Range* Cursor::range() const
00124 {
00125     return m_range;
00126 }
00127 
00128 Cursor::~ Cursor( )
00129 {
00130 }
00131 
00132 void Cursor::setRange( Range * range )
00133 {
00134   m_range = range;
00135 }
00136 
00137 void KTextEditor::Cursor::cursorChangedDirectly(const Cursor& from)
00138 {
00139   if (m_range) {
00140     if (this == &m_range->start())
00141       m_range->rangeChanged(this, Range(from, m_range->end()));
00142     else
00143       m_range->rangeChanged(this, Range(m_range->start(), from));
00144   }
00145 }
00146 
00147 bool KTextEditor::Cursor::atStartOfLine( ) const
00148 {
00149   return m_column == 0;
00150 }
00151 
00152 bool KTextEditor::Cursor::atStartOfDocument( ) const
00153 {
00154   return m_line == 0 && m_column == 0;
00155 }
00156 
00157 SmartCursor * KTextEditor::Cursor::toSmartCursor( ) const
00158 {
00159   return 0L;
00160 }
00161 
00162 // 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