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

Kate

katelayoutcache.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2005 Hamish Rodda <rodda@kde.org>
00003    Copyright (C) 2008 Dominik Haumann <dhaumann 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 KATELAYOUTCACHE_H
00021 #define KATELAYOUTCACHE_H
00022 
00023 #include <QThreadStorage>
00024 #include <QPair>
00025 
00026 #include <ktexteditor/range.h>
00027 
00028 #include "katetextlayout.h"
00029 
00030 class KateRenderer;
00031 class KateEditInfo;
00032 
00033 namespace KTextEditor { class Document; }
00034 
00035 class KateLineLayoutMap
00036 {
00037   public:
00038     KateLineLayoutMap();
00039     ~KateLineLayoutMap();
00040 
00041     inline void clear();
00042 
00043     inline bool contains(int i) const;
00044 
00045     inline void insert(int realLine, const KateLineLayoutPtr& lineLayoutPtr);
00046 
00047     inline void viewWidthIncreased();
00048     inline void viewWidthDecreased(int newWidth);
00049 
00050     inline void relayoutLines(int startRealLine, int endRealLine);
00051 
00052     inline void slotEditDone(int fromLine, int toLine, int shiftAmount);
00053 
00054     KateLineLayoutPtr& operator[](int i);
00055 
00056     //static bool lessThan(const LineLayoutPair& lhs, const LineLayoutPair& rhs);
00057 
00058     typedef QPair<int, KateLineLayoutPtr> LineLayoutPair;
00059   private:
00060     typedef QVector<LineLayoutPair> LineLayoutMap;
00061     LineLayoutMap m_lineLayouts;
00062 };
00063 
00064 
00079 class KateLayoutCache : public QObject
00080 {
00081   Q_OBJECT
00082 
00083   public:
00084     explicit KateLayoutCache(KateRenderer* renderer, QObject* parent);
00085 
00086     void clear();
00087 
00088     int viewWidth() const;
00089     void setViewWidth(int width);
00090 
00091     bool wrap() const;
00092     void setWrap(bool wrap);
00093 
00094     bool acceptDirtyLayouts() const;
00095     void setAcceptDirtyLayouts(bool accept);
00096 
00097     // BEGIN generic methods to get/set layouts
00110     KateLineLayoutPtr line(int realLine, int virtualLine = -1) const;
00112     KateLineLayoutPtr line(const KTextEditor::Cursor& realCursor) const;
00113 
00115     KateTextLayout textLayout(const KTextEditor::Cursor& realCursor) const;
00116 
00119     KateTextLayout textLayout(uint realLine, int viewLine) const;
00120     // END
00121 
00122     // BEGIN methods to do with the caching of lines visible within a view
00124     KateTextLayout& viewLine(int viewLine) const;
00125 
00126     // find the view line of the cursor, relative to the display (0 = top line of view, 1 = second line, etc.)
00127     // if limitToVisible is true, only lines which are currently visible will be searched for, and -1 returned if the line is not visible.
00128     int displayViewLine(const KTextEditor::Cursor& virtualCursor, bool limitToVisible = false) const;
00129 
00130     int viewCacheLineCount() const;
00131     KTextEditor::Cursor viewCacheStart() const;
00132     KTextEditor::Cursor viewCacheEnd() const;
00133     void updateViewCache(const KTextEditor::Cursor& startPos, int newViewLineCount = -1, int viewLinesScrolled = 0);
00134 
00135     void relayoutLines(int startRealLine, int endRealLine);
00136 
00137     // find the index of the last view line for a specific line
00138     int lastViewLine(int realLine) const;
00139     // find the view line of cursor c (0 = same line, 1 = down one, etc.)
00140     int viewLine(const KTextEditor::Cursor& realCursor) const;
00141     int viewLineCount(int realLine) const;
00142 
00143     void viewCacheDebugOutput() const;
00144     // END
00145 
00146 private Q_SLOTS:
00147     void slotEditDone(KateEditInfo* edit);
00148 
00149 private:
00150     void updateCache(int fromLine, int toLine, int shiftAmount);
00151 
00152     void expireUnused();
00153     void expireCount(int numberToExpire);
00154 
00155     KateRenderer* m_renderer;
00156 
00163     mutable KateLineLayoutMap m_lineLayouts;
00164 
00165     // Convenience vector for quick direct access to the specific text layout
00166     KTextEditor::Cursor m_startPos;
00167     mutable QVector<KateTextLayout> m_textLayouts;
00168 
00169     int m_viewWidth;
00170     bool m_wrap;
00171 
00172     QThreadStorage<bool*> m_acceptDirtyLayouts;
00173 };
00174 
00175 #endif
00176 
00177 // 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
  • 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