Join line when sending to history

Before adding new lines to history it will check if it is a warpped
line and join it.
wilder
Carlos Alves 5 years ago committed by Tomaz Canabrava
parent 3b182fa18c
commit 6bcc306460
  1. 58
      src/Screen.cpp

@ -1494,26 +1494,46 @@ void Screen::addHistLine()
// add line to history buffer
// we have to take care about scrolling, too...
const int oldHistLines = _history->getLines();
if (hasScroll()) {
_history->addCellsVector(_screenLines[0]);
_history->addLine((_lineProperties[0] & LINE_WRAPPED) != 0);
int newHistLines = _history->getLines();
bool beginIsTL = (_selBegin == _selTopLeft);
const int newHistLines = _history->getLines();
if (hasScroll()) {
const bool beginIsTL = (_selBegin == _selTopLeft);
// Check if _history have 'new line' property and join lines before adding new ones
if (oldHistLines > 0 && _history->isWrappedLine(oldHistLines - 1)) {
int hist_linelen = _history->getLineLen(oldHistLines - 1);
auto *hist_line = getCharacterBuffer(hist_linelen);
_history->getCells(oldHistLines - 1, 0, hist_linelen, hist_line);
// If the history is full, increment the count
// of dropped _lines
if (newHistLines == oldHistLines) {
_droppedLines++;
}
ImageLine joinline;
for (int i = 0; i < hist_linelen; i++) {
joinline << hist_line[i];
}
joinline << _screenLines[0];
_history->setCellsVectorAt(oldHistLines - 1, joinline);
_history->setLineAt(oldHistLines - 1, (_lineProperties[0] & LINE_WRAPPED) != 0);
} else {
_history->addCellsVector(_screenLines[0]);
_history->addLine((_lineProperties[0] & LINE_WRAPPED) != 0);
newHistLines = _history->getLines();
beginIsTL = (_selBegin == _selTopLeft);
// If the history is full, increment the count
// of dropped _lines
if (newHistLines == oldHistLines) {
_droppedLines++;
// We removed a line, we need to verify if we need to remove a URL.
_escapeSequenceUrlExtractor->historyLinesRemoved(1);
}
// Adjust selection for the new point of reference
if (newHistLines > oldHistLines) {
if (_selBegin != -1) {
_selTopLeft += _columns;
_selBottomRight += _columns;
// Adjust selection for the new point of reference
if (newHistLines > oldHistLines) {
if (_selBegin != -1) {
_selTopLeft += _columns;
_selBottomRight += _columns;
}
}
}
@ -1544,12 +1564,6 @@ void Screen::addHistLine()
}
}
}
// We removed a line, we need to verify if we need to remove a URL.
const int newHistLines = _history->getLines();
if (oldHistLines == newHistLines) {
_escapeSequenceUrlExtractor->historyLinesRemoved(1);
}
}
int Screen::getHistLines() const

Loading…
Cancel
Save