• Skip to content
  • Skip to link menu
KDE 4.2 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:
00194     inline KateTextLine::Ptr plainLine (int line)
00195     {
00196         // valid line at all?
00197         int block = findBlock (line);
00198         if (block == -1)
00199           return KateTextLine::Ptr();
00200 
00201         // return requested line
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     // for the scrapty indent sensitive langs
00351     int m_tabWidth;
00352 
00353     int m_lineHighlightedMax;
00354     int m_lineHighlighted;
00355 
00359     int m_maxDynamicContexts;
00360 };
00361 
00362 #endif
00363 
00364 // 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
  • kformula
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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