| 1 | /* |
| 2 | This file is part of Konsole, an X terminal. |
| 3 | Copyright (C) 2000 by Stephan Kulow <[email protected]> |
| 4 | |
| 5 | Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 20 | 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #ifndef BLOCKARRAY_H |
| 24 | #define BLOCKARRAY_Hcxx . . $ `lib/BlockArray.h:24:9`! |
| 25 | |
| 26 | #include <unistd.h> |
| 27 | |
| 28 | //#error Do not use in KDE 2.1 |
| 29 | |
| 30 | #define QTERMWIDGET_BLOCKSIZEcxx . . $ `lib/BlockArray.h:30:9`! (1 << 12) |
| 31 | #define ENTRIEScxx . . $ `lib/BlockArray.h:31:9`! ((QTERMWIDGET_BLOCKSIZEcxx . . $ `lib/BlockArray.h:30:9`! - sizeof(size_t) ) / sizeof(unsigned char)) |
| 32 | |
| 33 | namespace Konsolecxx . . $ Konsole/ { |
| 34 | |
| 35 | struct Blockcxx . . $ Konsole/Block# { |
| 36 | Blockcxx . . $ Konsole/Block#Block(49f6e7a06ebc5aa8).() { |
| 37 | sizecxx . . $ Konsole/Block#size. = 0; |
| 38 | } |
| 39 | unsigned char datacxx . . $ Konsole/Block#data.[ENTRIEScxx . . $ `lib/BlockArray.h:31:9`!]; |
| 40 | size_t sizecxx . . $ Konsole/Block#size.; |
| 41 | }; |
| 42 | |
| 43 | // /////////////////////////////////////////////////////// |
| 44 | |
| 45 | class BlockArraycxx . . $ Konsole/BlockArray# { |
| 46 | public: |
| 47 | /** |
| 48 | * Creates a history file for holding |
| 49 | * maximal size blocks. If more blocks |
| 50 | * are requested, then it drops earlier |
| 51 | * added ones. |
| 52 | */ |
| 53 | BlockArraycxx . . $ Konsole/BlockArray#BlockArray(49f6e7a06ebc5aa8).(); |
| 54 | |
| 55 | /// destructor |
| 56 | ~cxx . . $ Konsole/BlockArray#`~BlockArray`(ced63f7c635d850d).BlockArraycxx . . $ Konsole/BlockArray#(); |
| 57 | |
| 58 | /** |
| 59 | * adds the Block at the end of history. |
| 60 | * This may drop other blocks. |
| 61 | * |
| 62 | * The ownership on the block is transfered. |
| 63 | * An unique index number is returned for accessing |
| 64 | * it later (if not yet dropped then) |
| 65 | * |
| 66 | * Note, that the block may be dropped completely |
| 67 | * if history is turned off. |
| 68 | */ |
| 69 | size_t appendcxx . . $ Konsole/BlockArray#append(6fe1facc1dab5d78).(Blockcxx . . $ Konsole/Block# * block); |
| 70 | |
| 71 | /** |
| 72 | * gets the block at the index. Function may return |
| 73 | * 0 if the block isn't available any more. |
| 74 | * |
| 75 | * The returned block is strictly readonly as only |
| 76 | * maped in memory - and will be invalid on the next |
| 77 | * operation on this class. |
| 78 | */ |
| 79 | const Blockcxx . . $ Konsole/Block# * atcxx . . $ Konsole/BlockArray#at(7d5b4b52cd5680c7).(size_t index); |
| 80 | |
| 81 | /** |
| 82 | * reorders blocks as needed. If newsize is null, |
| 83 | * the history is emptied completely. The indices |
| 84 | * returned on append won't change their semantic, |
| 85 | * but they may not be valid after this call. |
| 86 | */ |
| 87 | bool setHistorySizecxx . . $ Konsole/BlockArray#setHistorySize(31596a199e1d8a50).(size_t newsize); |
| 88 | |
| 89 | size_t newBlockcxx . . $ Konsole/BlockArray#newBlock(f708dce9a8856c70).(); |
| 90 | |
| 91 | Blockcxx . . $ Konsole/Block# * lastBlockcxx . . $ Konsole/BlockArray#lastBlock(ed43a5b5d99d0b0e).() const; |
| 92 | |
| 93 | /** |
| 94 | * Convenient function to set the size in KBytes |
| 95 | * instead of blocks |
| 96 | */ |
| 97 | bool setSizecxx . . $ Konsole/BlockArray#setSize(31596a199e1d8a50).(size_t newsize); |
| 98 | |
| 99 | size_t lencxx . . $ Konsole/BlockArray#len(fe4d2d262d4164a8).() const { |
| 100 | return lengthcxx . . $ Konsole/BlockArray#length.; |
| 101 | } |
| 102 | |
| 103 | bool hascxx . . $ Konsole/BlockArray#has(2ff7c7de1baa6d0a).(size_t index) const; |
| 104 | |
| 105 | size_t getCurrentcxx . . $ Konsole/BlockArray#getCurrent(fe4d2d262d4164a8).() const { |
| 106 | return currentcxx . . $ Konsole/BlockArray#current.; |
| 107 | } |
| 108 | |
| 109 | private: |
| 110 | void unmapcxx . . $ Konsole/BlockArray#unmap(49f6e7a06ebc5aa8).(); |
| 111 | void increaseBuffercxx . . $ Konsole/BlockArray#increaseBuffer(49f6e7a06ebc5aa8).(); |
| 112 | void decreaseBuffercxx . . $ Konsole/BlockArray#decreaseBuffer(2c44cd906ae4e829).(size_t newsize); |
| 113 | |
| 114 | size_t sizecxx . . $ Konsole/BlockArray#size.; |
| 115 | // current always shows to the last inserted block |
| 116 | size_t currentcxx . . $ Konsole/BlockArray#current.; |
| 117 | size_t indexcxx . . $ Konsole/BlockArray#index.; |
| 118 | |
| 119 | Blockcxx . . $ Konsole/Block# * lastmapcxx . . $ Konsole/BlockArray#lastmap.; |
| 120 | size_t lastmap_indexcxx . . $ Konsole/BlockArray#lastmap_index.; |
| 121 | Blockcxx . . $ Konsole/Block# * lastblockcxx . . $ Konsole/BlockArray#lastblock.; |
| 122 | |
| 123 | int ioncxx . . $ Konsole/BlockArray#ion.; |
| 124 | size_t lengthcxx . . $ Konsole/BlockArray#length.; |
| 125 | |
| 126 | }; |
| 127 | |
| 128 | } |
| 129 | |
| 130 | #endif |