summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index ad04896afdf..75a3aa0e20e 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.13 2009/07/22 18:02:23 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.14 2009/07/22 20:53:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -38,10 +38,11 @@ void tty_attributes(struct tty *, const struct grid_cell *);
void tty_attributes_fg(struct tty *, const struct grid_cell *);
void tty_attributes_bg(struct tty *, const struct grid_cell *);
+void tty_redraw_region(struct tty *, struct tty_ctx *);
void tty_emulate_repeat(
struct tty *, enum tty_code_code, enum tty_code_code, u_int);
-void tty_cell(struct tty *,
- const struct grid_cell *, const struct grid_utf8 *);
+void tty_cell(struct tty *,
+ const struct grid_cell *, const struct grid_utf8 *);
void
tty_init(struct tty *tty, char *path, char *term)
@@ -449,10 +450,11 @@ tty_emulate_repeat(
* width of the terminal.
*/
void
-tty_redraw_region(struct tty *tty, struct window_pane *wp)
+tty_redraw_region(struct tty *tty, struct tty_ctx *ctx)
{
- struct screen *s = wp->screen;
- u_int i;
+ struct window_pane *wp = ctx->wp;
+ struct screen *s = wp->screen;
+ u_int i;
/*
* If region is >= 50% of the screen, just schedule a window redraw. In
@@ -460,16 +462,16 @@ tty_redraw_region(struct tty *tty, struct window_pane *wp)
* without this, the entire pane ends up being redrawn many times which
* can be much more data.
*/
- if (s->old_rupper - s->old_rlower >= screen_size_y(s) / 2) {
+ if (ctx->orupper - ctx->orlower >= screen_size_y(s) / 2) {
wp->flags |= PANE_REDRAW;
return;
}
- if (s->old_cy < s->old_rupper || s->old_cy > s->old_rlower) {
- for (i = s->old_cy; i < screen_size_y(s); i++)
+ if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) {
+ for (i = ctx->ocy; i < screen_size_y(s); i++)
tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
} else {
- for (i = s->old_rupper; i <= s->old_rlower; i++)
+ for (i = ctx->orupper; i <= ctx->orlower; i++)
tty_draw_line(tty, s, i, wp->xoff, wp->yoff);
}
}
@@ -522,13 +524,13 @@ tty_cmd_insertcharacter(struct tty *tty, struct tty_ctx *ctx)
struct screen *s = wp->screen;
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
- tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff);
+ tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
return;
}
tty_reset(tty);
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
if (tty_term_has(tty->term, TTYC_ICH) ||
tty_term_has(tty->term, TTYC_ICH1))
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num);
@@ -547,13 +549,13 @@ tty_cmd_deletecharacter(struct tty *tty, struct tty_ctx *ctx)
struct screen *s = wp->screen;
if (wp->xoff != 0 || screen_size_x(s) < tty->sx) {
- tty_draw_line(tty, wp->screen, s->old_cy, wp->xoff, wp->yoff);
+ tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff);
return;
}
tty_reset(tty);
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num);
}
@@ -565,15 +567,15 @@ tty_cmd_insertline(struct tty *tty, struct tty_ctx *ctx)
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
- tty_redraw_region(tty, wp);
+ tty_redraw_region(tty, ctx);
return;
}
tty_reset(tty);
- tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
+ tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num);
}
@@ -585,15 +587,15 @@ tty_cmd_deleteline(struct tty *tty, struct tty_ctx *ctx)
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
- tty_redraw_region(tty, wp);
+ tty_redraw_region(tty, ctx);
return;
}
tty_reset(tty);
- tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
+ tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num);
}
@@ -606,7 +608,7 @@ tty_cmd_clearline(struct tty *tty, struct tty_ctx *ctx)
tty_reset(tty);
- tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL);
@@ -625,12 +627,12 @@ tty_cmd_clearendofline(struct tty *tty, struct tty_ctx *ctx)
tty_reset(tty);
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL);
else {
- for (i = s->old_cx; i < screen_size_x(s); i++)
+ for (i = ctx->ocx; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
}
}
@@ -639,17 +641,16 @@ void
tty_cmd_clearstartofline(struct tty *tty, struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
- struct screen *s = wp->screen;
u_int i;
tty_reset(tty);
if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_putcode(tty, TTYC_EL1);
} else {
- tty_cursor(tty, 0, s->old_cy, wp->xoff, wp->yoff);
- for (i = 0; i < s->old_cx + 1; i++)
+ tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff);
+ for (i = 0; i < ctx->ocx + 1; i++)
tty_putc(tty, ' ');
}
}
@@ -662,16 +663,16 @@ tty_cmd_reverseindex(struct tty *tty, struct tty_ctx *ctx)
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
- tty_redraw_region(tty, wp);
+ tty_redraw_region(tty, ctx);
return;
}
tty_reset(tty);
- tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
+ tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
- if (s->old_cy == s->old_rupper) {
- tty_cursor(tty, s->old_cx, s->old_rupper, wp->xoff, wp->yoff);
+ if (ctx->ocy == ctx->orupper) {
+ tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff);
tty_putcode(tty, TTYC_RI);
}
}
@@ -684,16 +685,16 @@ tty_cmd_linefeed(struct tty *tty, struct tty_ctx *ctx)
if (wp->xoff != 0 || screen_size_x(s) < tty->sx ||
!tty_term_has(tty->term, TTYC_CSR)) {
- tty_redraw_region(tty, wp);
+ tty_redraw_region(tty, ctx);
return;
}
tty_reset(tty);
- tty_region(tty, s->old_rupper, s->old_rlower, wp->yoff);
+ tty_region(tty, ctx->orupper, ctx->orlower, wp->yoff);
- if (s->old_cy == s->old_rlower) {
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ if (ctx->ocy == ctx->orlower) {
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_putc(tty, '\n');
}
}
@@ -708,13 +709,13 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx)
tty_reset(tty);
tty_region(tty, 0, screen_size_y(s) - 1, wp->yoff);
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL);
- if (s->old_cy != screen_size_y(s) - 1) {
- tty_cursor(tty, 0, s->old_cy + 1, wp->xoff, wp->yoff);
- for (i = s->old_cy + 1; i < screen_size_y(s); i++) {
+ if (ctx->ocy != screen_size_y(s) - 1) {
+ tty_cursor(tty, 0, ctx->ocy + 1, wp->xoff, wp->yoff);
+ for (i = ctx->ocy + 1; i < screen_size_y(s); i++) {
tty_putcode(tty, TTYC_EL);
if (i == screen_size_y(s) - 1)
continue;
@@ -723,9 +724,9 @@ tty_cmd_clearendofscreen(struct tty *tty, struct tty_ctx *ctx)
}
}
} else {
- for (i = s->old_cx; i < screen_size_x(s); i++)
+ for (i = ctx->ocx; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
- for (j = s->old_cy; j < screen_size_y(s); j++) {
+ for (j = ctx->ocy; j < screen_size_y(s); j++) {
tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
@@ -746,19 +747,19 @@ tty_cmd_clearstartofscreen(struct tty *tty, struct tty_ctx *ctx)
tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
- for (i = 0; i < s->old_cy; i++) {
+ for (i = 0; i < ctx->ocy; i++) {
tty_putcode(tty, TTYC_EL);
tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1);
tty->cy++;
}
} else {
- for (j = 0; j < s->old_cy; j++) {
+ for (j = 0; j < ctx->ocy; j++) {
tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
}
}
- for (i = 0; i <= s->old_cx; i++)
+ for (i = 0; i <= ctx->ocx; i++)
tty_putc(tty, ' ');
}
@@ -813,9 +814,8 @@ void
tty_cmd_cell(struct tty *tty, struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
- struct screen *s = wp->screen;
- tty_cursor(tty, s->old_cx, s->old_cy, wp->xoff, wp->yoff);
+ tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_cell(tty, ctx->cell, ctx->utf8);
}