2 This file is part of Konsole, an X terminal.
3 Copyright 2000 by Stephan Kulow <coolo@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 //#error Do not use in KDE 2.1
28 #define BlockSize (1 << 12)
29 #define ENTRIES ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char))
36 unsigned char data
[ENTRIES
];
40 // ///////////////////////////////////////////////////////
45 * Creates a history file for holding
46 * maximal size blocks. If more blocks
47 * are requested, then it drops earlier
56 * adds the Block at the end of history.
57 * This may drop other blocks.
59 * The ownership on the block is transfered.
60 * An unique index number is returned for accessing
61 * it later (if not yet dropped then)
63 * Note, that the block may be dropped completely
64 * if history is turned off.
66 size_t append(Block
*block
);
69 * gets the block at the index. Function may return
70 * 0 if the block isn't available any more.
72 * The returned block is strictly readonly as only
73 * maped in memory - and will be invalid on the next
74 * operation on this class.
76 const Block
*at(size_t index
);
79 * reorders blocks as needed. If newsize is null,
80 * the history is emptied completely. The indices
81 * returned on append won't change their semantic,
82 * but they may not be valid after this call.
84 bool setHistorySize(size_t newsize
);
88 Block
*lastBlock() const;
91 * Convenient function to set the size in KBytes
94 bool setSize(size_t newsize
);
96 size_t len() const { return length
; }
98 bool has(size_t index
) const;
100 size_t getCurrent() const { return current
; }
104 void increaseBuffer();
105 void decreaseBuffer(size_t newsize
);
108 // current always shows to the last inserted block
113 size_t lastmap_index
;