Kate
katelayoutcache.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 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 typedef QPair<int, KateLineLayoutPtr> LineLayoutPair;
00057 private:
00058 typedef QVector<LineLayoutPair> LineLayoutMap;
00059 LineLayoutMap m_lineLayouts;
00060 };
00061
00062
00077 class KateLayoutCache : public QObject
00078 {
00079 Q_OBJECT
00080
00081 public:
00082 explicit KateLayoutCache(KateRenderer* renderer, QObject* parent);
00083
00084 void clear();
00085
00086 int viewWidth() const;
00087 void setViewWidth(int width);
00088
00089 bool wrap() const;
00090 void setWrap(bool wrap);
00091
00092 bool acceptDirtyLayouts() const;
00093 void setAcceptDirtyLayouts(bool accept);
00094
00095
00108 KateLineLayoutPtr line(int realLine, int virtualLine = -1) const;
00110 KateLineLayoutPtr line(const KTextEditor::Cursor& realCursor) const;
00111
00113 KateTextLayout textLayout(const KTextEditor::Cursor& realCursor) const;
00114
00117 KateTextLayout textLayout(uint realLine, int viewLine) const;
00118
00119
00120
00122 KateTextLayout& viewLine(int viewLine) const;
00123
00124
00125
00126 int displayViewLine(const KTextEditor::Cursor& virtualCursor, bool limitToVisible = false) const;
00127
00128 int viewCacheLineCount() const;
00129 KTextEditor::Cursor viewCacheStart() const;
00130 KTextEditor::Cursor viewCacheEnd() const;
00131 void updateViewCache(const KTextEditor::Cursor& startPos, int newViewLineCount = -1, int viewLinesScrolled = 0);
00132
00133 void relayoutLines(int startRealLine, int endRealLine);
00134
00135
00136 int lastViewLine(int realLine) const;
00137
00138 int viewLine(const KTextEditor::Cursor& realCursor) const;
00139 int viewLineCount(int realLine) const;
00140
00141 void viewCacheDebugOutput() const;
00142
00143
00144 private Q_SLOTS:
00145 void slotEditDone(KateEditInfo* edit);
00146
00147 private:
00148 KateRenderer* m_renderer;
00149
00156 mutable KateLineLayoutMap m_lineLayouts;
00157
00158
00159 KTextEditor::Cursor m_startPos;
00160 mutable QVector<KateTextLayout> m_textLayouts;
00161
00162 int m_viewWidth;
00163 bool m_wrap;
00164
00165 QThreadStorage<bool*> m_acceptDirtyLayouts;
00166 };
00167
00168 #endif
00169
00170