summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--screen-redraw.c13
-rw-r--r--server.c4
-rw-r--r--tmux.h3
-rw-r--r--tty.c66
4 files changed, 49 insertions, 37 deletions
diff --git a/screen-redraw.c b/screen-redraw.c
index d22591f0..0e612461 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -195,7 +195,7 @@ screen_redraw_screen(struct client *c, int status_only)
for (i = 0; i < tty->sx; i++) {
type = screen_redraw_check_cell(c, i, j);
if (type != CELL_INSIDE) {
- tty_cursor(tty, i, j, 0, 0);
+ tty_cursor(tty, i, j);
tty_putc(tty, border[type]);
}
}
@@ -239,7 +239,7 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp)
struct tty *tty = &c->tty;
struct session *s = c->session;
struct grid_cell gc;
- u_int idx, px, py, i, j;
+ u_int idx, px, py, i, j, xoff, yoff;
int colour;
char buf[16], *ptr;
size_t len;
@@ -251,10 +251,11 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp)
return;
colour = options_get_number(&s->options, "display-panes-colour");
- px = wp->sx / 2;
- py = wp->sy / 2;
+ px = wp->sx / 2; py = wp->sy / 2;
+ xoff = wp->xoff; yoff = wp->yoff;
+
if (wp->sx < len * 6 || wp->sy < 5) {
- tty_cursor(tty, px - len / 2, py, wp->xoff, wp->yoff);
+ tty_cursor(tty, xoff + px - len / 2, yoff + py);
memcpy(&gc, &grid_default_cell, sizeof gc);
colour_set_fg(&gc, colour);
tty_attributes(tty, &gc);
@@ -275,7 +276,7 @@ screen_redraw_draw_number(struct client *c, struct window_pane *wp)
for (j = 0; j < 5; j++) {
for (i = px; i < px + 5; i++) {
- tty_cursor(tty, i, py + j, wp->xoff, wp->yoff);
+ tty_cursor(tty, xoff + i, yoff + py + j);
if (clock_table[idx][j][i - px])
tty_putc(tty, ' ');
}
diff --git a/server.c b/server.c
index 6360be1d..2906fb87 100644
--- a/server.c
+++ b/server.c
@@ -1054,9 +1054,9 @@ server_handle_client(struct client *c)
status = options_get_number(oo, "status");
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status)
- tty_cursor(&c->tty, 0, 0, 0, 0);
+ tty_cursor(&c->tty, 0, 0);
else
- tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff);
+ tty_cursor(&c->tty, wp->xoff + s->cx, wp->yoff + s->cy);
mode = s->mode;
if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL &&
diff --git a/tmux.h b/tmux.h
index 0b1ba198..93e178e1 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1249,7 +1249,8 @@ void tty_attributes(struct tty *, const struct grid_cell *);
void tty_reset(struct tty *);
void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
void tty_region(struct tty *, u_int, u_int);
-void tty_cursor(struct tty *, u_int, u_int, u_int, u_int);
+void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
+void tty_cursor(struct tty *, u_int, u_int);
void tty_putcode(struct tty *, enum tty_code_code);
void tty_putcode1(struct tty *, enum tty_code_code, int);
void tty_putcode2(struct tty *, enum tty_code_code, int, int);
diff --git a/tty.c b/tty.c
index bddb83e3..f7ef8c0d 100644
--- a/tty.c
+++ b/tty.c
@@ -451,7 +451,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
if (sx > tty->sx)
sx = tty->sx;
- tty_cursor(tty, 0, py, ox, oy);
+ tty_cursor(tty, ox, oy + py);
for (i = 0; i < sx; i++) {
gc = grid_view_peek_cell(s->grid, i, py);
@@ -477,7 +477,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
}
tty_reset(tty);
- tty_cursor(tty, sx, py, ox, oy);
+ 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 {
@@ -532,7 +532,8 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
+
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);
@@ -559,7 +560,8 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
+
if (tty_term_has(tty->term, TTYC_DCH) ||
tty_term_has(tty->term, TTYC_DCH1))
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num);
@@ -580,8 +582,8 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num);
}
@@ -600,8 +602,8 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num);
}
@@ -614,7 +616,8 @@ tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, ctx->ocy);
+
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL);
@@ -633,7 +636,8 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
+
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL);
@@ -652,10 +656,10 @@ tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
if (wp->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_putcode(tty, TTYC_EL1);
} else {
- tty_cursor(tty, 0, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, ctx->ocy);
for (i = 0; i < ctx->ocx + 1; i++)
tty_putc(tty, ' ');
}
@@ -677,7 +681,7 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
- tty_cursor(tty, ctx->ocx, ctx->orupper, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
tty_putcode(tty, TTYC_RI);
}
@@ -699,7 +703,7 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_putc(tty, '\n');
}
@@ -715,13 +719,13 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
tty_putcode(tty, TTYC_EL);
if (ctx->ocy != screen_size_y(s) - 1) {
- tty_cursor(tty, 0, ctx->ocy + 1, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
for (i = ctx->ocy + 1; i < screen_size_y(s); i++) {
tty_putcode(tty, TTYC_EL);
if (i == screen_size_y(s) - 1)
@@ -734,7 +738,7 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
for (i = ctx->ocx; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
for (j = ctx->ocy; j < screen_size_y(s); j++) {
- tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, j);
for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
}
@@ -751,7 +755,7 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
- tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, 0);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
@@ -762,7 +766,7 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
}
} else {
for (j = 0; j < ctx->ocy; j++) {
- tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, j);
for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
}
@@ -781,7 +785,7 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_reset(tty);
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
- tty_cursor(tty, 0, 0, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, 0);
if (wp->xoff == 0 && screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL)) {
@@ -794,7 +798,7 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
}
} else {
for (j = 0; j < screen_size_y(s); j++) {
- tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, j);
for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' ');
}
@@ -813,7 +817,7 @@ tty_cmd_alignmenttest(struct tty *tty, const struct tty_ctx *ctx)
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
for (j = 0; j < screen_size_y(s); j++) {
- tty_cursor(tty, 0, j, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, 0, j);
for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, 'E');
}
@@ -822,9 +826,7 @@ tty_cmd_alignmenttest(struct tty *tty, const struct tty_ctx *ctx)
void
tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
{
- struct window_pane *wp = ctx->wp;
-
- tty_cursor(tty, ctx->ocx, ctx->ocy, wp->xoff, wp->yoff);
+ tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_cell(tty, ctx->cell, ctx->utf8);
}
@@ -922,14 +924,22 @@ tty_region(struct tty *tty, u_int rupper, u_int rlower)
}
void
-tty_cursor(struct tty *tty, u_int cx, u_int cy, u_int ox, u_int oy)
+tty_cursor_pane(struct tty *tty, const struct tty_ctx *ctx, u_int cx, u_int cy)
+{
+ struct window_pane *wp = ctx->wp;
+
+ tty_cursor(tty, wp->xoff + cx, wp->yoff + cy);
+}
+
+void
+tty_cursor(struct tty *tty, u_int cx, u_int cy)
{
- if (ox + cx == 0 && tty->cx != 0 && tty->cy == oy + cy) {
+ if (cx == 0 && tty->cx != 0 && tty->cy == cy) {
tty->cx = 0;
tty_putc(tty, '\r');
- } else if (tty->cx != ox + cx || tty->cy != oy + cy) {
- tty->cx = ox + cx;
- tty->cy = oy + cy;
+ } else if (tty->cx != cx || tty->cy != cy) {
+ tty->cx = cx;
+ tty->cy = cy;
tty_putcode2(tty, TTYC_CUP, tty->cy, tty->cx);
}
}