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