Kate
katebuffer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __KATE_BUFFER_H__
00021 #define __KATE_BUFFER_H__
00022
00023 #include "katetextline.h"
00024 #include "katecodefolding.h"
00025
00026 #include <QtCore/QObject>
00027
00028 class KateLineInfo;
00029 class KateDocument;
00030 class KateHighlighting;
00031
00035 class KateBufferBlock
00036 {
00037 public:
00041 KateBufferBlock (int _start) : start (_start) {}
00042
00046 inline KateTextLine::Ptr line (int i) { return lines[i - start]; }
00047
00051 QVector<KateTextLine::Ptr> lines;
00052
00056 int start;
00057 };
00058
00065 class KateBuffer : public QObject
00066 {
00067 Q_OBJECT
00068
00069 public:
00074 explicit KateBuffer (KateDocument *doc);
00075
00079 ~KateBuffer ();
00080
00081 public:
00085 void editStart ();
00086
00090 void editEnd ();
00091
00097 inline bool editChanged () const { return editChangesDone; }
00098
00103 inline int editTagStart () const { return editTagLineStart; }
00104
00109 inline int editTagEnd () const { return editTagLineEnd; }
00110
00115 inline bool editTagFrom () const { return editTagLineFrom; }
00116
00117 private:
00121 int editSessionNumber;
00122
00126 bool editIsRunning;
00127
00131 int editTagLineStart;
00132
00136 int editTagLineEnd;
00137
00141 bool editTagLineFrom;
00142
00146 bool editChangesDone;
00147
00148 public:
00152 void clear();
00153
00159 bool openFile (const QString &m_file);
00160
00165 bool binary () const { return m_binary; }
00166
00172 bool brokenUTF8 () const { return m_brokenUTF8; }
00173
00178 bool canEncode ();
00179
00185 bool saveFile (const QString &m_file);
00186
00187 public:
00195 inline KateTextLine::Ptr plainLine (int line)
00196 {
00197
00198 int block = findBlock (line);
00199 if (block == -1)
00200 return KateTextLine::Ptr();
00201
00202
00203 return m_blocks[block]->line (line);
00204 }
00205
00209 void ensureHighlighted(int line);
00210
00214 inline int count() const { return m_lines; }
00215
00219 void changeLine(int i);
00220
00224 void insertLine(int i, KateTextLine::Ptr line);
00225
00229 void removeLine(int i);
00230
00231 private:
00232 inline void addIndentBasedFoldingInformation(QVector<int> &foldingList,int linelength,bool addindent,int deindent);
00233 inline void updatePreviousNotEmptyLine(int current_line,bool addindent,int deindent);
00234
00235 public:
00236 inline int countVisible () { return m_lines - m_regionTree.getHiddenLinesCount(m_lines); }
00237
00238 inline int lineNumber (int visibleLine) { return m_regionTree.getRealLine (visibleLine); }
00239
00240 inline int lineVisibleNumber (int line) { return m_regionTree.getVirtualLine (line); }
00241
00242 inline void lineInfo (KateLineInfo *info, int line) { m_regionTree.getLineInfo(info,line); }
00243
00244 inline int tabWidth () const { return m_tabWidth; }
00245
00246 public:
00247 void setTabWidth (int w);
00248
00255 void setHighlight (int hlMode);
00256
00257 KateHighlighting *highlight () { return m_highlight; }
00258
00262 void invalidateHighlighting();
00263
00264 KateCodeFoldingTree *foldingTree () { return &m_regionTree; }
00265
00266 void codeFoldingColumnUpdate(int lineNr);
00267
00268 private:
00269 int findBlock (int line);
00270
00271 void fixBlocksFrom (int lastValidBlock);
00272
00283 bool doHighlight (int from, int to, bool invalidate);
00284 bool isEmptyLine(KateTextLine::Ptr textline);
00285
00286 Q_SIGNALS:
00290 void codeFoldingUpdated();
00291
00296 void tagLines(int start, int end);
00297
00298 private:
00302 KateDocument *m_doc;
00303
00307 QVector<KateBufferBlock*> m_blocks;
00308
00312 int m_lastUsedBlock;
00313
00317 int m_lines;
00318
00322 bool m_binary;
00323
00327 bool m_brokenUTF8;
00328
00332 private:
00336 KateHighlighting *m_highlight;
00337
00341 KateCodeFoldingTree m_regionTree;
00342
00343
00344 int m_tabWidth;
00345
00346 int m_lineHighlightedMax;
00347 int m_lineHighlighted;
00348
00352 int m_maxDynamicContexts;
00353 };
00354
00355 #endif
00356
00357