=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-redraw.c,v retrieving revision 1.46 retrieving revision 1.47 diff -c -r1.46 -r1.47 *** src/usr.bin/tmux/screen-redraw.c 2017/05/01 12:20:55 1.46 --- src/usr.bin/tmux/screen-redraw.c 2017/10/16 19:30:53 1.47 *************** *** 1,4 **** ! /* $OpenBSD: screen-redraw.c,v 1.46 2017/05/01 12:20:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen-redraw.c,v 1.47 2017/10/16 19:30:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 33,43 **** struct window_pane *); static void screen_redraw_draw_pane_status(struct client *, int); ! static void screen_redraw_draw_borders(struct client *, int, int, u_int); ! static void screen_redraw_draw_panes(struct client *, u_int); ! static void screen_redraw_draw_status(struct client *, u_int); static void screen_redraw_draw_number(struct client *, struct window_pane *, ! u_int); #define CELL_INSIDE 0 #define CELL_LEFTRIGHT 1 --- 33,43 ---- struct window_pane *); static void screen_redraw_draw_pane_status(struct client *, int); ! static void screen_redraw_draw_borders(struct client *, int, u_int, u_int); ! static void screen_redraw_draw_panes(struct client *, u_int, u_int); ! static void screen_redraw_draw_status(struct client *, u_int, u_int); static void screen_redraw_draw_number(struct client *, struct window_pane *, ! u_int, u_int); #define CELL_INSIDE 0 #define CELL_LEFTRIGHT 1 *************** *** 377,412 **** struct tty *tty = &c->tty; struct window *w = c->session->curw->window; struct options *wo = w->options; ! u_int top; ! int status, pane_status, spos; - /* Suspended clients should not be updated. */ if (c->flags & CLIENT_SUSPENDED) return; ! /* Get status line, er, status. */ ! spos = options_get_number(oo, "status-position"); ! if (c->message_string != NULL || c->prompt_string != NULL) ! status = 1; else ! status = options_get_number(oo, "status"); ! top = 0; ! if (status && spos == 0) top = 1; ! if (!status) draw_status = 0; - /* Draw the elements. */ if (draw_borders) { pane_status = options_get_number(wo, "pane-border-status"); ! screen_redraw_draw_borders(c, status, pane_status, top); if (pane_status != CELL_STATUS_OFF) screen_redraw_draw_pane_status(c, pane_status); } if (draw_panes) ! screen_redraw_draw_panes(c, top); if (draw_status) ! screen_redraw_draw_status(c, top); tty_reset(tty); } --- 377,414 ---- struct tty *tty = &c->tty; struct window *w = c->session->curw->window; struct options *wo = w->options; ! u_int top, lines; ! int position, pane_status; if (c->flags & CLIENT_SUSPENDED) return; ! if (c->flags & CLIENT_STATUSOFF) ! lines = 0; else ! lines = status_line_size(c->session); ! if (c->message_string != NULL || c->prompt_string != NULL) ! lines = (lines == 0) ? 1 : lines; ! ! position = options_get_number(oo, "status-position"); ! if (lines != 0 && position == 0) top = 1; ! else ! top = 0; ! ! if (lines == 0) draw_status = 0; if (draw_borders) { pane_status = options_get_number(wo, "pane-border-status"); ! screen_redraw_draw_borders(c, pane_status, lines, top); if (pane_status != CELL_STATUS_OFF) screen_redraw_draw_pane_status(c, pane_status); } if (draw_panes) ! screen_redraw_draw_panes(c, lines, top); if (draw_status) ! screen_redraw_draw_status(c, lines, top); tty_reset(tty); } *************** *** 421,427 **** yoff = wp->yoff; if (status_at_line(c) == 0) ! yoff++; log_debug("%s: redraw pane %%%u (at %u,%u)", c->name, wp->id, wp->xoff, yoff); --- 423,429 ---- yoff = wp->yoff; if (status_at_line(c) == 0) ! yoff += status_line_size(c->session); log_debug("%s: redraw pane %%%u (at %u,%u)", c->name, wp->id, wp->xoff, yoff); *************** *** 433,439 **** /* Draw the borders. */ static void ! screen_redraw_draw_borders(struct client *c, int status, int pane_status, u_int top) { struct session *s = c->session; --- 435,441 ---- /* Draw the borders. */ static void ! screen_redraw_draw_borders(struct client *c, int pane_status, u_int lines, u_int top) { struct session *s = c->session; *************** *** 449,455 **** const char *tmp; size_t msglen = 0; ! small = (tty->sy - status + top > w->sy) || (tty->sx > w->sx); if (small) { flags = w->flags & (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT); if (flags == (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT)) --- 451,457 ---- const char *tmp; size_t msglen = 0; ! small = (tty->sy - lines + top > w->sy) || (tty->sx > w->sx); if (small) { flags = w->flags & (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT); if (flags == (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT)) *************** *** 458,475 **** tmp = "force-width"; else if (flags == WINDOW_FORCEHEIGHT) tmp = "force-height"; else tmp = "a smaller client"; xsnprintf(msg, sizeof msg, "(size %ux%u from %s)", w->sx, w->sy, tmp); msglen = strlen(msg); ! if (tty->sy - 1 - status + top > w->sy && tty->sx >= msglen) { msgx = tty->sx - msglen; ! msgy = tty->sy - 1 - status + top; } else if (tty->sx - w->sx > msglen) { msgx = tty->sx - msglen; ! msgy = tty->sy - 1 - status + top; } else small = 0; } --- 460,479 ---- tmp = "force-width"; else if (flags == WINDOW_FORCEHEIGHT) tmp = "force-height"; + else if (c->flags & CLIENT_STATUSOFF) + tmp = "status line"; else tmp = "a smaller client"; xsnprintf(msg, sizeof msg, "(size %ux%u from %s)", w->sx, w->sy, tmp); msglen = strlen(msg); ! if (tty->sy - 1 - lines + top > w->sy && tty->sx >= msglen) { msgx = tty->sx - msglen; ! msgy = tty->sy - 1 - lines + top; } else if (tty->sx - w->sx > msglen) { msgx = tty->sx - msglen; ! msgy = tty->sy - 1 - lines + top; } else small = 0; } *************** *** 483,489 **** memcpy(&m_active_gc, &active_gc, sizeof m_active_gc); m_active_gc.attr ^= GRID_ATTR_REVERSE; ! for (j = 0; j < tty->sy - status; j++) { for (i = 0; i < tty->sx; i++) { type = screen_redraw_check_cell(c, i, j, pane_status, &wp); --- 487,493 ---- memcpy(&m_active_gc, &active_gc, sizeof m_active_gc); m_active_gc.attr ^= GRID_ATTR_REVERSE; ! for (j = 0; j < tty->sy - lines; j++) { for (i = 0; i < tty->sx; i++) { type = screen_redraw_check_cell(c, i, j, pane_status, &wp); *************** *** 505,511 **** tty_attributes(tty, &active_gc, NULL); else tty_attributes(tty, &other_gc, NULL); ! tty_cursor(tty, i, top + j); tty_putc(tty, CELL_BORDERS[type]); } } --- 509,518 ---- tty_attributes(tty, &active_gc, NULL); else tty_attributes(tty, &other_gc, NULL); ! if (top) ! tty_cursor(tty, i, lines + j); ! else ! tty_cursor(tty, i, j); tty_putc(tty, CELL_BORDERS[type]); } } *************** *** 520,557 **** /* Draw the panes. */ static void ! screen_redraw_draw_panes(struct client *c, u_int top) { struct window *w = c->session->curw->window; struct tty *tty = &c->tty; struct window_pane *wp; ! u_int i; TAILQ_FOREACH(wp, &w->panes, entry) { if (!window_pane_visible(wp)) continue; for (i = 0; i < wp->sy; i++) ! tty_draw_pane(tty, wp, i, wp->xoff, top + wp->yoff); if (c->flags & CLIENT_IDENTIFY) ! screen_redraw_draw_number(c, wp, top); } } /* Draw the status line. */ static void ! screen_redraw_draw_status(struct client *c, u_int top) { struct tty *tty = &c->tty; if (top) ! tty_draw_line(tty, NULL, &c->status, 0, 0, 0); else ! tty_draw_line(tty, NULL, &c->status, 0, 0, tty->sy - 1); } /* Draw number on a pane. */ static void ! screen_redraw_draw_number(struct client *c, struct window_pane *wp, u_int top) { struct tty *tty = &c->tty; struct session *s = c->session; --- 527,573 ---- /* Draw the panes. */ static void ! screen_redraw_draw_panes(struct client *c, u_int lines, u_int top) { struct window *w = c->session->curw->window; struct tty *tty = &c->tty; struct window_pane *wp; ! u_int i, y; + if (top) + y = lines; + else + y = 0; + TAILQ_FOREACH(wp, &w->panes, entry) { if (!window_pane_visible(wp)) continue; for (i = 0; i < wp->sy; i++) ! tty_draw_pane(tty, wp, i, wp->xoff, y + wp->yoff); if (c->flags & CLIENT_IDENTIFY) ! screen_redraw_draw_number(c, wp, lines, top); } } /* Draw the status line. */ static void ! screen_redraw_draw_status(struct client *c, u_int lines, u_int top) { struct tty *tty = &c->tty; + u_int i, y; if (top) ! y = 0; else ! y = tty->sy - lines; ! for (i = 0; i < lines; i++) ! tty_draw_line(tty, NULL, &c->status, i, 0, y); } /* Draw number on a pane. */ static void ! screen_redraw_draw_number(struct client *c, struct window_pane *wp, ! u_int lines, u_int top) { struct tty *tty = &c->tty; struct session *s = c->session; *************** *** 576,582 **** xoff = wp->xoff; yoff = wp->yoff; if (top) ! yoff++; if (wp->sx < len * 6 || wp->sy < 5) { tty_cursor(tty, xoff + px - len / 2, yoff + py); --- 592,598 ---- xoff = wp->xoff; yoff = wp->yoff; if (top) ! yoff += lines; if (wp->sx < len * 6 || wp->sy < 5) { tty_cursor(tty, xoff + px - len / 2, yoff + py);