version 1.76, 2009/12/02 22:13:15 |
version 1.77, 2009/12/03 22:50:10 |
|
|
void tty_emulate_repeat( |
void tty_emulate_repeat( |
struct tty *, enum tty_code_code, enum tty_code_code, u_int); |
struct tty *, enum tty_code_code, enum tty_code_code, u_int); |
void tty_cell(struct tty *, |
void tty_cell(struct tty *, |
const struct grid_cell *, const struct grid_utf8 *); |
const struct grid_cell *, const struct grid_utf8 *); |
|
|
void |
void |
tty_init(struct tty *tty, int fd, char *term) |
tty_init(struct tty *tty, int fd, char *term) |
|
|
if (screen_check_selection(s, i, py)) { |
if (screen_check_selection(s, i, py)) { |
memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc); |
memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc); |
tmpgc.data = gc->data; |
tmpgc.data = gc->data; |
tmpgc.flags = gc->flags & |
tmpgc.flags = gc->flags & |
~(GRID_FLAG_FG256|GRID_FLAG_BG256); |
~(GRID_FLAG_FG256|GRID_FLAG_BG256); |
tmpgc.flags |= s->sel.cell.flags & |
tmpgc.flags |= s->sel.cell.flags & |
(GRID_FLAG_FG256|GRID_FLAG_BG256); |
(GRID_FLAG_FG256|GRID_FLAG_BG256); |
|
|
void |
void |
tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
u_int i; |
u_int i; |
|
|
|
|
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
|
|
if (tty_term_has(tty->term, TTYC_ICH) || |
if (tty_term_has(tty->term, TTYC_ICH) || |
tty_term_has(tty->term, TTYC_ICH1)) |
tty_term_has(tty->term, TTYC_ICH1)) |
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); |
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); |
else if (tty_term_has(tty->term, TTYC_SMIR) && |
else if (tty_term_has(tty->term, TTYC_SMIR) && |
tty_term_has(tty->term, TTYC_RMIR)) { |
tty_term_has(tty->term, TTYC_RMIR)) { |
tty_putcode(tty, TTYC_SMIR); |
tty_putcode(tty, TTYC_SMIR); |
for (i = 0; i < ctx->num; i++) |
for (i = 0; i < ctx->num; i++) |
|
|
void |
void |
tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
|
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
|
|
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
|
|
if (tty_term_has(tty->term, TTYC_DCH) || |
if (tty_term_has(tty->term, TTYC_DCH) || |
tty_term_has(tty->term, TTYC_DCH1)) |
tty_term_has(tty->term, TTYC_DCH1)) |
|
|
void |
void |
tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
|
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
!tty_term_has(tty->term, TTYC_CSR) || |
!tty_term_has(tty->term, TTYC_CSR) || |
!tty_term_has(tty->term, TTYC_IL1)) { |
!tty_term_has(tty->term, TTYC_IL1)) { |
tty_redraw_region(tty, ctx); |
tty_redraw_region(tty, ctx); |
return; |
return; |
|
|
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
|
|
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); |
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); |
} |
} |
|
|
void |
void |
tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
|
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
!tty_term_has(tty->term, TTYC_CSR) || |
!tty_term_has(tty->term, TTYC_CSR) || |
!tty_term_has(tty->term, TTYC_DL1)) { |
!tty_term_has(tty->term, TTYC_DL1)) { |
tty_redraw_region(tty, ctx); |
tty_redraw_region(tty, ctx); |
|
|
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
|
|
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); |
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); |
} |
} |
|
|
void |
void |
tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
u_int i; |
u_int i; |
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_cursor_pane(tty, ctx, 0, ctx->ocy); |
tty_cursor_pane(tty, ctx, 0, ctx->ocy); |
|
|
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && |
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx && |
tty_term_has(tty->term, TTYC_EL)) { |
tty_term_has(tty->term, TTYC_EL)) { |
|
|
void |
void |
tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
u_int i; |
u_int i; |
|
|
|
|
void |
void |
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
u_int i; |
u_int i; |
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
void |
void |
tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
|
|
if (ctx->ocy != ctx->orupper) |
if (ctx->ocy != ctx->orupper) |
return; |
return; |
|
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
!tty_term_has(tty->term, TTYC_CSR) || |
!tty_term_has(tty->term, TTYC_CSR) || |
!tty_term_has(tty->term, TTYC_RI)) { |
!tty_term_has(tty->term, TTYC_RI)) { |
tty_redraw_region(tty, ctx); |
tty_redraw_region(tty, ctx); |
|
|
} |
} |
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); |
|
|
tty_putcode(tty, TTYC_RI); |
tty_putcode(tty, TTYC_RI); |
} |
} |
|
|
void |
void |
tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
|
|
if (ctx->ocy != ctx->orlower) |
if (ctx->ocy != ctx->orlower) |
return; |
return; |
|
|
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
if (wp->xoff != 0 || screen_size_x(s) < tty->sx || |
!tty_term_has(tty->term, TTYC_CSR)) { |
!tty_term_has(tty->term, TTYC_CSR)) { |
tty_redraw_region(tty, ctx); |
tty_redraw_region(tty, ctx); |
return; |
return; |
|
|
return; |
return; |
|
|
tty_reset(tty); |
tty_reset(tty); |
|
|
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); |
|
|
tty_putc(tty, '\n'); |
tty_putc(tty, '\n'); |
} |
} |
|
|
void |
void |
tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
u_int i, j; |
u_int i, j; |
|
|
|
|
void |
void |
tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
u_int i, j; |
u_int i, j; |
|
|
|
|
void |
void |
tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx) |
tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
u_int i, j; |
u_int i, j; |
|
|
|
|
* Cannot rely on not being a partial character, so just redraw the |
* Cannot rely on not being a partial character, so just redraw the |
* whole line. |
* whole line. |
*/ |
*/ |
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); |
tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); |
} |
} |
|
|
void |
void |
|
|
tty_region_pane( |
tty_region_pane( |
struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower) |
struct tty *tty, const struct tty_ctx *ctx, u_int rupper, u_int rlower) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
|
|
tty_region(tty, wp->yoff + rupper, wp->yoff + rlower); |
tty_region(tty, wp->yoff + rupper, wp->yoff + rlower); |
} |
} |
|
|
void |
void |
tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy) |
tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy) |
{ |
{ |
struct window_pane *wp = ctx->wp; |
struct window_pane *wp = ctx->wp; |
|
|
tty_cursor(tty, wp->xoff + cx, wp->yoff + cy); |
tty_cursor(tty, wp->xoff + cx, wp->yoff + cy); |
} |
} |
|
|
struct tty_term *term = tty->term; |
struct tty_term *term = tty->term; |
u_int thisx, thisy; |
u_int thisx, thisy; |
int change; |
int change; |
|
|
if (cx > tty->sx - 1) |
if (cx > tty->sx - 1) |
cx = tty->sx - 1; |
cx = tty->sx - 1; |
|
|
|
|
*/ |
*/ |
|
|
/* One above. */ |
/* One above. */ |
if (thisy != tty->rupper && |
if (thisy != tty->rupper && |
cy == thisy - 1 && tty_term_has(term, TTYC_CUU1)) { |
cy == thisy - 1 && tty_term_has(term, TTYC_CUU1)) { |
tty_putcode(tty, TTYC_CUU1); |
tty_putcode(tty, TTYC_CUU1); |
goto out; |
goto out; |
|
|
change = thisy - cy; /* +ve up, -ve down */ |
change = thisy - cy; /* +ve up, -ve down */ |
|
|
/* |
/* |
* Try to use VPA if change is larger than absolute or if this change |
* Try to use VPA if change is larger than absolute or if this |
* would cross the scroll region, otherwise use CUU/CUD. |
* change would cross the scroll region, otherwise use CUU/CUD. |
*/ |
*/ |
if (abs(change) > cy || |
if (abs(change) > cy || |
(change < 0 && cy - change > tty->rlower) || |
(change < 0 && cy - change > tty->rlower) || |
|
|
} |
} |
if (bg_default && |
if (bg_default && |
bg != tc->bg && !(tc->flags & GRID_FLAG_BG256)) { |
bg != tc->bg && !(tc->flags & GRID_FLAG_BG256)) { |
if (have_ax) |
if (have_ax) |
tty_puts(tty, "\033[49m"); |
tty_puts(tty, "\033[49m"); |
else if (tc->bg != 0) |
else if (tc->bg != 0) |
tty_putcode1(tty, TTYC_SETAB, 0); |
tty_putcode1(tty, TTYC_SETAB, 0); |
|
|
/* Otherwise set the foreground colour. */ |
/* Otherwise set the foreground colour. */ |
tty_putcode1(tty, TTYC_SETAF, fg); |
tty_putcode1(tty, TTYC_SETAF, fg); |
|
|
save_fg: |
save_fg: |
/* Save the new values in the terminal current cell. */ |
/* Save the new values in the terminal current cell. */ |
tc->fg = fg; |
tc->fg = fg; |
tc->flags &= ~GRID_FLAG_FG256; |
tc->flags &= ~GRID_FLAG_FG256; |