Commit 9771b1d9 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Kurt Hindenburg
Browse files

Make reflow aware of line rendition attributes

While DECDHL/DECDWL lines are not wrapped at the correct column, now at
least reflowing doesn't clear line rendition attributes, so resizing
Konsole and going back to the original size always recovers the original
content, including double-height/double-width status of each line.

Reflowing double-height lines doesn't make much sense, since a
double-height line actually consists of a top (T) and a bottom (B)
line. Shrinking them could lead to TTBB lines, which look weird. At
least now going back to the original size brings back the original
content in all its glory.
parent 57ce654d
......@@ -511,11 +511,11 @@ void Screen::resizeImage(int new_lines, int new_columns)
while (cursorLine < oldCursorLine && _history->getLines()) {
int histPos = _history->getLines() - 1;
int histLineLen = _history->getLineLen(histPos);
int isWrapped = _history->isWrappedLine(histPos) ? LINE_WRAPPED : LINE_DEFAULT;
LineProperty lineProperty = _history->getLineProperty(histPos);
histLine.resize(histLineLen);
_history->getCells(histPos, 0, histLineLen, histLine.data());
_screenLines.insert(0, histLine);
_lineProperties.insert(0, isWrapped);
_lineProperties.insert(0, lineProperty);
_history->removeCells(histPos);
cursorLine++;
}
......@@ -1591,7 +1591,7 @@ void Screen::fastAddHistLine()
{
const bool removeLine = _history->getLines() == _history->getMaxLines();
_history->addCellsVector(_screenLines[0]);
_history->addLine((_lineProperties[0] & LINE_WRAPPED) != 0);
_history->addLine(_lineProperties[0]);
// If _history size > max history size it will drop a line from _history.
// We need to verify if we need to remove a URL.
......
......@@ -58,7 +58,7 @@ public:
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;
virtual void setLineAt(int position, LineProperty lineProperty) = 0;
virtual int reflowLines(int columns) = 0;
//
......
......@@ -141,7 +141,7 @@ int HistoryScrollFile::reflowLines(int columns)
auto reflowLineLen = [] (qint64 start, qint64 end) {
return (int)((end - start) / sizeof(Character));
};
auto setNewLine = [] (reflowData &change, qint64 index, bool lineflag) {
auto setNewLine = [] (reflowData &change, qint64 index, LineProperty lineflag) {
change.index = index;
change.lineFlag = lineflag;
};
......@@ -154,6 +154,7 @@ int HistoryScrollFile::reflowLines(int columns)
while (currentPos < getLines()) {
qint64 startLine = startOfLine(currentPos);
qint64 endLine = startOfLine(currentPos + 1);
LineProperty lineProperty = getLineProperty(currentPos);
// Join the lines if they are wrapped
while (isWrappedLine(currentPos)) {
......@@ -164,10 +165,10 @@ int HistoryScrollFile::reflowLines(int columns)
// Now reflow the lines
while (reflowLineLen(startLine, endLine) > columns) {
startLine += (qint64)columns * sizeof(Character);
setNewLine(newLine, startLine, true);
setNewLine(newLine, startLine, lineProperty | LINE_WRAPPED);
reflowFile->add(reinterpret_cast<const char *>(&newLine), sizeof(reflowData));
}
setNewLine(newLine, endLine, false);
setNewLine(newLine, endLine, lineProperty & ~LINE_WRAPPED);
reflowFile->add(reinterpret_cast<const char *>(&newLine), sizeof(reflowData));
currentPos++;
}
......@@ -188,8 +189,7 @@ int HistoryScrollFile::reflowLines(int columns)
while (currentPos < totalLines) {
reflowFile->get(reinterpret_cast<char *>(&newLine), sizeof(reflowData), currentPos * sizeof(reflowData));
unsigned char flags = newLine.lineFlag ? 0x01 : 0x00;
_lineflags.add(reinterpret_cast<char *>(&flags), sizeof(char));
_lineflags.add(reinterpret_cast<char *>(&newLine.lineFlag), sizeof(char));
_index.add(reinterpret_cast<char *>(&newLine.index), sizeof(qint64));
currentPos++;
}
......@@ -197,7 +197,7 @@ int HistoryScrollFile::reflowLines(int columns)
return 0;
}
void HistoryScrollFile::setLineAt(int, bool previousWrapped)
void HistoryScrollFile::setLineAt(int, LineProperty lineProperty)
{
qint64 locn = qMax(0, getLines() - 1);
_index.removeLast(locn * sizeof(qint64));
......@@ -206,6 +206,5 @@ void HistoryScrollFile::setLineAt(int, bool previousWrapped)
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));
}
......@@ -42,7 +42,7 @@ public:
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;
void setLineAt(int position, LineProperty lineProperty) override;
int reflowLines(int columns) override;
private:
......@@ -54,7 +54,7 @@ private:
struct reflowData { // data to reflow lines
qint64 index;
bool lineFlag;
LineProperty lineFlag;
};
};
......
......@@ -87,6 +87,6 @@ int HistoryScrollNone::reflowLines(int)
return 0;
}
void HistoryScrollNone::setLineAt(int , bool)
void HistoryScrollNone::setLineAt(int , LineProperty)
{
}
......@@ -41,7 +41,7 @@ public:
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;
void setLineAt(int position, LineProperty lineProperty) override;
int reflowLines(int) override;
};
......
......@@ -35,11 +35,11 @@ void HistoryTypeFile::scroll(std::unique_ptr<HistoryScroll> &old) const
auto tmp_line = std::make_unique<Character[]>(size);
old->getCells(i, 0, size, tmp_line.get());
newScroll->addCells(tmp_line.get(), size);
newScroll->addLine(old->isWrappedLine(i));
newScroll->addLine(old->getLineProperty(i));
} else {
old->getCells(i, 0, size, line);
newScroll->addCells(line, size);
newScroll->addLine(old->isWrappedLine(i));
newScroll->addLine(old->getLineProperty(i));
}
}
......
......@@ -130,11 +130,11 @@ void CompactHistoryScroll::setCellsVectorAt(int position, const TextLine &cells)
_lines[position]->setCharacters(cells);
}
void CompactHistoryScroll::setLineAt(int position, bool previousWrapped)
void CompactHistoryScroll::setLineAt(int position, LineProperty lineProperty)
{
auto line = _lines.at(position).get();
line->setWrapped(previousWrapped);
line->setLineProperty(lineProperty);
}
bool CompactHistoryScroll::isWrappedLine(int lineNumber)
......@@ -172,7 +172,7 @@ int CompactHistoryScroll::reflowLines(int columns)
if (isWrappedLine(currentPos) && currentPos < getLines() - 1) {
int next_linelen = getLineLen(currentPos + 1);
auto *new_line = getCharacterBuffer(curr_linelen + next_linelen);
bool new_line_property = isWrappedLine(currentPos + 1);
LineProperty new_line_property = getLineProperty(currentPos + 1);
// Join the lines
getCells(currentPos, 0, curr_linelen, new_line);
......@@ -189,11 +189,11 @@ int CompactHistoryScroll::reflowLines(int columns)
if (curr_linelen > columns) {
bool removeLine = getLines() == getMaxLines();
auto *curr_line = getCharacterBuffer(curr_linelen);
bool curr_line_property = isWrappedLine(currentPos);
LineProperty curr_line_property = getLineProperty(currentPos);
getCells(currentPos, 0, curr_linelen, curr_line);
setCellsAt(currentPos, curr_line, columns);
setLineAt(currentPos, true);
setLineAt(currentPos, curr_line_property | LINE_WRAPPED);
if (currentPos < getMaxLines() - 1) {
int correctPosition = (getLines() == getMaxLines()) ? 0 : 1;
insertCells(currentPos + 1, curr_line + columns, curr_linelen - columns);
......
......@@ -44,7 +44,7 @@ public:
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;
void setLineAt(int position, LineProperty lineProperty) override;
int reflowLines(int columns) override;
......
......@@ -46,11 +46,11 @@ void CompactHistoryType::scroll(std::unique_ptr<HistoryScroll> &old) const
auto tmp_line = std::make_unique<Character[]>(size);
old->getCells(i, 0, size, tmp_line.get());
newScroll->addCells(tmp_line.get(), size);
newScroll->addLine(old->isWrappedLine(i));
newScroll->addLine(old->getLineProperty(i));
} else {
old->getCells(i, 0, size, line);
newScroll->addCells(line, size);
newScroll->addLine(old->isWrappedLine(i));
newScroll->addLine(old->getLineProperty(i));
}
}
old = std::move(newScroll);
......
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