Example #1
0
void
TermView::_PushLine(int cols, const VTermScreenCell* cells)
{
	ScrollBufferItem* item = (ScrollBufferItem*)malloc(sizeof(int)
		+ cols * sizeof(VTermScreenCell));
	item->cols = cols;
	memcpy(item->cells, cells, cols * sizeof(VTermScreenCell));

	fScrollBuffer.AddItem(item, 0);

	free(fScrollBuffer.RemoveItem(kScrollBackSize));

	int availableRows, availableCols;
	vterm_get_size(fTerm, &availableRows, &availableCols);

	VTermRect dirty;
	dirty.start_col = 0;
	dirty.end_col = availableCols;
	dirty.end_row = 0;
	dirty.start_row = -fScrollBuffer.CountItems();
	// FIXME we should rather use CopyRect if possible, and only invalidate the
	// newly exposed area here.
	Invalidate(_GlyphsToPixels(dirty));

	BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
	if (scrollBar != NULL) {
		float range = (fScrollBuffer.CountItems() + availableRows)
			* fFontHeight;
		scrollBar->SetRange(availableRows * fFontHeight - range, 0.0f);
		// TODO we need to adjust this in FrameResized, as availableRows can
		// change
		scrollBar->SetProportion(availableRows * fFontHeight / range);
		scrollBar->SetSteps(fFontHeight, fFontHeight * 3);
	}
}
Example #2
0
void
TermView::_MoveCursor(VTermPos pos, VTermPos oldPos, int visible)
{
	VTermRect r;
	r.start_row = pos.row;
	r.start_col = pos.col;
	r.end_col = pos.col + 1;
	r.end_row = pos.row + 1;
	Invalidate(_GlyphsToPixels(r));

	r.start_row = oldPos.row;
	r.start_col = oldPos.col;
	r.end_col = oldPos.col + 1;
	r.end_row = oldPos.row + 1;
	Invalidate(_GlyphsToPixels(r));
}
Example #3
0
void
TermView::_MoveCursor(VTermPos pos, VTermPos oldPos, int visible)
{
	VTermRect r;

	// We need to erase the cursor from its old position
	r.start_row = oldPos.row;
	r.start_col = oldPos.col;
	r.end_col = oldPos.col + 1;
	r.end_row = oldPos.row + 1;
	Invalidate(_GlyphsToPixels(r));

	// And we need to draw it at the new one
	r.start_row = pos.row;
	r.start_col = pos.col;
	r.end_col = pos.col + 1;
	r.end_row = pos.row + 1;
	Invalidate(_GlyphsToPixels(r));
}
Example #4
0
BRect
TermView::_GlyphsToPixels(const int width, const int height) const
{
	VTermRect rect;
	rect.start_row = 0;
	rect.start_col = 0;
	rect.end_row = height;
	rect.end_col = width;
	return _GlyphsToPixels(rect);
}
Example #5
0
void
TermView::_Damage(VTermRect rect)
{
	Invalidate(_GlyphsToPixels(rect));
}