Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GRASS] qtermwidget updated to github.com/qterminal/qtermwidget 72ffc262
  • Loading branch information
blazek committed Aug 26, 2015
1 parent 84a4036 commit 61a1121
Show file tree
Hide file tree
Showing 63 changed files with 16,332 additions and 14,236 deletions.
502 changes: 260 additions & 242 deletions src/plugins/grass/qtermwidget/BlockArray.cpp

Large diffs are not rendered by default.

173 changes: 88 additions & 85 deletions src/plugins/grass/qtermwidget/BlockArray.h
Expand Up @@ -30,97 +30,100 @@
#define BlockSize (1 << 12)
#define ENTRIES ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char))

namespace Konsole
{
namespace Konsole {

struct Block
{
Block() { size = 0; }
struct Block {
Block() {
size = 0;
}
unsigned char data[ENTRIES];
size_t size;
};
};

// ///////////////////////////////////////////////////////

class BlockArray
{
public:
/**
* Creates a history file for holding
* maximal size blocks. If more blocks
* are requested, then it drops earlier
* added ones.
*/
BlockArray();

/// destructor
~BlockArray();

/**
* adds the Block at the end of history.
* This may drop other blocks.
*
* The ownership on the block is transfered.
* An unique index number is returned for accessing
* it later (if not yet dropped then)
*
* Note, that the block may be dropped completely
* if history is turned off.
*/
size_t append( Block *block );

/**
* gets the block at the index. Function may return
* 0 if the block isn't available any more.
*
* The returned block is strictly readonly as only
* maped in memory - and will be invalid on the next
* operation on this class.
*/
const Block *at( size_t index );

/**
* reorders blocks as needed. If newsize is null,
* the history is emptied completely. The indices
* returned on append won't change their semantic,
* but they may not be valid after this call.
*/
bool setHistorySize( size_t newsize );

size_t newBlock();

Block *lastBlock() const;

/**
* Convenient function to set the size in KBytes
* instead of blocks
*/
bool setSize( size_t newsize );

size_t len() const { return length; }

bool has( size_t index ) const;

size_t getCurrent() const { return current; }

private:
void unmap();
void increaseBuffer();
void decreaseBuffer( size_t newsize );

size_t size;
// current always shows to the last inserted block
size_t current;
size_t index;

Block *lastmap;
size_t lastmap_index;
Block *lastblock;

int ion;
size_t length;

};
class BlockArray {
public:
/**
* Creates a history file for holding
* maximal size blocks. If more blocks
* are requested, then it drops earlier
* added ones.
*/
BlockArray();

/// destructor
~BlockArray();

/**
* adds the Block at the end of history.
* This may drop other blocks.
*
* The ownership on the block is transfered.
* An unique index number is returned for accessing
* it later (if not yet dropped then)
*
* Note, that the block may be dropped completely
* if history is turned off.
*/
size_t append(Block * block);

/**
* gets the block at the index. Function may return
* 0 if the block isn't available any more.
*
* The returned block is strictly readonly as only
* maped in memory - and will be invalid on the next
* operation on this class.
*/
const Block * at(size_t index);

/**
* reorders blocks as needed. If newsize is null,
* the history is emptied completely. The indices
* returned on append won't change their semantic,
* but they may not be valid after this call.
*/
bool setHistorySize(size_t newsize);

size_t newBlock();

Block * lastBlock() const;

/**
* Convenient function to set the size in KBytes
* instead of blocks
*/
bool setSize(size_t newsize);

size_t len() const {
return length;
}

bool has(size_t index) const;

size_t getCurrent() const {
return current;
}

private:
void unmap();
void increaseBuffer();
void decreaseBuffer(size_t newsize);

size_t size;
// current always shows to the last inserted block
size_t current;
size_t index;

Block * lastmap;
size_t lastmap_index;
Block * lastblock;

int ion;
size_t length;

};

}

Expand Down

0 comments on commit 61a1121

Please sign in to comment.