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

Kate

katebuffer.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
00003    Copyright (C) 2002-2004 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 version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __KATE_BUFFER_H__
00021 #define __KATE_BUFFER_H__
00022 
00023 #include "katetextline.h"
00024 #include "katecodefoldinghelpers.h"
00025 
00026 #include <kvmallocator.h>
00027 
00028 #include <qptrlist.h>
00029 #include <qobject.h>
00030 #include <qtimer.h>
00031 #include <qvaluevector.h>
00032 
00033 class KateLineInfo;
00034 class KateDocument;
00035 class KateHighlighting;
00036 class KateBufBlockList;
00037 class KateBuffer;
00038 class KateFileLoader;
00039 
00040 class QTextCodec;
00041 
00049 class KateBufBlock
00050 {
00051   friend class KateBufBlockList;
00052 
00053   public:
00061     KateBufBlock ( KateBuffer *parent, KateBufBlock *prev = 0, KateBufBlock *next = 0,
00062                    KateFileLoader *stream = 0 );
00063 
00067     ~KateBufBlock ();
00068 
00069   private:
00074     void fillBlock (KateFileLoader *stream);
00075 
00076   public:
00080     enum State
00081     {
00082       stateSwapped = 0,
00083       stateClean = 1,
00084       stateDirty = 2
00085     };
00086 
00091     State state () const { return m_state; }
00092 
00093   public:
00101     KateTextLine::Ptr line(uint i);
00102 
00109     void insertLine(uint i, KateTextLine::Ptr line);
00110 
00116     void removeLine(uint i);
00117 
00122     void markDirty ();
00123 
00124   public:
00129     inline uint startLine () const { return m_startLine; };
00130 
00135     inline void setStartLine (uint line) { m_startLine = line; }
00136 
00141     inline uint endLine () const { return m_startLine + m_lines; }
00142 
00147     inline uint lines () const { return m_lines; }
00148 
00153     inline KateBufBlock *prev () { return m_prev; }
00154 
00159     inline KateBufBlock *next () { return m_next; }
00160 
00164   private:
00168     void swapIn ();
00169 
00173     void swapOut ();
00174 
00175   private:
00180     KateBufBlock::State m_state;
00181 
00185     uint m_startLine;
00186 
00190     uint m_lines;
00191 
00195     KVMAllocator::Block *m_vmblock;
00196 
00200     uint m_vmblockSize;
00201 
00205     QValueVector<KateTextLine::Ptr> m_stringList;
00206 
00210     KateBuffer* m_parent;
00211 
00215     KateBufBlock *m_prev;
00216 
00220     KateBufBlock *m_next;
00221 
00222   private:
00227     KateBufBlockList *list;
00228 
00232     KateBufBlock *listPrev;
00233 
00237     KateBufBlock *listNext;
00238 };
00239 
00248 class KateBufBlockList
00249 {
00250   public:
00254     KateBufBlockList ();
00255 
00256   public:
00261     inline uint count() const { return m_count; }
00262 
00267     inline KateBufBlock *first () { return m_first; };
00268 
00273     inline KateBufBlock *last () { return m_last; };
00274 
00280     inline bool isFirst (KateBufBlock *buf) { return m_first == buf; };
00281 
00287     inline bool isLast (KateBufBlock *buf) { return m_last == buf; };
00288 
00294     void append (KateBufBlock *buf);
00295 
00300     inline static void remove (KateBufBlock *buf)
00301     {
00302       if (buf->list)
00303         buf->list->removeInternal (buf);
00304     }
00305 
00306   private:
00311     void removeInternal (KateBufBlock *buf);
00312 
00313   private:
00317     uint m_count;
00318 
00322     KateBufBlock *m_first;
00323 
00327     KateBufBlock *m_last;
00328 };
00329 
00341 class KateBuffer : public QObject
00342 {
00343   Q_OBJECT
00344 
00345   friend class KateBufBlock;
00346 
00347   public:
00352     inline static uint maxLoadedBlocks () { return m_maxLoadedBlocks; }
00353 
00358     static void setMaxLoadedBlocks (uint count);
00359 
00360   private:
00364     static uint m_maxLoadedBlocks;
00365 
00366   public:
00371     KateBuffer (KateDocument *doc);
00372 
00376     ~KateBuffer ();
00377 
00378   public:
00382     void editStart ();
00383 
00387     void editEnd ();
00388 
00394     inline bool editChanged () const { return editChangesDone; }
00395 
00400     inline uint editTagStart () const { return editTagLineStart; }
00401 
00406     inline uint editTagEnd () const { return editTagLineEnd; }
00407 
00412     inline bool editTagFrom () const { return editTagLineFrom; }
00413 
00414   private:
00418     uint editSessionNumber;
00419 
00423     bool editIsRunning;
00424 
00428     uint editTagLineStart;
00429 
00433     uint editTagLineEnd;
00434 
00438     bool editTagLineFrom;
00439 
00443     bool editChangesDone;
00444 
00445   public:
00449     void clear();
00450 
00456     bool openFile (const QString &m_file);
00457 
00463     bool loadingBorked () const { return m_loadingBorked; }
00464 
00469     bool binary () const { return m_binary; }
00470 
00475     bool canEncode ();
00476 
00482     bool saveFile (const QString &m_file);
00483 
00484   public:
00488     inline KateTextLine::Ptr line(uint i)
00489     {
00490       KateBufBlock *buf = findBlock(i);
00491       if (!buf)
00492         return 0;
00493 
00494       if (i < m_lineHighlighted)
00495         return buf->line (i - buf->startLine());
00496 
00497       return line_internal (buf, i);
00498     }
00499 
00500   private:
00504      KateTextLine::Ptr line_internal (KateBufBlock *buf, uint i);
00505 
00506      inline void addIndentBasedFoldingInformation(QMemArray<uint> &foldingList,bool addindent,uint deindent);
00507      inline void updatePreviousNotEmptyLine(KateBufBlock *blk,uint current_line,bool addindent,uint deindent);
00508   public:
00512     inline KateTextLine::Ptr plainLine(uint i)
00513     {
00514       KateBufBlock *buf = findBlock(i);
00515       if (!buf)
00516         return 0;
00517 
00518       return buf->line(i - buf->startLine());
00519     }
00520 
00524     inline uint count() const { return m_lines; }
00525 
00526   private:
00532     KateBufBlock *findBlock (uint i, uint *index = 0)
00533     {
00534       // out of range !
00535       if (i >= m_lines)
00536         return 0;
00537 
00538       if ((m_blocks[m_lastFoundBlock]->startLine() <= i) && (m_blocks[m_lastFoundBlock]->endLine() > i))
00539       {
00540         if (index)
00541           (*index) = m_lastFoundBlock;
00542 
00543         return m_blocks[m_lastFoundBlock];
00544       }
00545 
00546       return findBlock_internal (i, index);
00547     }
00548 
00549     KateBufBlock *findBlock_internal (uint i, uint *index = 0);
00550 
00551   public:
00555     void changeLine(uint i);
00556 
00560     void insertLine(uint i, KateTextLine::Ptr line);
00561 
00565     void removeLine(uint i);
00566 
00567   public:
00568     inline uint countVisible () { return m_lines - m_regionTree.getHiddenLinesCount(m_lines); }
00569 
00570     inline uint lineNumber (uint visibleLine) { return m_regionTree.getRealLine (visibleLine); }
00571 
00572     inline uint lineVisibleNumber (uint line) { return m_regionTree.getVirtualLine (line); }
00573 
00574     inline void lineInfo (KateLineInfo *info, unsigned int line) { m_regionTree.getLineInfo(info,line); }
00575 
00576     inline uint tabWidth () const { return m_tabWidth; }
00577 
00578   public:
00579     void setTabWidth (uint w);
00580 
00587     void setHighlight (uint hlMode);
00588 
00589     KateHighlighting *highlight () { return m_highlight; };
00590 
00594     void invalidateHighlighting();
00595 
00596     KateCodeFoldingTree *foldingTree () { return &m_regionTree; };
00597 
00598   public slots:
00599     void codeFoldingColumnUpdate(unsigned int lineNr);
00600 
00601   private:
00614     bool doHighlight (KateBufBlock *buf, uint from, uint to, bool invalidate);
00615 
00616   signals:
00620     void codeFoldingUpdated();
00621 
00626     void tagLines(int start, int end);
00627 
00628   private:
00632     KateDocument *m_doc;
00633 
00637     uint m_lines;
00638 
00643     QValueVector<KateBufBlock*> m_blocks;
00644 
00648     uint m_lastInSyncBlock;
00649 
00653     uint m_lastFoundBlock;
00654 
00659     bool m_cacheReadError;
00660     bool m_cacheWriteError;
00661 
00665     bool m_loadingBorked;
00666 
00670     bool m_binary;
00671 
00675   private:
00679     KateHighlighting *m_highlight;
00680 
00684     KateCodeFoldingTree m_regionTree;
00685 
00686     // for the scrapty indent sensitive langs
00687     uint m_tabWidth;
00688 
00689     uint m_lineHighlightedMax;
00690     uint m_lineHighlighted;
00691 
00695     uint m_maxDynamicContexts;
00696 
00700   private:
00704     KateBufBlockList m_loadedBlocks;
00705 };
00706 
00707 #endif
00708 
00709 // 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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
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