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

# katecodefoldinghelpers.h

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License version 2 as published by the Free Software Foundation.
    00007
    00008    This library is distributed in the hope that it will be useful,
    00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00011    Library General Public License for more details.
    00012
    00013    You should have received a copy of the GNU Library General Public License
    00014    along with this library; see the file COPYING.LIB.  If not, write to
    00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00016    Boston, MA 02111-1307, USA.
    00017 */
    00018
    00019 #ifndef _KATE_CODEFOLDING_HELPERS_
    00020 #define _KATE_CODEFOLDING_HELPERS_
    00021
    00022 //BEGIN INCLUDES + FORWARDS
    00023 #include <qptrlist.h>
    00024 #include <qvaluelist.h>
    00025 #include <qobject.h>
    00026 #include <qintdict.h>
    00027 #include <qmemarray.h>
    00028
    00029 class KateCodeFoldingTree;
    00030 class KateTextCursor;
    00031 class KateBuffer;
    00032
    00033 class QString;
    00034 //END
    00035
    00036 class KateHiddenLineBlock
    00037 {
    00038   public:
    00039     unsigned int start;
    00040     unsigned int length;
    00041 };
    00042
    00043 class KateLineInfo
    00044 {
    00045   public:
    00046     bool topLevel;
    00047     bool startsVisibleBlock;
    00048     bool startsInVisibleBlock;
    00049     bool endsBlock;
    00050     bool invalidBlockEnd;
    00051 };
    00052
    00053 class KateCodeFoldingNode
    00054 {
    00055   friend class KateCodeFoldingTree;
    00056
    00057   public:
    00058     KateCodeFoldingNode ();
    00059     KateCodeFoldingNode (KateCodeFoldingNode *par, signed char typ, unsigned int sLRel);
    00060
    00061     ~KateCodeFoldingNode ();
    00062
    00063     inline int nodeType () { return type;}
    00064
    00065     inline bool isVisible () {return visible;}
    00066
    00067     inline KateCodeFoldingNode *getParentNode () {return parentNode;}
    00068
    00069     bool getBegin (KateCodeFoldingTree *tree, KateTextCursor* begin);
    00070     bool getEnd (KateCodeFoldingTree *tree, KateTextCursor *end);
    00071
    00075   protected:
    00076     inline bool noChildren () const { return m_children.isEmpty(); }
    00077
    00078     inline uint childCount () const { return m_children.size(); }
    00079
    00080     inline KateCodeFoldingNode *child (uint index) const { return m_children[index]; }
    00081
    00082     inline int findChild (KateCodeFoldingNode *node, uint start = 0) const { return m_children.find (node, start); }
    00083
    00084     inline void appendChild (KateCodeFoldingNode *node) { m_children.resize(m_children.size()+1); m_children[m_children.size()-1] = node; }
    00085
    00086     void insertChild (uint index, KateCodeFoldingNode *node);
    00087
    00088     KateCodeFoldingNode *takeChild (uint index);
    00089
    00090     void clearChildren ();
    00091
    00092     int cmpPos(KateCodeFoldingTree *tree, uint line, uint col);
    00093
    00097   private:
    00098     KateCodeFoldingNode                *parentNode;
    00099     unsigned int startLineRel;
    00100     unsigned int endLineRel;
    00101
    00102     unsigned int startCol;
    00103     unsigned int endCol;
    00104
    00105     bool startLineValid;
    00106     bool endLineValid;
    00107
    00108     signed char type;                // 0 -> toplevel / invalid
    00109     bool visible;
    00110     bool deleteOpening;
    00111     bool deleteEnding;
    00112
    00113     QMemArray<KateCodeFoldingNode*> m_children;
    00114 };
    00115
    00116 class KateCodeFoldingTree : public QObject
    00117 {
    00118   friend class KateCodeFoldingNode;
    00119
    00120   Q_OBJECT
    00121
    00122   public:
    00123     KateCodeFoldingTree (KateBuffer *buffer);
    00124     ~KateCodeFoldingTree ();
    00125
    00126     KateCodeFoldingNode *findNodeForLine (unsigned int line);
    00127
    00128     unsigned int getRealLine         (unsigned int virtualLine);
    00129     unsigned int getVirtualLine      (unsigned int realLine);
    00130     unsigned int getHiddenLinesCount (unsigned int docLine);
    00131
    00132     bool isTopLevel (unsigned int line);
    00133
    00134     void lineHasBeenInserted (unsigned int line);
    00135     void lineHasBeenRemoved  (unsigned int line);
    00136     void debugDump ();
    00137     void getLineInfo (KateLineInfo *info,unsigned int line);
    00138
    00139     unsigned int getStartLine (KateCodeFoldingNode *node);
    00140
    00141     void fixRoot (int endLRel);
    00142     void clear ();
    00143
    00144     KateCodeFoldingNode *findNodeForPosition(unsigned int line, unsigned int column);
    00145   private:
    00146
    00147     KateCodeFoldingNode m_root;
    00148
    00149     KateBuffer *m_buffer;
    00150
    00151     QIntDict<unsigned int> lineMapping;
    00152     QIntDict<bool>         dontIgnoreUnchangedLines;
    00153
    00154     QPtrList<KateCodeFoldingNode> markedForDeleting;
    00155     QPtrList<KateCodeFoldingNode> nodesForLine;
    00156     QValueList<KateHiddenLineBlock>   hiddenLines;
    00157
    00158     unsigned int hiddenLinesCountCache;
    00159     bool         something_changed;
    00160     bool         hiddenLinesCountCacheValid;
    00161
    00162     static bool trueVal;
    00163
    00164     KateCodeFoldingNode *findNodeForLineDescending (KateCodeFoldingNode *, unsigned int, unsigned int, bool oneStepOnly=false);
    00165
    00166     bool correctEndings (signed char data, KateCodeFoldingNode *node, unsigned int line, unsigned int endCol, int insertPos);
    00167
    00168     void dumpNode    (KateCodeFoldingNode *node, const QString &prefix);
    00169     void addOpening  (KateCodeFoldingNode *node, signed char nType,QMemArray<uint>* list, unsigned int line,unsigned int charPos);
    00170     void addOpening_further_iterations (KateCodeFoldingNode *node,signed char nType, QMemArray<uint>*
    00171                                         list,unsigned int line,int current,unsigned int startLine,unsigned int charPos);
    00172
    00173     void incrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after);
    00174     void decrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after);
    00175
    00176     void cleanupUnneededNodes (unsigned int line);
    00177
    00181     bool removeEnding (KateCodeFoldingNode *node,unsigned int line);
    00182
    00186     bool removeOpening (KateCodeFoldingNode *node,unsigned int line);
    00187
    00188     void findAndMarkAllNodesforRemovalOpenedOrClosedAt (unsigned int line);
    00189     void findAllNodesOpenedOrClosedAt (unsigned int line);
    00190
    00191     void addNodeToFoundList  (KateCodeFoldingNode *node,unsigned int line,int childpos);
    00192     void addNodeToRemoveList (KateCodeFoldingNode *node,unsigned int line);
    00193     void addHiddenLineBlock  (KateCodeFoldingNode *node,unsigned int line);
    00194
    00195     bool existsOpeningAtLineAfter(unsigned int line, KateCodeFoldingNode *node);
    00196
    00197     void dontDeleteEnding  (KateCodeFoldingNode*);
    00198     void dontDeleteOpening (KateCodeFoldingNode*);
    00199
    00200     void updateHiddenSubNodes (KateCodeFoldingNode *node);
    00201     void moveSubNodesUp (KateCodeFoldingNode *node);
    00202
    00203   public slots:
    00204     void updateLine (unsigned int line,QMemArray<uint>* regionChanges, bool *updated, bool changed,bool colschanged);
    00205     void toggleRegionVisibility (unsigned int);
    00206     void collapseToplevelNodes ();
    00207     void expandToplevelNodes (int numLines);
    00208     int collapseOne (int realLine);
    00209     void expandOne  (int realLine, int numLines);
    00213     void ensureVisible( uint line );
    00214
    00215   signals:
    00216     void regionVisibilityChangedAt  (unsigned int);
    00217     void regionBeginEndAddedRemoved (unsigned int);
    00218 };
    00219
    00220 #endif
    00221
    00222 // 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:30 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003