• Skip to content
  • Skip to link menu
KDE 4.3 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() const { 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 
00170     QString leadingWhitespace() const;
00171 
00175     int indentDepth (int tabWidth) const;
00176 
00180     int toVirtualColumn (int column, int tabWidth) const;
00181 
00186     int fromVirtualColumn (int column, int tabWidth) const;
00187 
00191     int virtualLength (int tabWidth) const;
00192 
00197     bool matchesAt(int column, const QString& match) const;
00198 
00202     inline bool startsWith(const QString& match) const { return m_text.startsWith (match); }
00203 
00207     inline bool endsWith(const QString& match) const { return m_text.endsWith (match); }
00208 
00220     bool searchText (uint startCol, uint endCol,const QString &text,
00221                      uint *foundAtCol, uint *matchLen,
00222                      bool casesensitive = true,
00223                      bool backwards = false) const;
00224 
00234     bool searchText (uint startCol, const QRegExp &regexp,
00235                      uint *foundAtCol, uint *matchLen,
00236                      bool backwards = false) const;
00237 
00245     inline uchar attribute (int pos) const
00246     {
00247       for (int i=0; i < m_attributesList.size(); i+=3)
00248       {
00249         if (pos >= m_attributesList[i] && pos < m_attributesList[i]+m_attributesList[i+1])
00250           return m_attributesList[i+2];
00251 
00252         if (pos < m_attributesList[i])
00253           break;
00254       }
00255 
00256       return 0;
00257     }
00258 
00263     inline const QVector<short> &ctxArray () const { return m_ctx; }
00264 
00268     inline bool noIndentBasedFolding() const { return m_flags & KateTextLine::flagNoIndentationBasedFolding; }
00269     inline bool noIndentBasedFoldingAtStart() const { return m_flags & KateTextLine::flagNoIndentationBasedFoldingAtStart; }
00274     inline const QVector<int> &foldingListArray () const { return m_foldingList; }
00275 
00280     inline const QVector<unsigned short> &indentationDepthArray () const { return m_indentationDepth; }
00281 
00287     void insertText (int pos, const QString& insText);
00288 
00294     void removeText (uint pos, uint delLen);
00295 
00300     void truncate(int newLen);
00301 
00306     inline void setHlLineContinue (bool cont)
00307     {
00308       if (cont) m_flags = m_flags | KateTextLine::flagHlContinue;
00309       else m_flags = m_flags & ~ KateTextLine::flagHlContinue;
00310     }
00311 
00316     inline void setAutoWrapped (bool wrapped)
00317     {
00318       if (wrapped) m_flags = m_flags | KateTextLine::flagAutoWrapped;
00319       else m_flags = m_flags & ~ KateTextLine::flagAutoWrapped;
00320     }
00321 
00326     inline void setContext (QVector<short> &val) { m_ctx = val; }
00327 
00331     inline void setNoIndentBasedFolding(bool val)
00332     {
00333       if (val) m_flags = m_flags | KateTextLine::flagNoIndentationBasedFolding;
00334       else m_flags = m_flags & ~ KateTextLine::flagNoIndentationBasedFolding;
00335     }
00336 
00337     inline void setNoIndentBasedFoldingAtStart(bool val)
00338     {
00339       if (val) m_flags = m_flags | KateTextLine::flagNoIndentationBasedFoldingAtStart;
00340       else m_flags = m_flags & ~ KateTextLine::flagNoIndentationBasedFoldingAtStart;
00341     }
00342 
00347     inline void setFoldingList (QVector<int> &val) { m_foldingList = val; }
00348 
00353     inline void setIndentationDepth (QVector<unsigned short> &val) { m_indentationDepth = val; }
00354 
00358   public:
00359     void addAttribute (int start, int length, int attribute);
00360 
00361     void clearAttributes () { m_attributesList.clear (); }
00362 
00363     const QVector<int> &attributesList () const { return m_attributesList; }
00364 
00368   private:
00372     QString m_text;
00373 
00378     QVector<int> m_attributesList;
00379 
00383     QVector<short> m_ctx;
00384 
00388     QVector<int> m_foldingList;
00389 
00393     QVector<unsigned short> m_indentationDepth;
00394 
00398     uchar m_flags;
00399 };
00400 
00401 #endif
00402 
00403 // 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
  • 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