katetextline.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __KATE_TEXTLINE_H__
00024 #define __KATE_TEXTLINE_H__
00025
00026 #include <ksharedptr.h>
00027
00028 #include <qmemarray.h>
00029 #include <qstring.h>
00030
00038 class KateTextLine : public KShared
00039 {
00040 public:
00044 typedef KSharedPtr<KateTextLine> Ptr;
00045
00046 public:
00050 enum Flags
00051 {
00052 flagNoOtherData = 0x1,
00053 flagHlContinue = 0x2,
00054 flagVisible = 0x4,
00055 flagAutoWrapped = 0x8
00056 };
00057
00058 public:
00064 KateTextLine ();
00065
00069 ~KateTextLine ();
00070
00074 public:
00079 inline uint length() const { return m_text.length(); }
00080
00085 inline bool hlLineContinue () const { return m_flags & KateTextLine::flagHlContinue; }
00086
00091 inline bool isVisible () const { return m_flags & KateTextLine::flagVisible; }
00092
00097 inline bool isAutoWrapped () const { return m_flags & KateTextLine::flagAutoWrapped; }
00098
00103 int firstChar() const;
00104
00109 int lastChar() const;
00110
00117 int nextNonSpaceChar(uint pos) const;
00118
00125 int previousNonSpaceChar(uint pos) const;
00126
00133 inline QChar getChar (uint pos) const { return m_text[pos]; }
00134
00139 inline const QChar *text() const { return m_text.unicode(); }
00140
00145 inline uchar *attributes () const { return m_attributes.data(); }
00146
00151 inline const QString& string() const { return m_text; }
00152
00159 inline QString string(uint startCol, uint length) const
00160 { return m_text.mid(startCol, length); }
00161
00168 inline QConstString constString(uint startCol, uint length) const
00169 { return QConstString(m_text.unicode() + startCol, length); }
00170
00175 const QChar *firstNonSpace() const;
00176
00182 uint indentDepth (uint tabwidth) const;
00183
00191 int cursorX(uint pos, uint tabChars) const;
00192
00199 bool stringAtPos(uint pos, const QString& match) const;
00200
00206 bool startingWith(const QString& match) const;
00207
00213 bool endingWith(const QString& match) const;
00214
00225 bool searchText (uint startCol, const QString &text,
00226 uint *foundAtCol, uint *matchLen,
00227 bool casesensitive = true,
00228 bool backwards = false);
00229
00239 bool searchText (uint startCol, const QRegExp ®exp,
00240 uint *foundAtCol, uint *matchLen,
00241 bool backwards = false);
00242
00248 inline uchar attribute (uint pos) const
00249 {
00250 if (pos < m_attributes.size()) return m_attributes[pos];
00251 return 0;
00252 }
00253
00258 inline const QMemArray<short> &ctxArray () const { return m_ctx; };
00259
00264 inline const QMemArray<signed char> &foldingListArray () const { return m_foldingList; };
00265
00270 inline const QMemArray<unsigned short> &indentationDepthArray () const { return m_indentationDepth; };
00271
00279 void insertText (uint pos, uint insLen, const QChar *insText, uchar *insAttribs = 0);
00280
00286 void removeText (uint pos, uint delLen);
00287
00292 void truncate(uint newLen);
00293
00298 inline void setHlLineContinue (bool cont)
00299 {
00300 if (cont) m_flags = m_flags | KateTextLine::flagHlContinue;
00301 else m_flags = m_flags & ~ KateTextLine::flagHlContinue;
00302 }
00303
00308 inline void setVisible(bool val)
00309 {
00310 if (val) m_flags = m_flags | KateTextLine::flagVisible;
00311 else m_flags = m_flags & ~ KateTextLine::flagVisible;
00312 }
00313
00318 inline void setAutoWrapped (bool wrapped)
00319 {
00320 if (wrapped) m_flags = m_flags | KateTextLine::flagAutoWrapped;
00321 else m_flags = m_flags & ~ KateTextLine::flagAutoWrapped;
00322 }
00323
00330 void setAttribs(uchar attribute, uint start, uint end);
00331
00336 inline void setContext (QMemArray<short> &val) { m_ctx.assign (val); }
00337
00342 inline void setFoldingList (QMemArray<signed char> &val) { m_foldingList.assign (val); m_foldingList.detach(); }
00343
00348 inline void setIndentationDepth (QMemArray<unsigned short> &val) { m_indentationDepth.assign (val); }
00349
00353 public:
00359 inline uint dumpSize (bool withHighlighting) const
00360 {
00361 return ( 1
00362 + sizeof(uint)
00363 + (m_text.length() * sizeof(QChar))
00364 + ( withHighlighting ?
00365 ( (3 * sizeof(uint))
00366 + (m_text.length() * sizeof(uchar))
00367 + (m_ctx.size() * sizeof(short))
00368 + (m_foldingList.size() * sizeof(signed char))
00369 + (m_indentationDepth.size() * sizeof(unsigned short))
00370 ) : 0
00371 )
00372 );
00373 }
00374
00382 char *dump (char *buf, bool withHighlighting) const;
00383
00390 char *restore (char *buf);
00391
00395 private:
00399 QString m_text;
00400
00404 QMemArray<uchar> m_attributes;
00405
00409 QMemArray<short> m_ctx;
00410
00414 QMemArray<signed char> m_foldingList;
00415
00419 QMemArray<unsigned short> m_indentationDepth;
00420
00424 uchar m_flags;
00425 };
00426
00427 #endif
00428
00429
This file is part of the documentation for kate Library Version 3.3.0.