19 #ifndef _KATE_CODEFOLDING_HELPERS_
20 #define _KATE_CODEFOLDING_HELPERS_
23 #include <tqptrlist.h>
24 #include <tqvaluelist.h>
26 #include <tqintdict.h>
27 #include <tqmemarray.h>
29 class KateCodeFoldingTree;
36 class KateHiddenLineBlock
47 bool startsVisibleBlock;
48 bool startsInVisibleBlock;
53 class KateCodeFoldingNode
55 friend class KateCodeFoldingTree;
58 KateCodeFoldingNode ();
59 KateCodeFoldingNode (KateCodeFoldingNode *par,
signed char typ,
unsigned int sLRel);
61 ~KateCodeFoldingNode ();
63 inline int nodeType () {
return type;}
65 inline bool isVisible () {
return visible;}
67 inline KateCodeFoldingNode *getParentNode () {
return parentNode;}
76 inline bool noChildren ()
const {
return m_children.isEmpty(); }
78 inline uint childCount ()
const {
return m_children.size(); }
80 inline KateCodeFoldingNode *child (uint index)
const {
return m_children[index]; }
82 inline int findChild (KateCodeFoldingNode *node, uint start = 0)
const {
return m_children.find (node, start); }
84 inline void appendChild (KateCodeFoldingNode *node) { m_children.resize(m_children.size()+1); m_children[m_children.size()-1] = node; }
86 void insertChild (uint index, KateCodeFoldingNode *node);
88 KateCodeFoldingNode *takeChild (uint index);
90 void clearChildren ();
92 int cmpPos(KateCodeFoldingTree *tree, uint line, uint col);
98 KateCodeFoldingNode *parentNode;
99 unsigned int startLineRel;
100 unsigned int endLineRel;
102 unsigned int startCol;
113 TQMemArray<KateCodeFoldingNode*> m_children;
116 class KateCodeFoldingTree :
public TQObject
118 friend class KateCodeFoldingNode;
124 ~KateCodeFoldingTree ();
126 KateCodeFoldingNode *findNodeForLine (
unsigned int line);
128 unsigned int getRealLine (
unsigned int virtualLine);
129 unsigned int getVirtualLine (
unsigned int realLine);
130 unsigned int getHiddenLinesCount (
unsigned int docLine);
132 bool isTopLevel (
unsigned int line);
134 void lineHasBeenInserted (
unsigned int line);
135 void lineHasBeenRemoved (
unsigned int line);
137 void getLineInfo (KateLineInfo *info,
unsigned int line);
139 unsigned int getStartLine (KateCodeFoldingNode *node);
141 void fixRoot (
int endLRel);
144 KateCodeFoldingNode *findNodeForPosition(
unsigned int line,
unsigned int column);
147 KateCodeFoldingNode m_root;
151 TQIntDict<unsigned int> lineMapping;
152 TQIntDict<bool> dontIgnoreUnchangedLines;
154 TQPtrList<KateCodeFoldingNode> markedForDeleting;
155 TQPtrList<KateCodeFoldingNode> nodesForLine;
156 TQValueList<KateHiddenLineBlock> hiddenLines;
158 unsigned int hiddenLinesCountCache;
159 bool something_changed;
160 bool hiddenLinesCountCacheValid;
164 KateCodeFoldingNode *findNodeForLineDescending (KateCodeFoldingNode *,
unsigned int,
unsigned int,
bool oneStepOnly=
false);
166 bool correctEndings (
signed char data, KateCodeFoldingNode *node,
unsigned int line,
unsigned int endCol,
int insertPos);
168 void dumpNode (KateCodeFoldingNode *node,
const TQString &prefix);
169 void addOpening (KateCodeFoldingNode *node,
signed char nType,TQMemArray<uint>* list,
unsigned int line,
unsigned int charPos);
170 void addOpening_further_iterations (KateCodeFoldingNode *node,
signed char nType, TQMemArray<uint>*
171 list,
unsigned int line,
int current,
unsigned int startLine,
unsigned int charPos);
173 void incrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after);
174 void decrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after);
176 void cleanupUnneededNodes (
unsigned int line);
181 bool removeEnding (KateCodeFoldingNode *node,
unsigned int line);
186 bool removeOpening (KateCodeFoldingNode *node,
unsigned int line);
188 void findAndMarkAllNodesforRemovalOpenedOrClosedAt (
unsigned int line);
189 void findAllNodesOpenedOrClosedAt (
unsigned int line);
191 void addNodeToFoundList (KateCodeFoldingNode *node,
unsigned int line,
int childpos);
192 void addNodeToRemoveList (KateCodeFoldingNode *node,
unsigned int line);
193 void addHiddenLineBlock (KateCodeFoldingNode *node,
unsigned int line);
195 bool existsOpeningAtLineAfter(
unsigned int line, KateCodeFoldingNode *node);
197 void dontDeleteEnding (KateCodeFoldingNode*);
198 void dontDeleteOpening (KateCodeFoldingNode*);
200 void updateHiddenSubNodes (KateCodeFoldingNode *node);
201 void moveSubNodesUp (KateCodeFoldingNode *node);
204 void updateLine (
unsigned int line,TQMemArray<uint>* regionChanges,
bool *updated,
bool changed,
bool colschanged);
205 void toggleRegionVisibility (
unsigned int);
206 void collapseToplevelNodes ();
207 void expandToplevelNodes (
int numLines);
208 int collapseOne (
int realLine);
209 void expandOne (
int realLine,
int numLines);
213 void ensureVisible( uint line );
216 void regionVisibilityChangedAt (
unsigned int);
217 void regionBeginEndAddedRemoved (
unsigned int);
The KateBuffer class maintains a collections of lines.
Simple cursor class with no document pointer.
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)