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:
00194 inline KateTextLine::Ptr plainLine (int line)
00195 {
00196
00197 int block = findBlock (line);
00198 if (block == -1)
00199 return KateTextLine::Ptr();
00200
00201
00202 return m_blocks[block]->line (line);
00203 }
00204
00211 KateTextLine::Ptr line(int line);
00212
00216 inline int count() const { return m_lines; }
00217
00221 inline int lines() const { return m_lines; }
00222
00226 void changeLine(int i);
00227
00231 void insertLine(int i, KateTextLine::Ptr line);
00232
00236 void removeLine(int i);
00237
00238 private:
00239 inline void addIndentBasedFoldingInformation(QVector<int> &foldingList,int linelength,bool addindent,int deindent);
00240 inline void updatePreviousNotEmptyLine(int current_line,bool addindent,int deindent);
00241
00242 public:
00243 inline int countVisible () { return m_lines - m_regionTree.getHiddenLinesCount(m_lines); }
00244
00245 inline int lineNumber (int visibleLine) { return m_regionTree.getRealLine (visibleLine); }
00246
00247 inline int lineVisibleNumber (int line) { return m_regionTree.getVirtualLine (line); }
00248
00249 inline void lineInfo (KateLineInfo *info, int line) { m_regionTree.getLineInfo(info,line); }
00250
00251 inline int tabWidth () const { return m_tabWidth; }
00252
00253 public:
00254 void setTabWidth (int w);
00255
00262 void setHighlight (int hlMode);
00263
00264 KateHighlighting *highlight () { return m_highlight; }
00265
00269 void invalidateHighlighting();
00270
00271 KateCodeFoldingTree *foldingTree () { return &m_regionTree; }
00272
00273 void codeFoldingColumnUpdate(int lineNr);
00274
00275 private:
00276 int findBlock (int line);
00277
00278 void fixBlocksFrom (int lastValidBlock);
00279
00290 bool doHighlight (int from, int to, bool invalidate);
00291 bool isEmptyLine(KateTextLine::Ptr textline);
00292
00293 Q_SIGNALS:
00297 void codeFoldingUpdated();
00298
00303 void tagLines(int start, int end);
00304
00305 private:
00309 KateDocument *m_doc;
00310
00314 QVector<KateBufferBlock*> m_blocks;
00315
00319 int m_lastUsedBlock;
00320
00324 int m_lines;
00325
00329 bool m_binary;
00330
00334 bool m_brokenUTF8;
00335
00339 private:
00343 KateHighlighting *m_highlight;
00344
00348 KateCodeFoldingTree m_regionTree;
00349
00350
00351 int m_tabWidth;
00352
00353 int m_lineHighlightedMax;
00354 int m_lineHighlighted;
00355
00359 int m_maxDynamicContexts;
00360 };
00361
00362 #endif
00363
00364