| # kate Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# katebuffer.h

    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., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, 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
    00389   private:
    00394     void editTagLine (uint line);
    00395
    00400     void editRemoveTagLine (uint line);
    00401
    00406     void editInsertTagLine (uint line);
    00407
    00408   private:
    00412     uint editSessionNumber;
    00413
    00417     bool editIsRunning;
    00418
    00422     uint editTagLineStart;
    00423
    00427     uint editTagLineEnd;
    00428
    00429   public:
    00433     void clear();
    00434
    00440     bool openFile (const QString &m_file);
    00441
    00447     bool loadingBorked () const { return m_loadingBorked; }
    00448
    00453     bool binary () const { return m_binary; }
    00454
    00459     bool canEncode ();
    00460
    00466     bool saveFile (const QString &m_file);
    00467
    00468   public:
    00472     inline KateTextLine::Ptr line(uint i)
    00473     {
    00474       KateBufBlock *buf = findBlock(i);
    00475       if (!buf)
    00476         return 0;
    00477
    00478       if (i < m_lineHighlighted)
    00479         return buf->line (i - buf->startLine());
    00480
    00481       return line_internal (buf, i);
    00482     }
    00483
    00484   private:
    00488      KateTextLine::Ptr line_internal (KateBufBlock *buf, uint i);
    00489
    00490   public:
    00494     inline KateTextLine::Ptr plainLine(uint i)
    00495     {
    00496       KateBufBlock *buf = findBlock(i);
    00497       if (!buf)
    00498         return 0;
    00499
    00500       return buf->line(i - buf->startLine());
    00501     }
    00502
    00506     inline uint count() const { return m_lines; }
    00507
    00508   private:
    00514     KateBufBlock *findBlock (uint i, uint *index = 0)
    00515     {
    00516       // out of range !
    00517       if (i >= m_lines)
    00518         return 0;
    00519
    00520       if ((m_blocks[m_lastFoundBlock]->startLine() <= i) && (m_blocks[m_lastFoundBlock]->endLine() > i))
    00521       {
    00522         if (index)
    00523           (*index) = m_lastFoundBlock;
    00524
    00525         return m_blocks[m_lastFoundBlock];
    00526       }
    00527
    00528       return findBlock_internal (i, index);
    00529     }
    00530
    00531     KateBufBlock *findBlock_internal (uint i, uint *index = 0);
    00532
    00533   public:
    00537     void changeLine(uint i);
    00538
    00542     void insertLine(uint i, KateTextLine::Ptr line);
    00543
    00547     void removeLine(uint i);
    00548
    00549   public:
    00550     inline uint countVisible () { return m_lines - m_regionTree.getHiddenLinesCount(m_lines); }
    00551
    00552     inline uint lineNumber (uint visibleLine) { return m_regionTree.getRealLine (visibleLine); }
    00553
    00554     inline uint lineVisibleNumber (uint line) { return m_regionTree.getVirtualLine (line); }
    00555
    00556     inline void lineInfo (KateLineInfo *info, unsigned int line) { m_regionTree.getLineInfo(info,line); }
    00557
    00558     inline uint tabWidth () const { return m_tabWidth; }
    00559
    00560   public:
    00561     void setTabWidth (uint w);
    00562
    00569     void setHighlight (uint hlMode);
    00570
    00571     KateHighlighting *highlight () { return m_highlight; };
    00572
    00576     void invalidateHighlighting();
    00577
    00578     KateCodeFoldingTree *foldingTree () { return &m_regionTree; };
    00579
    00580   public slots:
    00581     void codeFoldingColumnUpdate(unsigned int lineNr);
    00582
    00583   private:
    00596     bool doHighlight (KateBufBlock *buf, uint from, uint to, bool invalidate);
    00597
    00598   signals:
    00602     void codeFoldingUpdated();
    00603
    00608     void tagLines(int start, int end);
    00609
    00610   private:
    00614     KateDocument *m_doc;
    00615
    00619     uint m_lines;
    00620
    00625     QValueVector<KateBufBlock*> m_blocks;
    00626
    00630     uint m_lastInSyncBlock;
    00631
    00635     uint m_lastFoundBlock;
    00636
    00641     bool m_cacheReadError;
    00642     bool m_cacheWriteError;
    00643
    00647     bool m_loadingBorked;
    00648
    00652     bool m_binary;
    00653
    00657   private:
    00661     KateHighlighting *m_highlight;
    00662
    00666     KateCodeFoldingTree m_regionTree;
    00667
    00668     // for the scrapty indent sensitive langs
    00669     uint m_tabWidth;
    00670
    00671     uint m_lineHighlightedMax;
    00672     uint m_lineHighlighted;
    00673
    00677     uint m_maxDynamicContexts;
    00678
    00682   private:
    00686     KateBufBlockList m_loadedBlocks;
    00687 };
    00688
    00689 #endif
    00690
    00691 // kate: space-indent on; indent-width 2; replace-tabs on;

This file is part of the documentation for kate Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:36:29 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003