=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.174 retrieving revision 1.175 diff -c -r1.174 -r1.175 *** src/usr.bin/tmux/status.c 2018/01/01 11:03:54 1.174 --- src/usr.bin/tmux/status.c 2018/02/05 08:21:54 1.175 *************** *** 1,4 **** ! /* $OpenBSD: status.c,v 1.174 2018/01/01 11:03:54 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: status.c,v 1.175 2018/02/05 08:21:54 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 151,157 **** struct session *s = c->session; struct timeval tv; ! evtimer_del(&c->status_timer); if (s == NULL) return; --- 151,157 ---- struct session *s = c->session; struct timeval tv; ! evtimer_del(&c->status.timer); if (s == NULL) return; *************** *** 163,169 **** tv.tv_sec = options_get_number(s->options, "status-interval"); if (tv.tv_sec != 0) ! evtimer_add(&c->status_timer, &tv); log_debug("client %p, status interval %d", c, (int)tv.tv_sec); } --- 163,169 ---- tv.tv_sec = options_get_number(s->options, "status-interval"); if (tv.tv_sec != 0) ! evtimer_add(&c->status.timer, &tv); log_debug("client %p, status interval %d", c, (int)tv.tv_sec); } *************** *** 173,182 **** { struct session *s = c->session; ! if (event_initialized(&c->status_timer)) ! evtimer_del(&c->status_timer); else ! evtimer_set(&c->status_timer, status_timer_callback, c); if (s != NULL && options_get_number(s->options, "status")) status_timer_callback(-1, 0, c); --- 173,182 ---- { struct session *s = c->session; ! if (event_initialized(&c->status.timer)) ! evtimer_del(&c->status.timer); else ! evtimer_set(&c->status.timer, status_timer_callback, c); if (s != NULL && options_get_number(s->options, "status")) status_timer_callback(-1, 0, c); *************** *** 317,326 **** int larrow, rarrow; /* Delete the saved status line, if any. */ ! if (c->old_status != NULL) { ! screen_free(c->old_status); ! free(c->old_status); ! c->old_status = NULL; } /* No status line? */ --- 317,326 ---- int larrow, rarrow; /* Delete the saved status line, if any. */ ! if (c->status.old_status != NULL) { ! screen_free(c->status.old_status); ! free(c->status.old_status); ! c->status.old_status = NULL; } /* No status line? */ *************** *** 337,345 **** style_apply(&stdgc, s->options, "status-style"); /* Create the target screen. */ ! memcpy(&old_status, &c->status, sizeof old_status); ! screen_init(&c->status, c->tty.sx, lines, 0); ! screen_write_start(&ctx, NULL, &c->status); for (offset = 0; offset < lines * c->tty.sx; offset++) screen_write_putc(&ctx, &stdgc, ' '); screen_write_stop(&ctx); --- 337,345 ---- style_apply(&stdgc, s->options, "status-style"); /* Create the target screen. */ ! memcpy(&old_status, &c->status.status, sizeof old_status); ! screen_init(&c->status.status, c->tty.sx, lines, 0); ! screen_write_start(&ctx, NULL, &c->status.status); for (offset = 0; offset < lines * c->tty.sx; offset++) screen_write_putc(&ctx, &stdgc, ' '); screen_write_stop(&ctx); *************** *** 462,468 **** draw: /* Begin drawing. */ ! screen_write_start(&ctx, NULL, &c->status); /* Draw the left string and arrow. */ screen_write_cursormove(&ctx, 0, 0); --- 462,468 ---- draw: /* Begin drawing. */ ! screen_write_start(&ctx, NULL, &c->status.status); /* Draw the left string and arrow. */ screen_write_cursormove(&ctx, 0, 0); *************** *** 517,523 **** free(left); free(right); ! if (grid_compare(c->status.grid, old_status.grid) == 0) { screen_free(&old_status); return (0); } --- 517,523 ---- free(left); free(right); ! if (grid_compare(c->status.status.grid, old_status.grid) == 0) { screen_free(&old_status); return (0); } *************** *** 590,599 **** status_message_clear(c); ! if (c->old_status == NULL) { ! c->old_status = xmalloc(sizeof *c->old_status); ! memcpy(c->old_status, &c->status, sizeof *c->old_status); ! screen_init(&c->status, c->tty.sx, 1, 0); } va_start(ap, fmt); --- 590,600 ---- status_message_clear(c); ! if (c->status.old_status == NULL) { ! c->status.old_status = xmalloc(sizeof *c->status.old_status); ! memcpy(c->status.old_status, &c->status.status, ! sizeof *c->status.old_status); ! screen_init(&c->status.status, c->tty.sx, 1, 0); } va_start(ap, fmt); *************** *** 631,637 **** c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */ ! screen_reinit(&c->status); } /* Clear status line message after timer expires. */ --- 632,638 ---- c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */ ! screen_reinit(&c->status.status); } /* Clear status line message after timer expires. */ *************** *** 656,669 **** if (c->tty.sx == 0 || c->tty.sy == 0) return (0); ! memcpy(&old_status, &c->status, sizeof old_status); lines = status_line_size(c->session); if (lines <= 1) { lines = 1; ! screen_init(&c->status, c->tty.sx, 1, 0); } else ! screen_init(&c->status, c->tty.sx, lines, 0); len = screen_write_strlen("%s", c->message_string); if (len > c->tty.sx) --- 657,670 ---- if (c->tty.sx == 0 || c->tty.sy == 0) return (0); ! memcpy(&old_status, &c->status.status, sizeof old_status); lines = status_line_size(c->session); if (lines <= 1) { lines = 1; ! screen_init(&c->status.status, c->tty.sx, 1, 0); } else ! screen_init(&c->status.status, c->tty.sx, lines, 0); len = screen_write_strlen("%s", c->message_string); if (len > c->tty.sx) *************** *** 671,677 **** style_apply(&gc, s->options, "message-style"); ! screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, 0); for (offset = 0; offset < lines * c->tty.sx; offset++) screen_write_putc(&ctx, &gc, ' '); --- 672,678 ---- style_apply(&gc, s->options, "message-style"); ! screen_write_start(&ctx, NULL, &c->status.status); screen_write_cursormove(&ctx, 0, 0); for (offset = 0; offset < lines * c->tty.sx; offset++) screen_write_putc(&ctx, &gc, ' '); *************** *** 679,685 **** screen_write_nputs(&ctx, len, &gc, "%s", c->message_string); screen_write_stop(&ctx); ! if (grid_compare(c->status.grid, old_status.grid) == 0) { screen_free(&old_status); return (0); } --- 680,686 ---- screen_write_nputs(&ctx, len, &gc, "%s", c->message_string); screen_write_stop(&ctx); ! if (grid_compare(c->status.status.grid, old_status.grid) == 0) { screen_free(&old_status); return (0); } *************** *** 710,719 **** status_message_clear(c); status_prompt_clear(c); ! if (c->old_status == NULL) { ! c->old_status = xmalloc(sizeof *c->old_status); ! memcpy(c->old_status, &c->status, sizeof *c->old_status); ! screen_init(&c->status, c->tty.sx, 1, 0); } c->prompt_string = format_expand_time(ft, msg, t); --- 711,721 ---- status_message_clear(c); status_prompt_clear(c); ! if (c->status.old_status == NULL) { ! c->status.old_status = xmalloc(sizeof *c->status.old_status); ! memcpy(c->status.old_status, &c->status.status, ! sizeof *c->status.old_status); ! screen_init(&c->status.status, c->tty.sx, 1, 0); } c->prompt_string = format_expand_time(ft, msg, t); *************** *** 763,769 **** c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */ ! screen_reinit(&c->status); } /* Update status line prompt with a new prompt string. */ --- 765,771 ---- c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */ ! screen_reinit(&c->status.status); } /* Update status line prompt with a new prompt string. */ *************** *** 809,822 **** if (c->tty.sx == 0 || c->tty.sy == 0) return (0); ! memcpy(&old_status, &c->status, sizeof old_status); lines = status_line_size(c->session); if (lines <= 1) { lines = 1; ! screen_init(&c->status, c->tty.sx, 1, 0); } else ! screen_init(&c->status, c->tty.sx, lines, 0); len = screen_write_strlen("%s", c->prompt_string); if (len > c->tty.sx) --- 811,824 ---- if (c->tty.sx == 0 || c->tty.sy == 0) return (0); ! memcpy(&old_status, &c->status.status, sizeof old_status); lines = status_line_size(c->session); if (lines <= 1) { lines = 1; ! screen_init(&c->status.status, c->tty.sx, 1, 0); } else ! screen_init(&c->status.status, c->tty.sx, lines, 0); len = screen_write_strlen("%s", c->prompt_string); if (len > c->tty.sx) *************** *** 834,840 **** if (start > c->tty.sx) start = c->tty.sx; ! screen_write_start(&ctx, NULL, &c->status); screen_write_cursormove(&ctx, 0, 0); for (offset = 0; offset < lines * c->tty.sx; offset++) screen_write_putc(&ctx, &gc, ' '); --- 836,842 ---- if (start > c->tty.sx) start = c->tty.sx; ! screen_write_start(&ctx, NULL, &c->status.status); screen_write_cursormove(&ctx, 0, 0); for (offset = 0; offset < lines * c->tty.sx; offset++) screen_write_putc(&ctx, &gc, ' '); *************** *** 880,892 **** screen_write_cell(&ctx, &cursorgc); } } ! if (c->status.cx < screen_size_x(&c->status) && c->prompt_index >= i) screen_write_putc(&ctx, &cursorgc, ' '); finished: screen_write_stop(&ctx); ! if (grid_compare(c->status.grid, old_status.grid) == 0) { screen_free(&old_status); return (0); } --- 882,895 ---- screen_write_cell(&ctx, &cursorgc); } } ! if (c->status.status.cx < screen_size_x(&c->status.status) && ! c->prompt_index >= i) screen_write_putc(&ctx, &cursorgc, ' '); finished: screen_write_stop(&ctx); ! if (grid_compare(c->status.status.grid, old_status.grid) == 0) { screen_free(&old_status); return (0); }