kate Library API Documentation

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 00028 class QString; 00029 //END 00030 00031 class KateHiddenLineBlock 00032 { 00033 public: 00034 unsigned int start; 00035 unsigned int length; 00036 }; 00037 00038 class KateLineInfo 00039 { 00040 public: 00041 bool topLevel; 00042 bool startsVisibleBlock; 00043 bool startsInVisibleBlock; 00044 bool endsBlock; 00045 bool invalidBlockEnd; 00046 }; 00047 00048 class KateCodeFoldingNode 00049 { 00050 public: 00051 KateCodeFoldingNode(); 00052 KateCodeFoldingNode(KateCodeFoldingNode *par, signed char typ, unsigned int sLRel); 00053 ~KateCodeFoldingNode(); 00054 00055 inline QPtrList<KateCodeFoldingNode> *childnodes () 00056 { 00057 if (!m_childnodes) 00058 { 00059 m_childnodes = new QPtrList<KateCodeFoldingNode>; 00060 m_childnodes->setAutoDelete (true); 00061 } 00062 00063 return m_childnodes; 00064 } 00065 00066 inline bool hasChildNodes () 00067 { 00068 if (!m_childnodes) 00069 return false; 00070 00071 return !m_childnodes->isEmpty (); 00072 } 00073 00074 // temporary public to avoid friend an be able to disallow the access of m_childnodes directly ;) 00075 KateCodeFoldingNode *parentNode; 00076 unsigned int startLineRel; 00077 unsigned int endLineRel; 00078 00079 bool startLineValid; 00080 bool endLineValid; 00081 00082 signed char type; // 0 -> toplevel / invalid 00083 bool visible; 00084 bool deleteOpening; 00085 bool deleteEnding; 00086 00087 protected: 00088 QPtrList<KateCodeFoldingNode> *m_childnodes; 00089 }; 00090 00091 00092 class KateCodeFoldingTree : public QObject, public KateCodeFoldingNode 00093 { 00094 Q_OBJECT 00095 00096 public: 00097 KateCodeFoldingTree (QObject *); 00098 ~KateCodeFoldingTree (); 00099 00100 KateCodeFoldingNode *findNodeForLine (unsigned int line); 00101 00102 unsigned int getRealLine (unsigned int virtualLine); 00103 unsigned int getVirtualLine (unsigned int realLine); 00104 unsigned int getHiddenLinesCount (unsigned int docLine); 00105 00106 bool isTopLevel (unsigned int line); 00107 00108 void lineHasBeenInserted (unsigned int line); 00109 void lineHasBeenRemoved (unsigned int line); 00110 void debugDump (); 00111 void getLineInfo (KateLineInfo *info,unsigned int line); 00112 00113 unsigned int getStartLine (KateCodeFoldingNode *node); 00114 00115 void fixRoot (int endLRel); 00116 void clear (); 00117 00118 private: 00119 QIntDict<unsigned int> lineMapping; 00120 QIntDict<bool> dontIgnoreUnchangedLines; 00121 00122 QPtrList<KateCodeFoldingNode> markedForDeleting; 00123 QPtrList<KateCodeFoldingNode> nodesForLine; 00124 QValueList<KateHiddenLineBlock> hiddenLines; 00125 00126 unsigned int hiddenLinesCountCache; 00127 bool something_changed; 00128 bool hiddenLinesCountCacheValid; 00129 00130 static bool trueVal; 00131 00132 KateCodeFoldingNode *findNodeForLineDescending (KateCodeFoldingNode *, unsigned int, unsigned int, bool oneStepOnly=false); 00133 00134 bool correctEndings (signed char data, KateCodeFoldingNode *node, unsigned int line, int insertPos); 00135 00136 void dumpNode (KateCodeFoldingNode *node,QString prefix); 00137 void addOpening (KateCodeFoldingNode *node, signed char nType,QMemArray<signed char>* list, unsigned int line); 00138 void addOpening_further_iterations (KateCodeFoldingNode *node,signed char nType, QMemArray<signed char>* 00139 list,unsigned int line,int current,unsigned int startLine); 00140 00141 void incrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after); 00142 void decrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after); 00143 00144 void cleanupUnneededNodes (unsigned int line); 00145 00149 bool removeEnding (KateCodeFoldingNode *node,unsigned int line); 00150 00154 bool removeOpening (KateCodeFoldingNode *node,unsigned int line); 00155 00156 void findAndMarkAllNodesforRemovalOpenedOrClosedAt (unsigned int line); 00157 void findAllNodesOpenedOrClosedAt (unsigned int line); 00158 00159 void addNodeToFoundList (KateCodeFoldingNode *node,unsigned int line,int childpos); 00160 void addNodeToRemoveList (KateCodeFoldingNode *node,unsigned int line); 00161 void addHiddenLineBlock (KateCodeFoldingNode *node,unsigned int line); 00162 00163 bool existsOpeningAtLineAfter(unsigned int line, KateCodeFoldingNode *node); 00164 00165 void dontDeleteEnding (KateCodeFoldingNode*); 00166 void dontDeleteOpening (KateCodeFoldingNode*); 00167 00168 void updateHiddenSubNodes (KateCodeFoldingNode *node); 00169 void moveSubNodesUp (KateCodeFoldingNode *node); 00170 00171 public slots: 00172 void updateLine (unsigned int line,QMemArray<signed char>* regionChanges, bool *updated, bool changed); 00173 void toggleRegionVisibility (unsigned int); 00174 void collapseToplevelNodes (); 00175 void expandToplevelNodes (int numLines); 00176 int collapseOne (int realLine); 00177 void expandOne (int realLine, int numLines); 00181 void ensureVisible( uint line ); 00182 00183 signals: 00184 void setLineVisible (unsigned int, bool); 00185 void regionVisibilityChangedAt (unsigned int); 00186 void regionBeginEndAddedRemoved (unsigned int); 00187 }; 00188 00189 #endif 00190 00191 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE Logo
This file is part of the documentation for kate Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:45:07 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003