• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katetextline.h

Go to the documentation of this file.
00001 /*  This file is part of the Kate project.
00002  *
00003  *  Copyright (C) 2010 Christoph Cullmann <cullmann@kde.org>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Library General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU Library General Public License
00016  *  along with this library; see the file COPYING.LIB.  If not, write to
00017  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  *  Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef KATE_TEXTLINE_H
00022 #define KATE_TEXTLINE_H
00023 
00024 #include <QtCore/QVector>
00025 #include <QtCore/QString>
00026 #include <QtCore/QSharedPointer>
00027 
00028 #include "katepartprivate_export.h"
00029 
00030 namespace Kate {
00031 
00037 class KATEPART_TESTS_EXPORT TextLineData {
00041   friend class TextBuffer;
00042   friend class TextBlock;
00043 
00044   public:
00048     enum Flags
00049     {
00050       flagHlContinue = 1,
00051       flagAutoWrapped = 2,
00052       flagFoldingColumnsOutdated = 4,
00053       flagNoIndentationBasedFolding = 8,
00054       flagNoIndentationBasedFoldingAtStart = 16
00055     };
00056 
00060     TextLineData ();
00061 
00066     TextLineData (const QString &text);
00067 
00071     ~TextLineData ();
00072 
00077     const QString &text () const { return m_text; }
00078 
00083     int firstChar() const;
00084 
00089     int lastChar() const;
00090 
00097     int nextNonSpaceChar(int pos) const;
00098 
00105     int previousNonSpaceChar(int pos) const;
00106 
00113     inline QChar at (int column) const
00114     {
00115       if (column >= 0 && column < m_text.length())
00116         return m_text[column];
00117 
00118       return QChar();
00119     }
00120 
00126     inline QChar operator[](int column) const
00127     {
00128       if (column >= 0 && column < m_text.length())
00129         return m_text[column];
00130 
00131       return QChar();
00132     }
00133 
00138     void setFoldingColumnsOutdated(bool set)
00139     {
00140       if (set) m_flags |= flagFoldingColumnsOutdated;
00141       else m_flags &= (~flagFoldingColumnsOutdated);
00142     }
00143 
00148     bool foldingColumnsOutdated() const { return m_flags & flagFoldingColumnsOutdated; }
00149 
00153     int length() const { return m_text.length(); }
00154 
00160     bool hlLineContinue () const { return m_flags & flagHlContinue; }
00161 
00167     bool isAutoWrapped () const { return m_flags & flagAutoWrapped; }
00168 
00173     const QString& string() const { return m_text; }
00174 
00181     QString string (int column, int length) const
00182     { return m_text.mid(column, length); }
00183 
00188     QString leadingWhitespace() const;
00189 
00193     int indentDepth (int tabWidth) const;
00194 
00198     int toVirtualColumn (int column, int tabWidth) const;
00199 
00204     int fromVirtualColumn (int column, int tabWidth) const;
00205 
00209     int virtualLength (int tabWidth) const;
00210 
00215     bool matchesAt(int column, const QString& match) const;
00216 
00220     bool startsWith(const QString& match) const { return m_text.startsWith (match); }
00221 
00225     bool endsWith(const QString& match) const { return m_text.endsWith (match); }
00226 
00234     int attribute (int pos) const
00235     {
00236       for (int i=0; i < m_attributesList.size(); i+=3)
00237       {
00238         if (pos >= m_attributesList[i] && pos < m_attributesList[i]+m_attributesList[i+1])
00239           return m_attributesList[i+2];
00240 
00241         if (pos < m_attributesList[i])
00242           break;
00243       }
00244 
00245       return 0;
00246     }
00247 
00252     const QVector<short> &ctxArray () const { return m_ctx; }
00253 
00257     bool noIndentBasedFolding() const { return m_flags & flagNoIndentationBasedFolding; }
00258 
00262     bool noIndentBasedFoldingAtStart() const { return m_flags & flagNoIndentationBasedFoldingAtStart; }
00263 
00268     const QVector<int> &foldingListArray () const { return m_foldingList; }
00269 
00274     const QVector<unsigned short> &indentationDepthArray () const { return m_indentationDepth; }
00275 
00282     void addAttribute (int start, int length, int attribute);
00283 
00287     void clearAttributes () { m_attributesList.clear (); }
00288 
00293     const QVector<int> &attributesList () const { return m_attributesList; }
00294 
00299     void setHlLineContinue (bool cont)
00300     {
00301       if (cont) m_flags = m_flags | flagHlContinue;
00302       else m_flags = m_flags & ~ flagHlContinue;
00303     }
00304 
00309     void setAutoWrapped (bool wrapped)
00310     {
00311       if (wrapped) m_flags = m_flags | flagAutoWrapped;
00312       else m_flags = m_flags & ~ flagAutoWrapped;
00313     }
00314 
00319     void setContext (QVector<short> &val) { m_ctx = val; }
00320 
00325     void setNoIndentBasedFolding(bool val)
00326     {
00327       if (val) m_flags = m_flags | flagNoIndentationBasedFolding;
00328       else m_flags = m_flags & ~ flagNoIndentationBasedFolding;
00329     }
00330 
00335     void setNoIndentBasedFoldingAtStart(bool val)
00336     {
00337       if (val) m_flags = m_flags | flagNoIndentationBasedFoldingAtStart;
00338       else m_flags = m_flags & ~ flagNoIndentationBasedFoldingAtStart;
00339     }
00340 
00345     void setFoldingList (QVector<int> &val) { m_foldingList = val; }
00346 
00351     void setIndentationDepth (QVector<unsigned short> &val) { m_indentationDepth = val; }
00352 
00353   private:
00359     QString &textReadWrite () { return m_text; }
00360 
00361   private:
00365     QString m_text;
00366 
00371     QVector<int> m_attributesList;
00372 
00376     QVector<short> m_ctx;
00377 
00381     QVector<int> m_foldingList;
00382 
00386     QVector<unsigned short> m_indentationDepth;
00387 
00391     uchar m_flags;
00392 };
00393 
00397 typedef QSharedPointer<TextLineData> TextLine;
00398 
00399 }
00400 
00401 #endif

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