31 #include <sys/types.h> 38 #define LINE_SIZE 1024 109 fileMap = (
char*)mmap(
nullptr ,
length , PROT_READ , MAP_PRIVATE ,
ion , 0 );
116 qDebug() <<
": mmap'ing history failed. errno = " << errno;
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; }
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++)
627 newScroll->
addCells(tmp_line, size);
647 : m_fileName(fileName)
663 if (dynamic_cast<HistoryFile *>(old))
669 int lines = (old !=
nullptr) ? old->
getLines() : 0;
670 for(
int i = 0;
i < lines;
i++)
677 newScroll->
addCells(tmp_line, size);
virtual void addLine(bool previousWrapped=false)
virtual void getCells(int lineno, int colno, int count, Character res[])=0
virtual HistoryScroll * scroll(HistoryScroll *) const
size_t getCurrent() const
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
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual void addCells(const Character a[], int count)
HistoryLine * _historyBuffer
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual bool isWrappedLine(int lineno)=0
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
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)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
virtual ~HistoryScrollBlockArray()
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 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)
virtual int maximumLineCount() const
Returns the maximum number of lines which this history type can store or 0 if the history can store a...
HistoryScrollBuffer(unsigned int maxNbLines=1000)
bool setHistorySize(size_t newsize)
reorders blocks as needed.
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...
virtual const QString & getFileName() const
HistoryTypeBuffer(unsigned int nbLines)
virtual int getLineLen(int lineno)
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
QHash< int, size_t > m_lineLengths
virtual void getCells(int lineno, int colno, int count, Character res[])
virtual int getLineLen(int lineno)
With real return the complex result
virtual bool isWrappedLine(int lineno)
int startOfLine(int lineno)
virtual ~HistoryScrollFile()
HistoryTypeBlockArray(size_t size)
virtual void addCells(const Character a[], int count)
virtual HistoryScroll * scroll(HistoryScroll *) const
virtual bool isEnabled() const
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
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 void addLine(bool previousWrapped=false)=0
virtual bool isWrappedLine(int lineno)
int bufferIndex(int lineNumber)
HistoryScrollFile(const QString &logFileName)
virtual void addCells(const Character a[], int count)
virtual HistoryScroll * scroll(HistoryScroll *) const
Block * lastBlock() const
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 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...