Exemple #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);
}
Exemple #2
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);
}
Exemple #3
0
/* Line feed. */
void
screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
{
	struct screen		*s = ctx->s;
	struct grid_line	*gl;
	struct tty_ctx	 	 ttyctx;
	u_int			 sx = screen_size_x(s), sy = screen_size_y(s);

	screen_write_initctx(ctx, &ttyctx);

	gl = &s->grid->linedata[s->grid->hsize + s->cy];
	if (wrapped)
		gl->flags |= GRID_LINE_WRAPPED;
	else
		gl->flags &= ~GRID_LINE_WRAPPED;

	if (s->cy == s->rlower) {
		screen_dirty_clear(s, 0, s->rupper, sx - 1, s->rupper);
		screen_write_flush(ctx);
		grid_view_scroll_region_up(s->grid, s->rupper, s->rlower);
	} else if (s->cy < sy - 1)
		s->cy++;

	ttyctx.num = wrapped;
	tty_write(tty_cmd_linefeed, &ttyctx);
}
Exemple #4
0
/* VT100 alignment test. */
void
screen_write_alignmenttest(struct screen_write_ctx *ctx)
{
	struct screen		*s = ctx->s;
	struct tty_ctx	 	 ttyctx;
	struct grid_cell       	 gc;
	u_int			 xx, yy;
	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);

	memcpy(&gc, &grid_default_cell, sizeof gc);
	utf8_set(&gc.data, 'E');

	for (yy = 0; yy < screen_size_y(s); yy++) {
		for (xx = 0; xx < screen_size_x(s); xx++)
			grid_view_set_cell(s->grid, xx, yy, &gc);
	}

	s->cx = 0;
	s->cy = 0;

	s->rupper = 0;
	s->rlower = screen_size_y(s) - 1;

	tty_write(tty_cmd_alignmenttest, &ttyctx);
}
Exemple #5
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_size_x(s);

	screen_write_initctx(ctx, &ttyctx);

	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);
	} else {
		screen_dirty_clear(s, 0, s->cy, s->cx, s->cy);
		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
	}

	tty_write(tty_cmd_clearstartofline, &ttyctx);
}
Exemple #6
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);
}
Exemple #7
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);
}
Exemple #8
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);
}