aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-10-15 01:30:00 +0000
committerTiago Cunha <tcunha@gmx.com>2009-10-15 01:30:00 +0000
commit8bdcc10c8f08dd14797c0e49c18809aff60a2390 (patch)
tree4d1ab528e4bb68a2c3dca9d615dbc604120f7711
parent6369fca253fe4e289cbf0a1b8e1c5b52d7875e80 (diff)
downloadrtmux-8bdcc10c8f08dd14797c0e49c18809aff60a2390.tar.gz
rtmux-8bdcc10c8f08dd14797c0e49c18809aff60a2390.tar.bz2
rtmux-8bdcc10c8f08dd14797c0e49c18809aff60a2390.zip
Sync OpenBSD patchset 393:
Similarly add a tty_cursor_pane function to tidy up most of the calls.
-rw-r--r--screen-redraw.c15
-rw-r--r--server.c6
-rw-r--r--tmux.h5
-rw-r--r--tty.c68
4 files changed, 53 insertions, 41 deletions
diff --git a/screen-redraw.c b/screen-redraw.c
index 466c3569..6034ce3d 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -1,4 +1,4 @@
-/* $Id: screen-redraw.c,v 1.47 2009-09-11 14:13:52 tcunha Exp $ */
+/* $Id: screen-redraw.c,v 1.48 2009-10-15 01:30:00 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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 03c79d78..fa587e4c 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.208 2009-10-15 01:28:14 tcunha Exp $ */
+/* $Id: server.c,v 1.209 2009-10-15 01:30:00 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1057,9 +1057,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 73423c23..19a5d61e 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.471 2009-10-15 01:28:14 tcunha Exp $ */
+/* $Id: tmux.h,v 1.472 2009-10-15 01:30:00 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1247,7 +1247,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 dd1c0ea5..2b3ad140 100644
--- a/tty.c
+++ b/tty.c
@@ -1,4 +1,4 @@
-/* $Id: tty.c,v 1.144 2009-10-15 01:28:14 tcunha Exp $ */
+/* $Id: tty.c,v 1.145 2009-10-15 01:30:00 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -456,7 +456,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);
@@ -482,7 +482,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 {
@@ -537,7 +537,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);
@@ -564,7 +565,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);
@@ -585,8 +587,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);
}
@@ -605,8 +607,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);
}
@@ -619,7 +621,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);
@@ -638,7 +641,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);
@@ -657,10 +661,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, ' ');
}
@@ -682,7 +686,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);
}
@@ -704,7 +708,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');
}
@@ -720,13 +724,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)
@@ -739,7 +743,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, ' ');
}
@@ -756,7 +760,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)) {
@@ -767,7 +771,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, ' ');
}
@@ -786,7 +790,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)) {
@@ -799,7 +803,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, ' ');
}
@@ -818,7 +822,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');
}
@@ -827,9 +831,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);
}
@@ -927,14 +929,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);
}
}