Esempio n. 1
0
File: tty.c Progetto: jnbek/tmux
void
tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
{
    struct window_pane	*wp = ctx->wp;
    struct screen		*s = wp->screen;
    u_int			 cx;

    tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);

    /* Is the cursor in the very last position? */
    if (ctx->ocx > wp->sx - ctx->last_width) {
        if (wp->xoff != 0 || wp->sx != tty->sx) {
            /*
             * The pane doesn't fill the entire line, the linefeed
             * will already have happened, so just move the cursor.
             */
            tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
        } else if (tty->cx < tty->sx) {
            /*
             * The cursor isn't in the last position already, so
             * move as far left as possinble and redraw the last
             * cell to move into the last position.
             */
            cx = screen_size_x(s) - ctx->last_width;
            tty_cursor_pane(tty, ctx, cx, ctx->ocy);
            tty_cell(tty, &ctx->last_cell, &ctx->last_utf8);
        }
    } else
        tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);

    tty_cell(tty, ctx->cell, ctx->utf8);
}
Esempio n. 2
0
File: tty.c Progetto: UNGLinux/Obase
void
tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
{
	struct window_pane	*wp = ctx->wp;
	struct screen		*s = wp->screen;
	u_int			 cx;
	u_int			 width;
	const struct grid_cell	*gc = ctx->cell;
	const struct grid_utf8	*gu = ctx->utf8;

	if (gc->flags & GRID_FLAG_UTF8)
		width = gu->width;
	else
		width = 1;

	tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);

	/* Is the cursor in the very last position? */
	if (ctx->ocx > wp->sx - width) {
		if (ctx->xoff != 0 || wp->sx != tty->sx) {
			/*
			 * The pane doesn't fill the entire line, the linefeed
			 * will already have happened, so just move the cursor.
			 */
			if (ctx->ocy != wp->yoff + wp->screen->rlower)
				tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
			else
				tty_cursor_pane(tty, ctx, 0, ctx->ocy);
		} else if (tty->cx < tty->sx) {
			/*
			 * The cursor isn't in the last position already, so
			 * move as far left as possible and redraw the last
			 * cell to move into the last position.
			 */
			if (ctx->last_cell.flags & GRID_FLAG_UTF8)
				cx = screen_size_x(s) - ctx->last_utf8.width;
			else
				cx = screen_size_x(s) - 1;
			tty_cursor_pane(tty, ctx, cx, ctx->ocy);
			tty_cell(tty, &ctx->last_cell, &ctx->last_utf8);
		}
	} else
		tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);

	tty_cell(tty, ctx->cell, ctx->utf8);
}
Esempio n. 3
0
void
tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
{
	const struct grid_cell	*gc;
	const struct grid_utf8	*gu;
	u_int			 i, sx;

	sx = screen_size_x(s);
	if (sx > s->grid->size[s->grid->hsize + py])
		sx = s->grid->size[s->grid->hsize + py];
	if (sx > tty->sx)
		sx = tty->sx;

	tty_cursor(tty, 0, py, ox, oy);
	for (i = 0; i < sx; i++) {
		gc = grid_view_peek_cell(s->grid, i, py);

		gu = NULL;
		if (gc->flags & GRID_FLAG_UTF8)
			gu = grid_view_peek_utf8(s->grid, i, py);

		if (screen_check_selection(s, i, py)) {
			s->sel.cell.data = gc->data;
			tty_cell(tty, &s->sel.cell, gu);
		} else
			tty_cell(tty, gc, gu);
	}

	if (sx >= tty->sx)
		return;
	tty_reset(tty);

	tty_cursor(tty, sx, py, ox, oy);
	if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL))
		tty_putcode(tty, TTYC_EL);
	else {
		for (i = sx; i < screen_size_x(s); i++)
			tty_putc(tty, ' ');
	}
}
Esempio n. 4
0
void
tty_cmd_cell(struct tty *tty, struct window_pane *wp, va_list ap)
{
	struct screen		*s = wp->screen;
	struct grid_cell	*gc;
	struct grid_utf8	*gu;

	gc = va_arg(ap, struct grid_cell *);
	gu = va_arg(ap, struct grid_utf8 *);

	tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);

	tty_cell(tty, gc, gu);
}
Esempio n. 5
0
void
tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
{
	const struct grid_cell	*gc;
	struct grid_line	*gl;
	struct grid_cell	 tmpgc;
	const struct grid_utf8	*gu;
	u_int			 i, sx;

	tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s);

	sx = screen_size_x(s);
	if (sx > s->grid->linedata[s->grid->hsize + py].cellsize)
		sx = s->grid->linedata[s->grid->hsize + py].cellsize;
	if (sx > tty->sx)
		sx = tty->sx;

	/*
	 * Don't move the cursor to the start permission if it will wrap there
	 * itself.
	 */
	gl = NULL;
	if (py != 0)
		gl = &s->grid->linedata[s->grid->hsize + py - 1];
	if (oy + py == 0 || gl == NULL || !(gl->flags & GRID_LINE_WRAPPED) ||
	    tty->cx < tty->sx || ox != 0 ||
	    (oy + py != tty->cy + 1 && tty->cy != s->rlower + oy))
		tty_cursor(tty, ox, oy + py);

	for (i = 0; i < sx; i++) {
		gc = grid_view_peek_cell(s->grid, i, py);

		gu = NULL;
		if (gc->flags & GRID_FLAG_UTF8)
			gu = grid_view_peek_utf8(s->grid, i, py);

		if (screen_check_selection(s, i, py)) {
			memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc);
			tmpgc.data = gc->data;
			tmpgc.flags = gc->flags &
			    ~(GRID_FLAG_FG256|GRID_FLAG_BG256);
			tmpgc.flags |= s->sel.cell.flags &
			    (GRID_FLAG_FG256|GRID_FLAG_BG256);
			tty_cell(tty, &tmpgc, gu);
		} else
			tty_cell(tty, gc, gu);
	}

	if (sx >= tty->sx) {
		tty_update_mode(tty, tty->mode, s);
		return;
	}
	tty_reset(tty);

	tty_cursor(tty, ox + sx, oy + py);
	if (screen_size_x(s) >= tty->sx && tty_term_has(tty->term, TTYC_EL))
		tty_putcode(tty, TTYC_EL);
	else {
		for (i = sx; i < screen_size_x(s); i++)
			tty_putc(tty, ' ');
	}
	tty_update_mode(tty, tty->mode, s);
}