32 #include <sys/types.h>
39 #define LINE_SIZE 1024
110 fileMap = (
char*)mmap(
nullptr ,
length , PROT_READ , MAP_PRIVATE ,
ion , 0 );
117 qDebug() <<
": mmap'ing history failed. errno = " << errno;
124 assert( result == 0 );
143 rc = lseek(
ion,
length,
SEEK_SET);
if (rc < 0) { perror(
"HistoryFile::add.seek");
return; }
144 rc = write(
ion,bytes,
len);
if (rc < 0) { perror(
"HistoryFile::add.write");
return; }
160 for (
int i=0;i<
len;i++)
167 if (
loc < 0 || len < 0 || loc + len >
length)
168 fprintf(stderr,
"getHist(...,%d,%d): invalid args.\n",
len,
loc);
169 rc = lseek(
ion,
loc,
SEEK_SET);
if (rc < 0) { perror(
"HistoryFile::get.seek");
return; }
170 rc = read(
ion,bytes,
len);
if (rc < 0) { perror(
"HistoryFile::get.read");
return; }
213 m_logFileName(logFileName)
233 if (lineno>=0 && lineno <=
getLines()) {
235 lineflags.
get((
unsigned char*)&flag,
sizeof(
unsigned char),(lineno)*
sizeof(
unsigned char));
243 if (lineno <= 0)
return 0;
251 index.
get((
unsigned char*)&res,
sizeof(
int),(lineno-1)*
sizeof(
int));
273 index.
add((
unsigned char*)&locn,
sizeof(
int));
274 unsigned char flags = previousWrapped ? 0x01 : 0x00;
275 lineflags.
add((
unsigned char*)&flags,
sizeof(
unsigned char));
312 std::copy(a,a+count,newLine.begin());
356 if ( count == 0 )
return;
362 memset(buffer, 0, count *
sizeof(
Character));
372 Q_ASSERT( startColumn <= line.size() - count );
374 memcpy(buffer, line.constData() + startColumn , count *
sizeof(
Character));
382 for (
int i = 0 ; i < qMin(
_usedLines,(
int)lineCount) ; i++ )
399 Q_ASSERT( lineNumber >= 0 );
495 memset(res, 0, count *
sizeof(
Character));
621 for(
int i = startLine; i < lines; i++)
627 old->
getCells(i, 0, size, tmp_line);
628 newScroll->
addCells(tmp_line, size);
648 : m_fileName(fileName)
670 int lines = (old !=
nullptr) ? old->
getLines() : 0;
671 for(
int i = 0; i < lines; i++)
677 old->
getCells(i, 0, size, tmp_line);
678 newScroll->
addCells(tmp_line, size);
size_t getCurrent() const
const Block * at(size_t index)
gets the block at the index.
Block * lastBlock() const
bool setHistorySize(size_t newsize)
reorders blocks as needed.
A single character in the terminal which consists of a unicode character value, foreground and backgr...
static const int MAP_THRESHOLD
virtual void get(unsigned char *bytes, int len, int loc)
virtual void add(const unsigned char *bytes, int len)
HistoryScrollBlockArray(size_t size)
virtual bool isWrappedLine(int lineno)
QHash< int, size_t > m_lineLengths
virtual ~HistoryScrollBlockArray()
virtual void addCells(const Character a[], int count)
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual int getLineLen(int lineno)
virtual void addLine(bool previousWrapped=false)
virtual ~HistoryScrollBuffer()
virtual bool isWrappedLine(int lineno)
HistoryLine * _historyBuffer
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual void addCells(const Character a[], int count)
HistoryScrollBuffer(unsigned int maxNbLines=1000)
virtual int getLineLen(int lineno)
void setMaxNbLines(unsigned int nbLines)
int bufferIndex(int lineNumber)
virtual void addCellsVector(const QVector< Character > &cells)
QVector< Character > HistoryLine
virtual void addLine(bool previousWrapped=false)
virtual bool isWrappedLine(int lineno)
virtual void addLine(bool previousWrapped=false)
virtual ~HistoryScrollFile()
HistoryScrollFile(const QString &logFileName)
virtual int getLineLen(int lineno)
virtual void addCells(const Character a[], int count)
virtual void getCells(int lineno, int colno, int count, Character res[])
int startOfLine(int lineno)
virtual bool isWrappedLine(int lineno)
virtual int getLineLen(int lineno)
virtual ~HistoryScrollNone()
virtual void addCells(const Character a[], int count)
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual void addLine(bool previousWrapped=false)
virtual void addCells(const Character a[], int count)=0
virtual void addLine(bool previousWrapped=false)=0
virtual bool isWrappedLine(int lineno)=0
virtual int getLineLen(int lineno)=0
virtual void getCells(int lineno, int colno, int count, Character res[])=0
HistoryScroll(HistoryType *)
HistoryTypeBlockArray(size_t size)
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual int maximumLineCount() const
Returns the maximum number of lines which this history type can store or 0 if the history can store a...
virtual int maximumLineCount() const
Returns the maximum number of lines which this history type can store or 0 if the history can store a...
HistoryTypeBuffer(unsigned int nbLines)
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual const QString & getFileName() const
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
virtual int maximumLineCount() const
Returns the maximum number of lines which this history type can store or 0 if the history can store a...
HistoryTypeFile(const QString &fileName=QString())
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual int maximumLineCount() const
Returns the maximum number of lines which this history type can store or 0 if the history can store a...
unsigned char data[(((1<< 12) - sizeof(size_t))/sizeof(unsigned char))]