From 03d531ebc6058f0c3d4f5d2a5471255d23c0b93e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 11 Feb 2009 17:50:36 +0000 Subject: [PATCH] Move sx,sy into tty rather than client. --- cmd-list-clients.c | 4 ++-- cmd-new-session.c | 6 +++--- cmd-server-info.c | 6 +++--- resize.c | 10 +++++----- screen-redraw.c | 22 ++++++++++----------- server-msg.c | 18 ++++++++--------- server.c | 14 +++++++------- status.c | 48 +++++++++++++++++++++++----------------------- tmux.h | 8 ++++---- 9 files changed, 68 insertions(+), 68 deletions(-) diff --git a/cmd-list-clients.c b/cmd-list-clients.c index c920f4dc..67a0cc5b 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-clients.c,v 1.12 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-list-clients.c,v 1.13 2009-02-11 17:50:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -54,7 +54,7 @@ cmd_list_clients_exec(unused struct cmd *self, struct cmd_ctx *ctx) continue; ctx->print(ctx, "%s: %s [%ux%u %s]", c->tty.path, - c->session->name, c->sx, c->sy, c->tty.termname); + c->session->name, c->tty.sx, c->tty.sy, c->tty.termname); } return (0); diff --git a/cmd-new-session.c b/cmd-new-session.c index 76dd5130..537b3fe5 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.38 2009-01-23 16:59:14 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.39 2009-02-11 17:50:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -146,8 +146,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) sx = 80; sy = 25; if (!data->flag_detached) { - sx = c->sx; - sy = c->sy; + sx = c->tty.sx; + sy = c->tty.sy; } if (options_get_number(&global_options, "status")) { diff --git a/cmd-server-info.c b/cmd-server-info.c index 11b55468..e353f200 100644 --- a/cmd-server-info.c +++ b/cmd-server-info.c @@ -1,4 +1,4 @@ -/* $Id: cmd-server-info.c,v 1.9 2009-01-19 18:23:40 nicm Exp $ */ +/* $Id: cmd-server-info.c,v 1.10 2009-02-11 17:50:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -86,8 +86,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx) ctx->print(ctx, "%4d: %s (%d, %d): %s [%ux%u %s] " "[flags=0x%x/0x%x]", i, c->tty.path, c->fd, c->tty.fd, - c->session->name, c->sx, c->sy, c->tty.termname, c->flags, - c->tty.flags); + c->session->name, c->tty.sx, c->tty.sy, c->tty.termname, + c->flags, c->tty.flags); } ctx->print(ctx, ""); diff --git a/resize.c b/resize.c index 2c2ee5fc..6ed0eb71 100644 --- a/resize.c +++ b/resize.c @@ -1,4 +1,4 @@ -/* $Id: resize.c,v 1.18 2009-01-11 23:31:46 nicm Exp $ */ +/* $Id: resize.c,v 1.19 2009-02-11 17:50:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -62,10 +62,10 @@ recalculate_sizes(void) if (c == NULL) continue; if (c->session == s) { - if (c->sx < ssx) - ssx = c->sx; - if (c->sy < ssy) - ssy = c->sy; + if (c->tty.sx < ssx) + ssx = c->tty.sx; + if (c->tty.sy < ssy) + ssy = c->tty.sy; } } if (ssx == UINT_MAX || ssy == UINT_MAX) { diff --git a/screen-redraw.c b/screen-redraw.c index 917f7175..68b4223c 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1,4 +1,4 @@ -/* $Id: screen-redraw.c,v 1.22 2009-02-11 17:04:38 nicm Exp $ */ +/* $Id: screen-redraw.c,v 1.23 2009-02-11 17:50:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -45,8 +45,8 @@ screen_redraw_screen(struct client *c, struct screen *s) status = options_get_number(&c->session->options, "status"); /* Fill in empty space on the right. */ - if (w->sx < c->sx) - screen_redraw_blankx(c, w->sx, c->sx - w->sx); + if (w->sx < c->tty.sx) + screen_redraw_blankx(c, w->sx, c->tty.sx - w->sx); /* Draw the panes. */ TAILQ_FOREACH(wp, &w->panes, entry) { @@ -58,7 +58,7 @@ screen_redraw_screen(struct client *c, struct screen *s) cy = s->cy; if (wp->yoff + sy <= w->sy) { for (i = 0; i < sy; i++) { - if (wp->yoff + i != c->sy - 1) + if (wp->yoff + i != c->tty.sy - 1) screen_redraw_line(c, s, wp->yoff, i); } if (TAILQ_NEXT(wp, entry) != NULL) @@ -69,8 +69,8 @@ screen_redraw_screen(struct client *c, struct screen *s) } /* Fill in empty space below. */ - if (w->sy < c->sy - status) - screen_redraw_blanky(c, w->sy, c->sy - status - w->sy, '='); + if (w->sy < c->tty.sy - status) + screen_redraw_blanky(c, w->sy, c->tty.sy - status - w->sy, '='); /* Draw the status line. */ screen_redraw_status(c); @@ -80,7 +80,7 @@ screen_redraw_screen(struct client *c, struct screen *s) void screen_redraw_status(struct client *c) { - screen_redraw_line(c, &c->status, c->sy - 1, 0); + screen_redraw_line(c, &c->status, c->tty.sy - 1, 0); } /* Draw blank columns. */ @@ -90,7 +90,7 @@ screen_redraw_blankx(struct client *c, u_int ox, u_int nx) u_int i, j; tty_putcode(&c->tty, TTYC_SGR0); - for (j = 0; j < c->sy; j++) { + for (j = 0; j < c->tty.sy; j++) { tty_putcode2(&c->tty, TTYC_CUP, j, ox); for (i = 0; i < nx; i++) tty_putc(&c->tty, ' '); @@ -110,7 +110,7 @@ screen_redraw_blanky(struct client *c, u_int oy, u_int ny, char ch) tty_putcode(&c->tty, TTYC_SGR0); for (j = 0; j < ny; j++) { tty_putcode2(&c->tty, TTYC_CUP, oy + j, 0); - for (i = 0; i < c->sx; i++) { + for (i = 0; i < c->tty.sx; i++) { if (j == 0) tty_putc(&c->tty, ch); else @@ -132,8 +132,8 @@ screen_redraw_line(struct client *c, struct screen *s, u_int oy, u_int py) u_int i, sx; sx = screen_size_x(s); - if (sx > c->sx) - sx = c->sx; + if (sx > c->tty.sx) + sx = c->tty.sx; for (i = 0; i < sx; i++) { gc = grid_view_peek_cell(s->grid, i, py); tty_cursor(&c->tty, i, py, oy); diff --git a/server-msg.c b/server-msg.c index c972b8fe..27fe5a3b 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.62 2009-01-28 17:57:00 nicm Exp $ */ +/* $Id: server-msg.c,v 1.63 2009-02-11 17:50:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -192,8 +192,8 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c) return (0); } - c->sx = data.sx; - c->sy = data.sy; + c->tty.sx = data.sx; + c->tty.sy = data.sy; c->cwd = NULL; if (*data.cwd != '\0') @@ -225,12 +225,12 @@ server_msg_fn_resize(struct hdr *hdr, struct client *c) log_debug("resize msg from client: %u,%u", data.sx, data.sy); - c->sx = data.sx; - if (c->sx == 0) - c->sx = 80; - c->sy = data.sy; - if (c->sy == 0) - c->sy = 25; + c->tty.sx = data.sx; + if (c->tty.sx == 0) + c->tty.sx = 80; + c->tty.sy = data.sy; + if (c->tty.sy == 0) + c->tty.sy = 25; c->tty.cx = UINT_MAX; c->tty.cy = UINT_MAX; diff --git a/server.c b/server.c index d7ef46f7..1a5f6166 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.119 2009-02-10 00:18:06 nicm Exp $ */ +/* $Id: server.c,v 1.120 2009-02-11 17:50:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -85,9 +85,9 @@ server_create_client(int fd) c->title = NULL; c->session = NULL; - c->sx = 80; - c->sy = 25; - screen_init(&c->status, c->sx, 1, 0); + c->tty.sx = 80; + c->tty.sy = 25; + screen_init(&c->status, c->tty.sx, 1, 0); c->message_string = NULL; @@ -520,8 +520,8 @@ server_redraw_locked(struct client *c) u_int colour, xx, yy; int style; - xx = c->sx; - yy = c->sy - 1; + xx = c->tty.sx; + yy = c->tty.sy - 1; if (xx == 0 || yy == 0) return; colour = options_get_number( @@ -768,7 +768,7 @@ server_handle_client(struct client *c) /* Ensure cursor position and mode settings. */ status = options_get_number(&c->session->options, "status"); - if (wp->yoff + wp->screen->cy < c->sy - status) + if (wp->yoff + wp->screen->cy < c->tty.sy - status) tty_cursor(&c->tty, wp->screen->cx, wp->screen->cy, wp->yoff); mode = wp->screen->mode; diff --git a/status.c b/status.c index e8d68cd4..190b1c96 100644 --- a/status.c +++ b/status.c @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.72 2009-02-10 00:18:06 nicm Exp $ */ +/* $Id: status.c,v 1.73 2009-02-11 17:50:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -56,10 +56,10 @@ status_redraw(struct client *c) /* Create the target screen. */ memcpy(&old_status, &c->status, sizeof old_status); - screen_init(&c->status, c->sx, 1, 0); + screen_init(&c->status, c->tty.sx, 1, 0); /* No status line? */ - if (c->sy == 0 || !options_get_number(&s->options, "status")) + if (c->tty.sy == 0 || !options_get_number(&s->options, "status")) goto off; larrow = rarrow = 0; @@ -70,7 +70,7 @@ status_redraw(struct client *c) stdgc.fg = options_get_number(&s->options, "status-bg"); stdgc.attr |= options_get_number(&s->options, "status-attr"); - yy = c->sy - 1; + yy = c->tty.sy - 1; if (yy == 0) goto blank; @@ -98,9 +98,9 @@ status_redraw(struct client *c) xx += llen + 1; if (rlen != 0) xx += rlen + 1; - if (c->sx == 0 || c->sx <= xx) + if (c->tty.sx == 0 || c->tty.sx <= xx) goto blank; - xx = c->sx - xx; + xx = c->tty.sx - xx; /* * Right. We have xx characters to fill. Find out how much is to go in @@ -215,7 +215,7 @@ draw: /* Draw the last item. */ if (rlen != 0) { - screen_write_cursormove(&ctx, c->sx - rlen - 1, yy); + screen_write_cursormove(&ctx, c->tty.sx - rlen - 1, yy); screen_write_puts(&ctx, &stdgc, " %s", right); } @@ -235,9 +235,9 @@ draw: if (rarrow == -1) gc.attr ^= GRID_ATTR_REVERSE; if (rlen != 0) - screen_write_cursormove(&ctx, c->sx - rlen - 2, yy); + screen_write_cursormove(&ctx, c->tty.sx - rlen - 2, yy); else - screen_write_cursormove(&ctx, c->sx - 1, yy); + screen_write_cursormove(&ctx, c->tty.sx - 1, yy); screen_write_putc(&ctx, &gc, '>'); } @@ -247,7 +247,7 @@ blank: /* Just draw the whole line as blank. */ screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, yy); - for (offset = 0; offset < c->sx; offset++) + for (offset = 0; offset < c->tty.sx; offset++) screen_write_putc(&ctx, &stdgc, ' '); goto out; @@ -267,13 +267,13 @@ off: } screen_write_cursormove(&ctx, 0, 0); - if (sy < c->sy) { + if (sy < c->tty.sy) { /* If the screen is too small, use blank. */ - for (offset = 0; offset < c->sx; offset++) + for (offset = 0; offset < c->tty.sx; offset++) screen_write_putc(&ctx, &stdgc, ' '); } else { screen_write_copy(&ctx, - sc, 0, sc->grid->hsize + screen_size_y(sc) - 1, c->sx, 1); + sc, 0, sc->grid->hsize + screen_size_y(sc) - 1, c->tty.sx, 1); } out: @@ -498,14 +498,14 @@ status_message_redraw(struct client *c) size_t len; struct grid_cell gc; - if (c->sx == 0 || c->sy == 0) + if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); - screen_init(&c->status, c->sx, 1, 0); + screen_init(&c->status, c->tty.sx, 1, 0); len = strlen(c->message_string); - if (len > c->sx) - len = c->sx; + if (len > c->tty.sx) + len = c->tty.sx; memcpy(&gc, &grid_default_cell, sizeof gc); gc.bg = options_get_number(&s->options, "message-fg"); @@ -516,7 +516,7 @@ status_message_redraw(struct client *c) screen_write_cursormove(&ctx, 0, 0); screen_write_puts(&ctx, &gc, "%.*s", (int) len, c->message_string); - for (; len < c->sx; len++) + for (; len < c->tty.sx; len++) screen_write_putc(&ctx, &gc, ' '); screen_write_stop(&ctx); @@ -540,15 +540,15 @@ status_prompt_redraw(struct client *c) char ch; struct grid_cell gc; - if (c->sx == 0 || c->sy == 0) + if (c->tty.sx == 0 || c->tty.sy == 0) return (0); memcpy(&old_status, &c->status, sizeof old_status); - screen_init(&c->status, c->sx, 1, 0); + screen_init(&c->status, c->tty.sx, 1, 0); offset = 0; len = strlen(c->prompt_string); - if (len > c->sx) - len = c->sx; + if (len > c->tty.sx) + len = c->tty.sx; memcpy(&gc, &grid_default_cell, sizeof gc); gc.bg = options_get_number(&s->options, "message-fg"); @@ -560,7 +560,7 @@ status_prompt_redraw(struct client *c) screen_write_cursormove(&ctx, 0, 0); screen_write_puts(&ctx, &gc, "%.*s", (int) len, c->prompt_string); - left = c->sx - len; + left = c->tty.sx - len; if (left != 0) { if (c->prompt_index < left) size = strlen(c->prompt_buffer); @@ -581,7 +581,7 @@ status_prompt_redraw(struct client *c) "%.*s", (int) left, c->prompt_buffer + offset); } - for (i = len + size; i < c->sx; i++) + for (i = len + size; i < c->tty.sx; i++) screen_write_putc(&ctx, &gc, ' '); } diff --git a/tmux.h b/tmux.h index 6a5a259c..8dcee8a7 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.267 2009-02-11 17:04:39 nicm Exp $ */ +/* $Id: tmux.h,v 1.268 2009-02-11 17:50:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -712,6 +712,9 @@ SLIST_HEAD(tty_terms, tty_term); struct tty { char *path; + u_int sx; + u_int sy; + u_int cx; u_int cy; @@ -762,9 +765,6 @@ struct client { struct timeval status_timer; struct timeval repeat_timer; - u_int sx; - u_int sy; - struct screen status; #define CLIENT_TERMINAL 0x1