Commit 57ce654d authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Kurt Hindenburg
Browse files

Support scrolling double-height/width lines

The scrollback buffer has support for a wrapped property for every line.
Extend it to support the line rendition attributes.
parent c61e4cac
......@@ -699,10 +699,7 @@ QVector<LineProperty> Screen::getLineProperties(int startLine , int endLine) con
// copy properties for _lines in history
for (int line = startLine; line < startLine + linesInHistory; line++) {
//TODO Support for line properties other than wrapped _lines
if (_history->isWrappedLine(line)) {
result[index] = static_cast<LineProperty>(result[index] | LINE_WRAPPED);
}
result[index] = _history->getLineProperty(line);
index++;
}
......@@ -1615,7 +1612,7 @@ void Screen::addHistLine()
if (hasScroll()) {
_history->addCellsVector(_screenLines[0]);
_history->addLine((_lineProperties[0] & LINE_WRAPPED) != 0);
_history->addLine(_lineProperties[0]);
newHistLines = _history->getLines();
......
......@@ -39,6 +39,7 @@ public:
virtual int getLineLen(int lineno) = 0;
virtual void getCells(int lineno, int colno, int count, Character res[]) = 0;
virtual bool isWrappedLine(int lineNumber) = 0;
virtual LineProperty getLineProperty(int lineno) = 0;
// adding lines.
virtual void addCells(const Character a[], int count) = 0;
......@@ -49,7 +50,7 @@ public:
addCells(cells.data(), cells.size());
}
virtual void addLine(bool previousWrapped = false) = 0;
virtual void addLine(LineProperty lineProperty = 0) = 0;
// modify history
virtual void insertCellsVector(int position, const QVector<Character> &cells) = 0;
......
......@@ -49,11 +49,22 @@ bool HistoryScrollFile::isWrappedLine(int lineno)
unsigned char flag = 0;
_lineflags.get(reinterpret_cast<char *>(&flag), sizeof(unsigned char),
(lineno)*sizeof(unsigned char));
return flag != 0u;
return (flag & LINE_WRAPPED) != 0;
}
return false;
}
LineProperty HistoryScrollFile::getLineProperty(int lineno)
{
if (lineno >= 0 && lineno <= getLines()) {
LineProperty flag = 0;
_lineflags.get(reinterpret_cast<char *>(&flag), sizeof(unsigned char),
(lineno)*sizeof(unsigned char));
return flag;
}
return 0;
}
qint64 HistoryScrollFile::startOfLine(int lineno)
{
if (lineno <= 0) {
......@@ -77,12 +88,11 @@ void HistoryScrollFile::addCells(const Character text[], int count)
_cells.add(reinterpret_cast<const char*>(text), count * sizeof(Character));
}
void HistoryScrollFile::addLine(bool previousWrapped)
void HistoryScrollFile::addLine(LineProperty lineProperty)
{
qint64 locn = _cells.len();
_index.add(reinterpret_cast<char *>(&locn), sizeof(qint64));
unsigned char flags = previousWrapped ? 0x01 : 0x00;
_lineflags.add(reinterpret_cast<char *>(&flags), sizeof(char));
_lineflags.add(reinterpret_cast<char *>(&lineProperty), sizeof(char));
}
void HistoryScrollFile::insertCells(int, const Character[], int)
......
......@@ -31,9 +31,10 @@ public:
int getLineLen(int lineno) override;
void getCells(int lineno, int colno, int count, Character res[]) override;
bool isWrappedLine(int lineno) override;
LineProperty getLineProperty(int lineno) override;
void addCells(const Character text[], int count) override;
void addLine(bool previousWrapped = false) override;
void addLine(LineProperty lineProperty = 0) override;
// Modify history
void insertCellsVector(int position, const QVector<Character> &cells) override;
......
......@@ -45,6 +45,11 @@ bool HistoryScrollNone::isWrappedLine(int /*lineno*/)
return false;
}
LineProperty HistoryScrollNone::getLineProperty(int /*lineno*/)
{
return 0;
}
void HistoryScrollNone::getCells(int, int, int, Character [])
{
}
......@@ -53,7 +58,7 @@ void HistoryScrollNone::addCells(const Character [], int)
{
}
void HistoryScrollNone::addLine(bool)
void HistoryScrollNone::addLine(LineProperty)
{
}
......
......@@ -30,9 +30,10 @@ public:
int getLineLen(int lineno) override;
void getCells(int lineno, int colno, int count, Character res[]) override;
bool isWrappedLine(int lineno) override;
LineProperty getLineProperty(int lineno) override;
void addCells(const Character a[], int count) override;
void addLine(bool previousWrapped = false) override;
void addLine(LineProperty lineProperty = 0) override;
// Modify history (do nothing here)
void insertCellsVector(int position, const QVector<Character> &cells) override;
......
......@@ -23,7 +23,7 @@ CompactHistoryLine::CompactHistoryLine(const TextLine &line, CompactHistoryBlock
_formatArray(nullptr),
_text(nullptr),
_formatLength(0),
_wrapped(false)
_lineProperty(0)
{
if (!line.isEmpty()) {
_length = line.size();
......@@ -56,7 +56,7 @@ CompactHistoryLine::CompactHistoryLine(const TextLine &line, CompactHistoryBlock
_text[i] = line[i].character;
}
_wrapped = false;
_lineProperty = 0;
}
}
......@@ -148,12 +148,26 @@ void CompactHistoryLine::setCharacters(const TextLine &line)
bool CompactHistoryLine::isWrapped() const
{
return _wrapped;
return _lineProperty & LINE_WRAPPED;
}
void CompactHistoryLine::setWrapped(bool value)
{
_wrapped = value;
if (value) {
_lineProperty |= LINE_WRAPPED;
} else {
_lineProperty &= ~LINE_WRAPPED;
}
}
LineProperty CompactHistoryLine::getLineProperty() const
{
return _lineProperty;
}
void CompactHistoryLine::setLineProperty(LineProperty value)
{
_lineProperty = value;
}
unsigned int CompactHistoryLine::getLength() const
......
......@@ -31,6 +31,8 @@ public:
virtual void getCharacters(Character *array, int size, int startColumn);
virtual bool isWrapped() const;
virtual void setWrapped(bool value);
virtual LineProperty getLineProperty() const;
virtual void setLineProperty(LineProperty value);
virtual unsigned int getLength() const;
protected:
......@@ -39,7 +41,7 @@ protected:
quint16 _length;
uint *_text;
quint16 _formatLength;
bool _wrapped;
LineProperty _lineProperty;
};
}
......
......@@ -44,11 +44,11 @@ void CompactHistoryScroll::addCells(const Character a[], int count)
addCellsVector(newLine);
}
void CompactHistoryScroll::addLine(bool previousWrapped)
void CompactHistoryScroll::addLine(LineProperty lineProperty)
{
auto line = _lines.back().get();
////qDebug() << "last line at address " << line;
line->setWrapped(previousWrapped);
line->setLineProperty(lineProperty);
}
int CompactHistoryScroll::getLines()
......@@ -143,6 +143,12 @@ bool CompactHistoryScroll::isWrappedLine(int lineNumber)
return _lines[lineNumber]->isWrapped();
}
LineProperty CompactHistoryScroll::getLineProperty(int lineNumber)
{
Q_ASSERT(static_cast<size_t>(lineNumber) < _lines.size());
return _lines[lineNumber]->getLineProperty();
}
int CompactHistoryScroll::reflowLines(int columns)
{
auto getCharacterBuffer = [](int size) {
......
......@@ -31,10 +31,11 @@ public:
int getLineLen(int lineNumber) override;
void getCells(int lineNumber, int startColumn, int count, Character buffer[]) override;
bool isWrappedLine(int lineNumber) override;
LineProperty getLineProperty(int lineNumber) override;
void addCells(const Character a[], int count) override;
void addCellsVector(const TextLine &cells) override;
void addLine(bool previousWrapped = false) override;
void addLine(LineProperty lineProperty = 0) override;
void insertCellsVector(int position, const TextLine &cells) override;
void insertCells(int position, const Character a[], int count) 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