Exemplo n.º 1
0
/* Clear to end of screen from cursor. */
void
screen_write_clearendofscreen(struct screen_write_ctx *ctx, u_int bg)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx = screen_size_x(s), sy = screen_size_y(s);

	screen_write_initctx(ctx, &ttyctx);
	ttyctx.bg = bg;

	/* Scroll into history if it is enabled and clearing entire screen. */
	if (s->cx == 0 && s->cy == 0 && s->grid->flags & GRID_HISTORY) {
		screen_dirty_clear(s, 0, 0, sx - 1, sy  - 1);
		grid_view_clear_history(s->grid, bg);
	} else {
		if (s->cx <= sx - 1) {
			screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);
			grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1,
			    bg);
		}
		screen_dirty_clear(s, 0, s->cy + 1, sx - 1, sy - 1);
		grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1),
		    bg);
	}

	tty_write(tty_cmd_clearendofscreen, &ttyctx);
}
Exemplo n.º 2
0
/* Clear into history. */
void
grid_view_clear_history(struct grid *gd, u_int bg)
{
	struct grid_line	*gl;
	u_int			 yy, last;

	/* Find the last used line. */
	last = 0;
	for (yy = 0; yy < gd->sy; yy++) {
		gl = &gd->linedata[grid_view_y(gd, yy)];
		if (gl->cellused != 0)
			last = yy + 1;
	}
	if (last == 0) {
		grid_view_clear(gd, 0, 0, gd->sx, gd->sy, bg);
		return;
	}

	/* Scroll the lines into the history. */
	for (yy = 0; yy < last; yy++) {
		grid_collect_history(gd, bg);
		grid_scroll_history(gd, bg);
	}
	if (last < gd->sy)
		grid_view_clear(gd, 0, 0, gd->sx, gd->sy - last, bg);
	gd->hscrolled = 0;
}
Exemplo n.º 3
0
/* Clear nx characters. */
void
screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;

	if (nx == 0)
		nx = 1;

	if (nx > screen_size_x(s) - s->cx)
		nx = screen_size_x(s) - s->cx;
	if (nx == 0)
		return;

	screen_write_initctx(ctx, &ttyctx);

	if (s->cx <= screen_size_x(s) - 1) {
		screen_dirty_clear(s, s->cx, s->cy, s->cx + nx - 1, s->cy);
		grid_view_clear(s->grid, s->cx, s->cy, nx, 1, 8);
	} else
		return;

	ttyctx.num = nx;
	tty_write(tty_cmd_clearcharacter, &ttyctx);
}
Exemplo n.º 4
0
/* Clear to start of line from cursor. */
void
screen_write_clearstartofline(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx;

	screen_write_initctx(ctx, &ttyctx, 0);

	sx = screen_size_x(s);

	if (s->cx > sx - 1)
		grid_view_clear(s->grid, 0, s->cy, sx, 1);
	else
		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);

	tty_write(tty_cmd_clearstartofline, &ttyctx);
}
Exemplo n.º 5
0
/* Clear to start of line from cursor. */
void
screen_write_clearstartofline(struct screen_write_ctx *ctx, u_int bg)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx = screen_size_x(s);

	screen_write_initctx(ctx, &ttyctx);
	ttyctx.bg = bg;

	if (s->cx > sx - 1) {
		screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy);
		grid_view_clear(s->grid, 0, s->cy, sx, 1, bg);
	} else {
		screen_dirty_clear(s, 0, s->cy, s->cx, s->cy);
		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg);
	}

	tty_write(tty_cmd_clearstartofline, &ttyctx);
}
Exemplo n.º 6
0
/* Clear line at cursor. */
void
screen_write_clearline(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;

	screen_write_initctx(ctx, &ttyctx, 0);

	grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);

	tty_write(tty_cmd_clearline, &ttyctx);
}
Exemplo n.º 7
0
/* Clear to start of screen. */
void
screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx = screen_size_x(s);

	screen_write_initctx(ctx, &ttyctx);

	if (s->cy > 0) {
		screen_dirty_clear(s, 0, 0, sx - 1, s->cy);
		grid_view_clear(s->grid, 0, 0, sx, s->cy, 8);
	}
	if (s->cx > sx - 1) {
		screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy);
		grid_view_clear(s->grid, 0, s->cy, sx, 1, 8);
	} else {
		screen_dirty_clear(s, 0, s->cy, s->cx, s->cy);
		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, 8);
	}

	tty_write(tty_cmd_clearstartofscreen, &ttyctx);
}
Exemplo n.º 8
0
/* Clear to end of screen from cursor. */
void
screen_write_clearendofscreen(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx, sy;

	screen_write_initctx(ctx, &ttyctx, 0);

	sx = screen_size_x(s);
	sy = screen_size_y(s);

	/* Scroll into history if it is enabled and clearing entire screen. */
	if (s->cy == 0 && s->grid->flags & GRID_HISTORY)
		grid_view_clear_history(s->grid);
	else {
		if (s->cx <= sx - 1)
			grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
		grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
	}

	tty_write(tty_cmd_clearendofscreen, &ttyctx);
}
Exemplo n.º 9
0
/* Clear to end of line from cursor. */
void
screen_write_clearendofline(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx;

	screen_write_initctx(ctx, &ttyctx);

	sx = screen_size_x(s);

	if (s->cx <= sx - 1)
		grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);

	tty_write(tty_cmd_clearendofline, &ttyctx);
}
Exemplo n.º 10
0
/* Clear entire screen. */
void
screen_write_clearscreen(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;

	screen_write_initctx(ctx, &ttyctx, 0);

	/* Scroll into history if it is enabled. */
	if (s->grid->flags & GRID_HISTORY)
		grid_view_clear_history(s->grid);
	else {
		grid_view_clear(
		    s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
	}

	tty_write(tty_cmd_clearscreen, &ttyctx);
}
Exemplo n.º 11
0
/* Clear entire screen. */
void
screen_write_clearscreen(struct screen_write_ctx *ctx)
{
	struct screen	*s = ctx->s;
	struct tty_ctx	 ttyctx;
	u_int		 sx = screen_size_x(s), sy = screen_size_y(s);

	screen_write_initctx(ctx, &ttyctx);

	screen_dirty_clear(s, 0, 0, sx - 1, sy  - 1);

	/* Scroll into history if it is enabled. */
	if (s->grid->flags & GRID_HISTORY)
		grid_view_clear_history(s->grid);
	else
		grid_view_clear(s->grid, 0, 0, sx, sy);

	tty_write(tty_cmd_clearscreen, &ttyctx);
}
Exemplo n.º 12
0
/* Clear to end of line from cursor. */
void
screen_write_clearendofline(struct screen_write_ctx *ctx)
{
	struct screen		*s = ctx->s;
	struct grid_line	*gl;
	struct tty_ctx		 ttyctx;
	u_int			 sx = screen_size_x(s);

	screen_write_initctx(ctx, &ttyctx);

	gl = &s->grid->linedata[s->grid->hsize + s->cy];
	if (s->cx <= sx - 1 && s->cx < gl->cellsize) {
		screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);
		grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
	} else
		return;

	tty_write(tty_cmd_clearendofline, &ttyctx);
}
Exemplo n.º 13
0
/* Clear to end of line from cursor. */
void
screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
{
	struct screen		*s = ctx->s;
	struct grid_line	*gl;
	struct tty_ctx		 ttyctx;
	u_int			 sx = screen_size_x(s);

	screen_write_initctx(ctx, &ttyctx);
	ttyctx.bg = bg;

	gl = &s->grid->linedata[s->grid->hsize + s->cy];
	if (s->cx > sx - 1 || (s->cx >= gl->cellsize && bg == 8))
		return;

	screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);
	grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1, bg);

	tty_write(tty_cmd_clearendofline, &ttyctx);
}