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

Kate

katetextline.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001-2005 Christoph Cullmann <cullmann@kde.org>
00003    Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
00004 
00005    Based on:
00006      KateTextLine : 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 __KATE_TEXTLINE_H__
00024 #define __KATE_TEXTLINE_H__
00025 
00026 #include <ksharedptr.h>
00027 
00028 #include <QtCore/QString>
00029 #include <QtCore/QVector>
00030 
00031 
00039 class KateTextLine : public KShared
00040 {
00041   public:
00045     typedef KSharedPtr<KateTextLine> Ptr;
00046 
00047   public:
00051     enum Flags
00052     {
00053       flagHlContinue = 1,
00054       flagAutoWrapped = 2,
00055       flagFoldingColumnsOutdated = 4,
00056       flagNoIndentationBasedFolding = 8,
00057       flagNoIndentationBasedFoldingAtStart = 16
00058     };
00059 
00060   public:
00066     KateTextLine ();
00067     
00068     KateTextLine (const QChar *data, int length);
00069 
00073     ~KateTextLine ();
00074 
00078   public:
00082     inline void setFoldingColumnsOutdated(bool set) { if (set) m_flags |= KateTextLine::flagFoldingColumnsOutdated; else m_flags&=
00083                                                       (~KateTextLine::flagFoldingColumnsOutdated);}
00084 
00088      inline bool foldingColumnsOutdated() { return m_flags & KateTextLine::flagFoldingColumnsOutdated; }
00089 
00090 
00094     inline int length() const { return m_text.length(); }
00095 
00100     inline bool hlLineContinue () const { return m_flags & KateTextLine::flagHlContinue; }
00101 
00106     inline bool isAutoWrapped () const { return m_flags & KateTextLine::flagAutoWrapped; }
00107 
00112     int firstChar() const;
00113 
00118     int lastChar() const;
00119 
00126     int nextNonSpaceChar(uint pos) const;
00127 
00134     int previousNonSpaceChar(int pos) const;
00135 
00140     inline QChar at (int column) const
00141     {
00142       if (column >= 0 && column < m_text.length())
00143         return m_text[column];
00144 
00145       return QChar();
00146     }
00147 
00151     inline QChar operator[](int column) const
00152     {
00153       if (column >= 0 && column < m_text.length())
00154         return m_text[column];
00155 
00156       return QChar();
00157     }
00158 
00162     inline const QString& string() const { return m_text; }
00163 
00167     inline QString string(int column, int length) const
00168     { return m_text.mid(column, length); }
00169 
00173     int indentDepth (int tabWidth) const;
00174 
00178     int toVirtualColumn (int column, int tabWidth) const;
00179 
00184     int fromVirtualColumn (int column, int tabWidth) const;
00185 
00189     int virtualLength (int tabWidth) const;
00190 
00195     bool matchesAt(int column, const QString& match) const;
00196 
00200     inline bool startsWith(const QString& match) const { return m_text.startsWith (match); }
00201 
00205     inline bool endsWith(const QString& match) const { return m_text.endsWith (match); }
00206 
00218     bool searchText (uint startCol, uint endCol,const QString &text,
00219                      uint *foundAtCol, uint *matchLen,
00220                      bool casesensitive = true,
00221                      bool backwards = false);
00222 
00232     bool searchText (uint startCol, const QRegExp &regexp,
00233                      uint *foundAtCol, uint *matchLen,
00234                      bool backwards = false);
00235 
00243     inline uchar attribute (int pos) const
00244     {
00245       for (int i=0; i < m_attributesList.size(); i+=3)
00246       {
00247         if (pos >= m_attributesList[i] && pos < m_attributesList[i]+m_attributesList[i+1])
00248           return m_attributesList[i+2];
00249 
00250         if (pos < m_attributesList[i])
00251           break;
00252       }
00253 
00254       return 0;
00255     }
00256 
00261     inline const QVector<short> &ctxArray () const { return m_ctx; }
00262 
00266     inline bool noIndentBasedFolding() const { return m_flags & KateTextLine::flagNoIndentationBasedFolding; }
00267     inline bool noIndentBasedFoldingAtStart() const { return m_flags & KateTextLine::flagNoIndentationBasedFoldingAtStart; }
00272     inline const QVector<int> &foldingListArray () const { return m_foldingList; }
00273 
00278     inline const QVector<unsigned short> &indentationDepthArray () const { return m_indentationDepth; }
00279 
00285     void insertText (int pos, const QString& insText);
00286 
00292     void removeText (uint pos, uint delLen);
00293 
00298     void truncate(int newLen);
00299 
00304     inline void setHlLineContinue (bool cont)
00305     {
00306       if (cont) m_flags = m_flags | KateTextLine::flagHlContinue;
00307       else m_flags = m_flags & ~ KateTextLine::flagHlContinue;
00308     }
00309 
00314     inline void setAutoWrapped (bool wrapped)
00315     {
00316       if (wrapped) m_flags = m_flags | KateTextLine::flagAutoWrapped;
00317       else m_flags = m_flags & ~ KateTextLine::flagAutoWrapped;
00318     }
00319 
00324     inline void setContext (QVector<short> &val) { m_ctx = val; }
00325 
00329     inline void setNoIndentBasedFolding(bool val)
00330     {
00331       if (val) m_flags = m_flags | KateTextLine::flagNoIndentationBasedFolding;
00332       else m_flags = m_flags & ~ KateTextLine::flagNoIndentationBasedFolding;
00333     }
00334 
00335     inline void setNoIndentBasedFoldingAtStart(bool val)
00336     {
00337       if (val) m_flags = m_flags | KateTextLine::flagNoIndentationBasedFoldingAtStart;
00338       else m_flags = m_flags & ~ KateTextLine::flagNoIndentationBasedFoldingAtStart;
00339     }
00340 
00345     inline void setFoldingList (QVector<int> &val) { m_foldingList = val; }
00346 
00351     inline void setIndentationDepth (QVector<unsigned short> &val) { m_indentationDepth = val; }
00352 
00356   public:
00357     void addAttribute (int start, int length, int attribute);
00358 
00359     void clearAttributes () { m_attributesList.clear (); }
00360 
00361     const QVector<int> &attributesList () const { return m_attributesList; }
00362 
00366   private:
00370     QString m_text;
00371 
00376     QVector<int> m_attributesList;
00377 
00381     QVector<short> m_ctx;
00382 
00386     QVector<int> m_foldingList;
00387 
00391     QVector<unsigned short> m_indentationDepth;
00392 
00396     uchar m_flags;
00397 };
00398 
00399 #endif
00400 
00401 // kate: space-indent on; indent-width 2; replace-tabs on;

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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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