• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • render
katelayoutcache.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2005 Hamish Rodda <rodda@kde.org>
4  * Copyright (C) 2008 Dominik Haumann <dhaumann kde org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef KATELAYOUTCACHE_H
23 #define KATELAYOUTCACHE_H
24 
25 #include <QPair>
26 
27 #include <ktexteditor/range.h>
28 
29 #include "katetextlayout.h"
30 
31 class KateRenderer;
32 
33 namespace KTextEditor { class Document; }
34 
35 class KateLineLayoutMap
36 {
37  public:
38  KateLineLayoutMap();
39  ~KateLineLayoutMap();
40 
41  inline void clear();
42 
43  inline bool contains(int i) const;
44 
45  inline void insert(int realLine, const KateLineLayoutPtr& lineLayoutPtr);
46 
47  inline void viewWidthIncreased();
48  inline void viewWidthDecreased(int newWidth);
49 
50  inline void relayoutLines(int startRealLine, int endRealLine);
51 
52  inline void slotEditDone(int fromLine, int toLine, int shiftAmount);
53 
54  KateLineLayoutPtr& operator[](int i);
55 
56  typedef QPair<int, KateLineLayoutPtr> LineLayoutPair;
57  private:
58  typedef QVector<LineLayoutPair> LineLayoutMap;
59  LineLayoutMap m_lineLayouts;
60 };
61 
77 class KateLayoutCache : public QObject
78 {
79  Q_OBJECT
80 
81  public:
82  explicit KateLayoutCache(KateRenderer* renderer, QObject* parent);
83 
84  void clear();
85 
86  int viewWidth() const;
87  void setViewWidth(int width);
88 
89  bool wrap() const;
90  void setWrap(bool wrap);
91 
92  bool acceptDirtyLayouts();
93  void setAcceptDirtyLayouts(bool accept);
94 
95  // BEGIN generic methods to get/set layouts
108  KateLineLayoutPtr line(int realLine, int virtualLine = -1);
110  KateLineLayoutPtr line(const KTextEditor::Cursor& realCursor);
111 
113  KateTextLayout textLayout(const KTextEditor::Cursor& realCursor);
114 
117  KateTextLayout textLayout(uint realLine, int viewLine);
118  // END
119 
120  // BEGIN methods to do with the caching of lines visible within a view
122  KateTextLayout& viewLine(int viewLine);
123 
124  // find the view line of the cursor, relative to the display (0 = top line of view, 1 = second line, etc.)
125  // if limitToVisible is true, only lines which are currently visible will be searched for, and -1 returned if the line is not visible.
126  int displayViewLine(const KTextEditor::Cursor& virtualCursor, bool limitToVisible = false);
127 
128  int viewCacheLineCount() const;
129  KTextEditor::Cursor viewCacheStart() const;
130  KTextEditor::Cursor viewCacheEnd() const;
131  void updateViewCache(const KTextEditor::Cursor& startPos, int newViewLineCount = -1, int viewLinesScrolled = 0);
132 
133  void relayoutLines(int startRealLine, int endRealLine);
134 
135  // find the index of the last view line for a specific line
136  int lastViewLine(int realLine);
137  // find the view line of cursor c (0 = same line, 1 = down one, etc.)
138  int viewLine(const KTextEditor::Cursor& realCursor);
139  int viewLineCount(int realLine);
140 
141  void viewCacheDebugOutput() const;
142  // END
143 
144 private Q_SLOTS:
145  void wrapLine (const KTextEditor::Cursor &position);
146  void unwrapLine (int line);
147  void insertText (const KTextEditor::Cursor &position, const QString &text);
148  void removeText (const KTextEditor::Range &range);
149 
150 private:
151  KateRenderer* m_renderer;
152 
159  mutable KateLineLayoutMap m_lineLayouts;
160 
161  // Convenience vector for quick direct access to the specific text layout
162  KTextEditor::Cursor m_startPos;
163  mutable QVector<KateTextLayout> m_textLayouts;
164 
165  int m_viewWidth;
166  bool m_wrap;
167  bool m_acceptDirtyLayouts;
168 };
169 
170 #endif
171 
172 // kate: space-indent on; indent-width 2; replace-tabs on;
KateLineLayoutMap::contains
bool contains(int i) const
Definition: katelayoutcache.cpp:54
KateLayoutCache::viewCacheStart
KTextEditor::Cursor viewCacheStart() const
Definition: katelayoutcache.cpp:369
KateLineLayoutMap::LineLayoutPair
QPair< int, KateLineLayoutPtr > LineLayoutPair
Definition: katelayoutcache.h:56
KateLineLayoutMap::KateLineLayoutMap
KateLineLayoutMap()
Definition: katelayoutcache.cpp:35
KateLineLayoutMap::insert
void insert(int realLine, const KateLineLayoutPtr &lineLayoutPtr)
Definition: katelayoutcache.cpp:61
KateLayoutCache::textLayout
KateTextLayout textLayout(const KTextEditor::Cursor &realCursor)
Returns the layout describing the text line which is occupied by realCursor.
Definition: katelayoutcache.cpp:337
KateLineLayoutMap::slotEditDone
void slotEditDone(int fromLine, int toLine, int shiftAmount)
Definition: katelayoutcache.cpp:105
KateLayoutCache::clear
void clear()
Definition: katelayoutcache.cpp:517
KateLineLayoutMap::relayoutLines
void relayoutLines(int startRealLine, int endRealLine)
Definition: katelayoutcache.cpp:92
KateLineLayoutMap::~KateLineLayoutMap
~KateLineLayoutMap()
Definition: katelayoutcache.cpp:39
KateLayoutCache::setAcceptDirtyLayouts
void setAcceptDirtyLayouts(bool accept)
Definition: katelayoutcache.cpp:565
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:50
KateLayoutCache::acceptDirtyLayouts
bool acceptDirtyLayouts()
Definition: katelayoutcache.cpp:560
KateLineLayoutMap::viewWidthDecreased
void viewWidthDecreased(int newWidth)
Definition: katelayoutcache.cpp:82
KateLayoutCache::wrap
bool wrap() const
Definition: katelayoutcache.cpp:541
KateLayoutCache::lastViewLine
int lastViewLine(int realLine)
Definition: katelayoutcache.cpp:466
QObject
KateLayoutCache::KateLayoutCache
KateLayoutCache(KateRenderer *renderer, QObject *parent)
Definition: katelayoutcache.cpp:140
KateLayoutCache::line
KateLineLayoutPtr line(int realLine, int virtualLine=-1)
Returns the KateLineLayout for the specified line.
Definition: katelayoutcache.cpp:280
KateLineLayoutMap
Definition: katelayoutcache.h:35
QString
KateLayoutCache
This class handles Kate's caching of layouting information (in KateLineLayout and KateTextLayout)...
Definition: katelayoutcache.h:77
KateLayoutCache::viewLine
KateTextLayout & viewLine(int viewLine)
Returns the layout of the corresponding line in the view.
Definition: katelayoutcache.cpp:358
QPair
KateLineLayoutMap::operator[]
KateLineLayoutPtr & operator[](int i)
Definition: katelayoutcache.cpp:132
KateLayoutCache::setViewWidth
void setViewWidth(int width)
Definition: katelayoutcache.cpp:524
KateLayoutCache::setWrap
void setWrap(bool wrap)
Definition: katelayoutcache.cpp:546
katetextlayout.h
KateLayoutCache::viewLineCount
int viewLineCount(int realLine)
Definition: katelayoutcache.cpp:475
KateTextLayout
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
Definition: katetextlayout.h:38
QVector< LineLayoutPair >
KateLayoutCache::relayoutLines
void relayoutLines(int startRealLine, int endRealLine)
Definition: katelayoutcache.cpp:552
KateLayoutCache::viewCacheEnd
KTextEditor::Cursor viewCacheEnd() const
Definition: katelayoutcache.cpp:374
KateLayoutCache::displayViewLine
int displayViewLine(const KTextEditor::Cursor &virtualCursor, bool limitToVisible=false)
Definition: katelayoutcache.cpp:405
KateLayoutCache::viewWidth
int viewWidth() const
Definition: katelayoutcache.cpp:379
KateLineLayoutMap::viewWidthIncreased
void viewWidthIncreased()
Definition: katelayoutcache.cpp:73
KateLayoutCache::viewCacheDebugOutput
void viewCacheDebugOutput() const
Definition: katelayoutcache.cpp:480
KateLayoutCache::viewCacheLineCount
int viewCacheLineCount() const
Definition: katelayoutcache.cpp:364
QObject::parent
QObject * parent() const
KateLayoutCache::updateViewCache
void updateViewCache(const KTextEditor::Cursor &startPos, int newViewLineCount=-1, int viewLinesScrolled=0)
Definition: katelayoutcache.cpp:159
KateLineLayoutPtr
KSharedPtr< KateLineLayout > KateLineLayoutPtr
Definition: katelinelayout.h:120
KateLineLayoutMap::clear
void clear()
Definition: katelayoutcache.cpp:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal