Commit 4fc03400 authored by Carlos Alves's avatar Carlos Alves Committed by Tomaz Canabrava
Browse files

Add insert to history

Modify old history to insert a line into an specific position.
parent 6bcc3064
......@@ -48,6 +48,10 @@ public:
virtual void addLine(bool previousWrapped = false) = 0;
// modify history
virtual void insertCellsVector(int position, const QVector<Character> &cells) = 0;
virtual void insertCells(int position, const Character a[], int count) = 0;
virtual void removeCells(int position) = 0;
virtual void setCellsAt(int position, const Character a[], int count) = 0;
virtual void setCellsVectorAt(int position, const QVector<Character> &cells) = 0;
virtual void setLineAt(int position, bool previousWrapped) = 0;
......
......@@ -80,6 +80,22 @@ void HistoryScrollFile::addLine(bool previousWrapped)
_lineflags.add(reinterpret_cast<char *>(&flags), sizeof(char));
}
void HistoryScrollFile::insertCells(int , const Character [], int)
{
}
void HistoryScrollFile::removeCells(int )
{
}
void HistoryScrollFile::insertCellsVector(int , const QVector<Character> &)
{
}
void HistoryScrollFile::setCellsAt(int , const Character [], int)
{
}
void HistoryScrollFile::setCellsVectorAt(int , const QVector<Character> &)
{
}
......
......@@ -34,6 +34,10 @@ public:
void addCells(const Character text[], int count) override;
void addLine(bool previousWrapped = false) override;
void insertCellsVector(int position, const QVector<Character> &cells) override;
void insertCells(int position, const Character a[], int count) override;
void removeCells(int position) override;
void setCellsAt(int position, const Character a[], int count) override;
void setCellsVectorAt(int position, const QVector<Character> &cells) override;
void setLineAt(int position, bool previousWrapped) override;
......
......@@ -52,6 +52,22 @@ void HistoryScrollNone::addLine(bool)
{
}
void HistoryScrollNone::insertCells(int , const Character [], int)
{
}
void HistoryScrollNone::removeCells(int )
{
}
void HistoryScrollNone::insertCellsVector(int , const QVector<Character> &)
{
}
void HistoryScrollNone::setCellsAt(int , const Character [], int)
{
}
void HistoryScrollNone::setCellsVectorAt(int , const QVector<Character> &)
{
}
......
......@@ -33,6 +33,10 @@ public:
void addCells(const Character a[], int count) override;
void addLine(bool previousWrapped = false) override;
void insertCellsVector(int position, const QVector<Character> &cells) override;
void insertCells(int position, const Character a[], int count) override;
void removeCells(int position) override;
void setCellsAt(int position, const Character a[], int count) override;
void setCellsVectorAt(int position, const QVector<Character> &cells) override;
void setLineAt(int position, bool previousWrapped) override;
};
......
......@@ -91,6 +91,36 @@ void CompactHistoryScroll::setMaxNbLines(unsigned int lineCount)
////qDebug() << "set max lines to: " << _maxLineCount;
}
void CompactHistoryScroll::insertCellsVector(int position, const TextLine &cells)
{
CompactHistoryLine *line = new(_blockList) CompactHistoryLine(cells, _blockList);
_lines.insert(position, line);
if (_lines.size() > static_cast<int>(_maxLineCount)) {
delete _lines.takeAt(0);
}
}
void CompactHistoryScroll::insertCells(int position, const Character a[], int count)
{
TextLine newLine(count);
std::copy(a, a + count, newLine.begin());
insertCellsVector(position, newLine);
}
void CompactHistoryScroll::removeCells(int position)
{
delete _lines.takeAt(position);
}
void CompactHistoryScroll::setCellsAt(int position, const Character a[], int count)
{
TextLine newLine(count);
std::copy(a, a + count, newLine.begin());
setCellsVectorAt(position, newLine);
}
void CompactHistoryScroll::setCellsVectorAt(int position, const TextLine &cells)
{
CompactHistoryLine *line = new(_blockList) CompactHistoryLine(cells, _blockList);
......
......@@ -32,7 +32,12 @@ public:
void addCellsVector(const TextLine &cells) override;
void addLine(bool previousWrapped = false) override;
void insertCellsVector(int position, const TextLine &cells) override;
void insertCells(int position, const Character a[], int count) override;
void removeCells(int position) override;
void setMaxNbLines(unsigned int lineCount);
void setCellsAt(int position, const Character a[], int count) override;
void setCellsVectorAt(int position, const TextLine &cells) override;
void setLineAt(int position, bool previousWrapped) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment