31 #include <sys/types.h>
38 #define LINE_SIZE 1024
116 qDebug() <<
": mmap'ing history failed. errno = " << errno;
123 assert( result == 0 );
142 rc = lseek(
ion,
length,
SEEK_SET);
if (rc < 0) { perror(
"HistoryFile::add.seek");
return; }
143 rc = write(
ion,bytes,len);
if (rc < 0) { perror(
"HistoryFile::add.write");
return; }
159 for (
int i=0;i<
len;i++)
166 if (loc < 0 || len < 0 || loc + len >
length)
167 fprintf(stderr,
"getHist(...,%d,%d): invalid args.\n",len,loc);
168 rc = lseek(
ion,loc,
SEEK_SET);
if (rc < 0) { perror(
"HistoryFile::get.seek");
return; }
169 rc = read(
ion,bytes,len);
if (rc < 0) { perror(
"HistoryFile::get.read");
return; }
212 m_logFileName(logFileName)
232 if (lineno>=0 && lineno <=
getLines()) {
234 lineflags.
get((
unsigned char*)&flag,
sizeof(
unsigned char),(lineno)*
sizeof(
unsigned char));
242 if (lineno <= 0)
return 0;
250 index.
get((
unsigned char*)&res,
sizeof(
int),(lineno-1)*
sizeof(
int));
272 index.
add((
unsigned char*)&locn,
sizeof(
int));
273 unsigned char flags = previousWrapped ? 0x01 : 0x00;
274 lineflags.
add((
unsigned char*)&flags,
sizeof(
unsigned char));
311 qCopy(a,a+count,newLine.begin());
355 if ( count == 0 )
return;
361 memset(buffer, 0, count *
sizeof(
Character));
371 Q_ASSERT( startColumn <= line.size() - count );
373 memcpy(buffer, line.constData() + startColumn , count *
sizeof(
Character));
381 for (
int i = 0 ; i < qMin(
_usedLines,(
int)lineCount) ; i++ )
398 Q_ASSERT( lineNumber >= 0 );
494 memset(res, 0, count *
sizeof(
Character));
620 for(
int i = startLine; i < lines; i++)
626 old->
getCells(i, 0, size, tmp_line);
627 newScroll->
addCells(tmp_line, size);
647 : m_fileName(fileName)
663 if (dynamic_cast<HistoryFile *>(old))
669 int lines = (old != 0) ? old->
getLines() : 0;
670 for(
int i = 0; i < lines; i++)
676 old->
getCells(i, 0, size, tmp_line);
677 newScroll->
addCells(tmp_line, size);
virtual HistoryScroll * scroll(HistoryScroll *) const
size_t getCurrent() const
virtual void addLine(bool previousWrapped=false)
virtual void getCells(int lineno, int colno, int count, Character res[])=0
virtual ~HistoryScrollNone()
virtual void addCells(const Character a[], int count)
HistoryScroll(HistoryType *)
virtual void addCells(const Character a[], int count)=0
A single character in the terminal which consists of a unicode character value, foreground and backgr...
QVector< Character > HistoryLine
Block * lastBlock() const
virtual const QString & getFileName() const
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual void addCells(const Character a[], int count)
HistoryLine * _historyBuffer
virtual bool isWrappedLine(int lineno)=0
virtual bool isWrappedLine(int lineno)
virtual void getCells(int lineno, int colno, int count, Character res[])
HistoryScrollBlockArray(size_t size)
virtual void addLine(bool previousWrapped=false)
virtual ~HistoryScrollBlockArray()
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...
virtual void addCellsVector(const QVector< Character > &cells)
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...
virtual int getLineLen(int lineno)
virtual bool isWrappedLine(int lineno)
HistoryScrollBuffer(unsigned int maxNbLines=1000)
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
bool setHistorySize(size_t newsize)
reorders blocks as needed.
virtual void addLine(bool previousWrapped=false)
size_t size(T const (&)[z])
unsigned char data[(((1<< 12)-sizeof(size_t))/sizeof(unsigned char))]
HistoryTypeBuffer(unsigned int nbLines)
virtual int getLineLen(int lineno)
virtual HistoryScroll * scroll(HistoryScroll *) const
QHash< int, size_t > m_lineLengths
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual int getLineLen(int lineno)
virtual bool isWrappedLine(int lineno)
int startOfLine(int lineno)
virtual ~HistoryScrollFile()
HistoryTypeBlockArray(size_t size)
virtual void addCells(const Character a[], int count)
void setMaxNbLines(unsigned int nbLines)
virtual void getCells(int lineno, int colno, int count, Character res[])
HistoryTypeFile(const QString &fileName=QString())
virtual void get(unsigned char *bytes, int len, int loc)
virtual int getLineLen(int lineno)=0
static const int MAP_THRESHOLD
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
virtual void addLine(bool previousWrapped=false)=0
virtual bool isWrappedLine(int lineno)
int bufferIndex(int lineNumber)
HistoryScrollFile(const QString &logFileName)
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual void addCells(const Character a[], int count)
virtual void add(const unsigned char *bytes, int len)
const Block * at(size_t index)
gets the block at the index.
virtual int getLineLen(int lineno)
virtual ~HistoryScrollBuffer()
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 HistoryScroll * scroll(HistoryScroll *) const
virtual void addLine(bool previousWrapped=false)
virtual int maximumLineCount() const
Returns the maximum number of lines which this history type can store or 0 if the history can store a...