• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katecodefoldinghelpers.h
1/* This file is part of the KDE libraries
2 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#ifndef _KATE_CODEFOLDING_HELPERS_
20#define _KATE_CODEFOLDING_HELPERS_
21
22//BEGIN INCLUDES + FORWARDS
23#include <tqptrlist.h>
24#include <tqvaluelist.h>
25#include <tqobject.h>
26#include <tqintdict.h>
27#include <tqmemarray.h>
28
29class KateCodeFoldingTree;
30class KateTextCursor;
31class KateBuffer;
32
33class TQString;
34//END
35
36class KateHiddenLineBlock
37{
38 public:
39 unsigned int start;
40 unsigned int length;
41};
42
43class KateLineInfo
44{
45 public:
46 bool topLevel;
47 bool startsVisibleBlock;
48 bool startsInVisibleBlock;
49 bool endsBlock;
50 bool invalidBlockEnd;
51};
52
53class KateCodeFoldingNode
54{
55 friend class KateCodeFoldingTree;
56
57 public:
58 KateCodeFoldingNode ();
59 KateCodeFoldingNode (KateCodeFoldingNode *par, signed char typ, unsigned int sLRel);
60
61 ~KateCodeFoldingNode ();
62
63 inline int nodeType () { return type;}
64
65 inline bool isVisible () {return visible;}
66
67 inline KateCodeFoldingNode *getParentNode () {return parentNode;}
68
69 bool getBegin (KateCodeFoldingTree *tree, KateTextCursor* begin);
70 bool getEnd (KateCodeFoldingTree *tree, KateTextCursor *end);
71
75 protected:
76 inline bool noChildren () const { return m_children.isEmpty(); }
77
78 inline uint childCount () const { return m_children.size(); }
79
80 inline KateCodeFoldingNode *child (uint index) const { return m_children[index]; }
81
82 inline int findChild (KateCodeFoldingNode *node, uint start = 0) const { return m_children.find (node, start); }
83
84 inline void appendChild (KateCodeFoldingNode *node) { m_children.resize(m_children.size()+1); m_children[m_children.size()-1] = node; }
85
86 void insertChild (uint index, KateCodeFoldingNode *node);
87
88 KateCodeFoldingNode *takeChild (uint index);
89
90 void clearChildren ();
91
92 int cmpPos(KateCodeFoldingTree *tree, uint line, uint col);
93
97 private:
98 KateCodeFoldingNode *parentNode;
99 unsigned int startLineRel;
100 unsigned int endLineRel;
101
102 unsigned int startCol;
103 unsigned int endCol;
104
105 bool startLineValid;
106 bool endLineValid;
107
108 signed char type; // 0 -> toplevel / invalid
109 bool visible;
110 bool deleteOpening;
111 bool deleteEnding;
112
113 TQMemArray<KateCodeFoldingNode*> m_children;
114};
115
116class KateCodeFoldingTree : public TQObject
117{
118 friend class KateCodeFoldingNode;
119
120 TQ_OBJECT
121
122 public:
123 KateCodeFoldingTree (KateBuffer *buffer);
124 ~KateCodeFoldingTree ();
125
126 KateCodeFoldingNode *findNodeForLine (unsigned int line);
127
128 unsigned int getRealLine (unsigned int virtualLine);
129 unsigned int getVirtualLine (unsigned int realLine);
130 unsigned int getHiddenLinesCount (unsigned int docLine);
131
132 bool isTopLevel (unsigned int line);
133
134 void lineHasBeenInserted (unsigned int line);
135 void lineHasBeenRemoved (unsigned int line);
136 void debugDump ();
137 void getLineInfo (KateLineInfo *info,unsigned int line);
138
139 unsigned int getStartLine (KateCodeFoldingNode *node);
140
141 void fixRoot (int endLRel);
142 void clear ();
143
144 KateCodeFoldingNode *findNodeForPosition(unsigned int line, unsigned int column);
145 private:
146
147 KateCodeFoldingNode m_root;
148
149 KateBuffer *m_buffer;
150
151 TQIntDict<unsigned int> lineMapping;
152 TQIntDict<bool> dontIgnoreUnchangedLines;
153
154 TQPtrList<KateCodeFoldingNode> markedForDeleting;
155 TQPtrList<KateCodeFoldingNode> nodesForLine;
156 TQValueList<KateHiddenLineBlock> hiddenLines;
157
158 unsigned int hiddenLinesCountCache;
159 bool something_changed;
160 bool hiddenLinesCountCacheValid;
161
162 static bool trueVal;
163
164 KateCodeFoldingNode *findNodeForLineDescending (KateCodeFoldingNode *, unsigned int, unsigned int, bool oneStepOnly=false);
165
166 bool correctEndings (signed char data, KateCodeFoldingNode *node, unsigned int line, unsigned int endCol, int insertPos);
167
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);
172
173 void incrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after);
174 void decrementBy1 (KateCodeFoldingNode *node, KateCodeFoldingNode *after);
175
176 void cleanupUnneededNodes (unsigned int line);
177
181 bool removeEnding (KateCodeFoldingNode *node,unsigned int line);
182
186 bool removeOpening (KateCodeFoldingNode *node,unsigned int line);
187
188 void findAndMarkAllNodesforRemovalOpenedOrClosedAt (unsigned int line);
189 void findAllNodesOpenedOrClosedAt (unsigned int line);
190
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);
194
195 bool existsOpeningAtLineAfter(unsigned int line, KateCodeFoldingNode *node);
196
197 void dontDeleteEnding (KateCodeFoldingNode*);
198 void dontDeleteOpening (KateCodeFoldingNode*);
199
200 void updateHiddenSubNodes (KateCodeFoldingNode *node);
201 void moveSubNodesUp (KateCodeFoldingNode *node);
202
203 public slots:
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 );
214
215 signals:
216 void regionVisibilityChangedAt (unsigned int);
217 void regionBeginEndAddedRemoved (unsigned int);
218};
219
220#endif
KateBuffer
The KateBuffer class maintains a collections of lines.
Definition: katebuffer.h:342
KateTextCursor
Simple cursor class with no document pointer.
Definition: katecursor.h:34
KStdAction::clear
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.