• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katebuffer.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
00003    Copyright (C) 2002-2004 Christoph Cullmann <cullmann@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
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         // valid line at all?
00198         int block = findBlock (line);
00199         if (block == -1)
00200           return KateTextLine::Ptr();
00201 
00202         // return requested line
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     // for the scrapty indent sensitive langs
00344     int m_tabWidth;
00345 
00346     int m_lineHighlightedMax;
00347     int m_lineHighlighted;
00348 
00352     int m_maxDynamicContexts;
00353 };
00354 
00355 #endif
00356 
00357 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal