summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/document/katebuffer.h
Unidiff
Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katebuffer.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.h143
1 files changed, 143 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.h b/noncore/apps/tinykate/libkate/document/katebuffer.h
new file mode 100644
index 0000000..9088498
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/document/katebuffer.h
@@ -0,0 +1,143 @@
1/*
2 This file is part of KWrite
3 Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
4 Copyright (c) 2002 Joseph Wenninger <jowenn@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 version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21#ifndef _KWBUFFER_H_
22#define _KWBUFFER_H_
23
24#include <qstring.h>
25#include <qstringlist.h>
26#include <qlist.h>
27#include <qobject.h>
28#include <qtimer.h>
29
30#include "katetextline.h"
31
32class QTextCodec;
33
34/**
35 * The KWBuffer class maintains a collections of lines.
36 * It allows to maintain state information in a lazy way.
37 * It handles swapping out of data using secondary storage.
38 *
39 * It is designed to handle large amounts of text-data efficiently
40 * with respect to CPU and memory usage.
41 *
42 * @author Waldo Bastian <bastian@kde.org>
43 */
44class KWBuffer : public QObject
45{
46 Q_OBJECT
47public:
48 /**
49 * Create an empty buffer.
50 */
51 KWBuffer();
52
53 /**
54 * Insert a file at line @p line in the buffer.
55 * Using @p codec to decode the file.
56 */
57 void insertFile(int line, const QString &file, QTextCodec *codec);
58
59 /**
60 * Insert a block of data at line @p line in the buffer.
61 * Using @p codec to decode the file.
62 */
63 void insertData(int line, const QByteArray &data, QTextCodec *codec);
64
65 /**
66 * Return the total number of lines in the buffer.
67 */
68 int count();
69
70 /**
71 * Return line @p i
72 */
73 TextLine::Ptr line(int i);
74
75 /**
76 * Insert @p line in front of line @p i
77 */
78 void insertLine(int i, TextLine::Ptr line);
79
80 /**
81 * Remove line @p i
82 */
83 void removeLine(int i);
84
85 /**
86 * Change line @p i
87 */
88 void changeLine(int i);
89
90 /**
91 * Clear the buffer.
92 */
93 void clear();
94
95signals:
96
97 void textChanged();
98 /**
99 * Emitted during loading.
100 */
101 void linesChanged(int lines);
102 void needHighlight(long,long);
103
104protected:
105 /**
106 * Make sure @p buf gets loaded.
107 */
108 void loadBlock(KWBufBlock *buf);
109
110 /**
111 * Make sure @p buf gets parsed.
112 */
113 void parseBlock(KWBufBlock *buf);
114
115 /**
116 * Mark @p buf dirty.
117 */
118 void dirtyBlock(KWBufBlock *buf);
119
120 /**
121 * Find the block containing line @p i
122 */
123 KWBufBlock *findBlock(int i);
124
125 /**
126 * Load a part of the file that is currently loading.
127 */
128 void loadFilePart();
129
130protected slots:
131 void slotLoadFile();
132
133protected:
134 TextLine::List m_stringList;
135 TextLine::List::Iterator m_stringListIt;
136 int m_stringListCurrent;
137 int m_lineCount;
138 void seek(int i);
139
140
141};
142
143#endif