SerialConnect: implement PopLine to get items from scrollback

Allows to make the scrollback visible again when resizing, instead of
adding blank lines at the bottom.

Change-Id: I7a14188cdcb14bcd197325b935d8cfe2435ae80f
Reviewed-on: https://review.haiku-os.org/c/1464
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Adrien Destugues
2019-05-19 14:00:48 +00:00
committed by waddlesplash
parent 1eb386084c
commit d4b3a3277d
+15 -2
View File
@@ -449,6 +449,7 @@ TermView::_PushLine(int cols, const VTermScreenCell* cells)
fScrollBuffer.AddItem(item, 0);
// Remove extra items if the scrollback gets too long
free(fScrollBuffer.RemoveItem(kScrollBackSize));
_UpdateScrollbar();
@@ -486,8 +487,20 @@ TermView::_UpdateScrollbar()
int
TermView::_PopLine(int cols, VTermScreenCell* cells)
{
/* TODO can be used when switching to alt screen and when resizing */
return 0;
ScrollBufferItem* item = (ScrollBufferItem*)fScrollBuffer.RemoveItem(0l);
if (item == NULL)
return 0;
_UpdateScrollbar();
if (item->cols >= cols) {
memcpy(cells, item->cells, cols * sizeof(VTermScreenCell));
} else {
memcpy(cells, item->cells, item->cols * sizeof(VTermScreenCell));
for (int i = item->cols; i < cols; i++)
cells[i] = cells[i - 1];
}
free(item);
return 1;
}