[BACK]Return to status.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/status.c between version 1.188 and 1.189

version 1.188, 2019/03/16 17:53:55 version 1.189, 2019/03/16 19:12:13
Line 296 
Line 296 
         return (NULL);          return (NULL);
 }  }
   
   /* Save old status line. */
   static void
   status_push_screen(struct client *c)
   {
           struct status_line *sl = &c->status;
   
           if (sl->active == &sl->screen) {
                   sl->active = xmalloc(sizeof *sl->active);
                   screen_init(sl->active, c->tty.sx, status_line_size(c), 0);
           }
           sl->references++;
   }
   
   /* Restore old status line. */
   static void
   status_pop_screen(struct client *c)
   {
           struct status_line *sl = &c->status;
   
           if (--sl->references == 0) {
                   screen_free(sl->active);
                   free(sl->active);
                   sl->active = &sl->screen;
           }
   }
   
 /* Initialize status line. */  /* Initialize status line. */
 void  void
 status_init(struct client *c)  status_init(struct client *c)
Line 303 
Line 329 
         struct status_line      *sl = &c->status;          struct status_line      *sl = &c->status;
   
         screen_init(&sl->screen, c->tty.sx, 1, 0);          screen_init(&sl->screen, c->tty.sx, 1, 0);
           sl->active = &sl->screen;
 }  }
   
 /* Free status line. */  /* Free status line. */
Line 314 
Line 341 
         if (event_initialized(&sl->timer))          if (event_initialized(&sl->timer))
                 evtimer_del(&sl->timer);                  evtimer_del(&sl->timer);
   
         screen_free(&sl->screen);          if (sl->active != &sl->screen) {
         if (sl->old_screen != NULL) {                  screen_free(sl->active);
                 screen_free(sl->old_screen);                  free(sl->active);
                 free(sl->old_screen);  
         }          }
           screen_free(&sl->screen);
 }  }
   
 /* Save as old status line. */  
 static void  
 status_save_old(struct client *c)  
 {  
         struct status_line *sl = &c->status;  
   
         if (sl->old_screen == NULL) {  
                 sl->old_screen = xmalloc(sizeof *sl->old_screen);  
                 memcpy(sl->old_screen, &sl->screen, sizeof *sl->old_screen);  
                 screen_init(&c->status.screen, c->tty.sx, 1, 0);  
         }  
 }  
   
 /* Free old status line. */  
 static void  
 status_free_old(struct client *c)  
 {  
         struct status_line *sl = &c->status;  
   
         if (sl->old_screen != NULL) {  
                 screen_free(sl->old_screen);  
                 free(sl->old_screen);  
                 sl->old_screen = NULL;  
         }  
 }  
   
 /* Draw status line for client. */  /* Draw status line for client. */
 int  int
 status_redraw(struct client *c)  status_redraw(struct client *c)
Line 365 
Line 366 
         size_t                   llen, rlen, seplen;          size_t                   llen, rlen, seplen;
         int                      larrow, rarrow;          int                      larrow, rarrow;
   
         /* Delete the saved status line, if any. */          /* Shouldn't get here if not the active screen. */
         status_free_old(c);          if (sl->active != &sl->screen)
                   fatalx("not the active screen");
   
         /* No status line? */          /* No status line? */
         lines = status_line_size(c);          lines = status_line_size(c);
Line 379 
Line 381 
         style_apply(&stdgc, s->options, "status-style");          style_apply(&stdgc, s->options, "status-style");
   
         /* Create the target screen. */          /* Create the target screen. */
         memcpy(&old_screen, &sl->screen, sizeof old_screen);          memcpy(&old_screen, sl->active, sizeof old_screen);
         screen_init(&sl->screen, c->tty.sx, lines, 0);          screen_init(sl->active, c->tty.sx, lines, 0);
         screen_write_start(&ctx, NULL, &sl->screen);          screen_write_start(&ctx, NULL, sl->active);
         for (offset = 0; offset < lines * c->tty.sx; offset++)          for (offset = 0; offset < lines * c->tty.sx; offset++)
                 screen_write_putc(&ctx, &stdgc, ' ');                  screen_write_putc(&ctx, &stdgc, ' ');
         screen_write_stop(&ctx);          screen_write_stop(&ctx);
Line 504 
Line 506 
   
 draw:  draw:
         /* Begin drawing. */          /* Begin drawing. */
         screen_write_start(&ctx, NULL, &sl->screen);          screen_write_start(&ctx, NULL, sl->active);
   
         /* Draw the left string and arrow. */          /* Draw the left string and arrow. */
         screen_write_cursormove(&ctx, 0, 0, 0);          screen_write_cursormove(&ctx, 0, 0, 0);
Line 563 
Line 565 
         free(left);          free(left);
         free(right);          free(right);
   
         if (grid_compare(sl->screen.grid, old_screen.grid) == 0) {          if (grid_compare(sl->active->grid, old_screen.grid) == 0) {
                 screen_free(&old_screen);                  screen_free(&old_screen);
                 return (0);                  return (0);
         }          }
Line 634 
Line 636 
         int             delay;          int             delay;
   
         status_message_clear(c);          status_message_clear(c);
         status_save_old(c);          status_push_screen(c);
   
         va_start(ap, fmt);          va_start(ap, fmt);
         xvasprintf(&c->message_string, fmt, ap);          xvasprintf(&c->message_string, fmt, ap);
Line 671 
Line 673 
                 c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);                  c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
         c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */          c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
   
         screen_reinit(&c->status.screen);          status_pop_screen(c);
 }  }
   
 /* Clear status line message after timer expires. */  /* Clear status line message after timer expires. */
Line 687 
Line 689 
 int  int
 status_message_redraw(struct client *c)  status_message_redraw(struct client *c)
 {  {
         struct screen_write_ctx         ctx;          struct status_line      *sl = &c->status;
         struct session                 *s = c->session;          struct screen_write_ctx  ctx;
         struct screen                   old_status;          struct session          *s = c->session;
         size_t                          len;          struct screen            old_screen;
         struct grid_cell                gc;          size_t                   len;
         u_int                           lines, offset;          u_int                    lines, offset;
           struct grid_cell         gc;
   
         if (c->tty.sx == 0 || c->tty.sy == 0)          if (c->tty.sx == 0 || c->tty.sy == 0)
                 return (0);                  return (0);
         memcpy(&old_status, &c->status.screen, sizeof old_status);          memcpy(&old_screen, sl->active, sizeof old_screen);
   
         lines = status_line_size(c);          lines = status_line_size(c);
         if (lines <= 1) {          if (lines <= 1)
                 lines = 1;                  lines = 1;
                 screen_init(&c->status.screen, c->tty.sx, 1, 0);          screen_init(sl->active, c->tty.sx, 1, 0);
         } else  
                 screen_init(&c->status.screen, c->tty.sx, lines, 0);  
   
         len = screen_write_strlen("%s", c->message_string);          len = screen_write_strlen("%s", c->message_string);
         if (len > c->tty.sx)          if (len > c->tty.sx)
Line 711 
Line 712 
   
         style_apply(&gc, s->options, "message-style");          style_apply(&gc, s->options, "message-style");
   
         screen_write_start(&ctx, NULL, &c->status.screen);          screen_write_start(&ctx, NULL, sl->active);
         screen_write_cursormove(&ctx, 0, 0, 0);          screen_write_cursormove(&ctx, 0, 0, 0);
         for (offset = 0; offset < lines * c->tty.sx; offset++)          for (offset = 0; offset < lines * c->tty.sx; offset++)
                 screen_write_putc(&ctx, &gc, ' ');                  screen_write_putc(&ctx, &gc, ' ');
Line 719 
Line 720 
         screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);          screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
         screen_write_stop(&ctx);          screen_write_stop(&ctx);
   
         if (grid_compare(c->status.screen.grid, old_status.grid) == 0) {          if (grid_compare(sl->active->grid, old_screen.grid) == 0) {
                 screen_free(&old_status);                  screen_free(&old_screen);
                 return (0);                  return (0);
         }          }
         screen_free(&old_status);          screen_free(&old_screen);
         return (1);          return (1);
 }  }
   
Line 747 
Line 748 
   
         status_message_clear(c);          status_message_clear(c);
         status_prompt_clear(c);          status_prompt_clear(c);
         status_save_old(c);          status_push_screen(c);
   
         c->prompt_string = format_expand_time(ft, msg);          c->prompt_string = format_expand_time(ft, msg);
   
Line 799 
Line 800 
         c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);          c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
         c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */          c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
   
         screen_reinit(&c->status.screen);          status_pop_screen(c);
 }  }
   
 /* Update status line prompt with a new prompt string. */  /* Update status line prompt with a new prompt string. */
Line 833 
Line 834 
 int  int
 status_prompt_redraw(struct client *c)  status_prompt_redraw(struct client *c)
 {  {
           struct status_line      *sl = &c->status;
         struct screen_write_ctx  ctx;          struct screen_write_ctx  ctx;
         struct session          *s = c->session;          struct session          *s = c->session;
         struct screen            old_status;          struct screen            old_screen;
         u_int                    i, offset, left, start, pcursor, pwidth, width;          u_int                    i, lines, offset, left, start, width;
         u_int                    lines;          u_int                    pcursor, pwidth;
         struct grid_cell         gc, cursorgc;          struct grid_cell         gc, cursorgc;
   
         if (c->tty.sx == 0 || c->tty.sy == 0)          if (c->tty.sx == 0 || c->tty.sy == 0)
                 return (0);                  return (0);
         memcpy(&old_status, &c->status.screen, sizeof old_status);          memcpy(&old_screen, sl->active, sizeof old_screen);
   
         lines = status_line_size(c);          lines = status_line_size(c);
         if (lines <= 1) {          if (lines <= 1)
                 lines = 1;                  lines = 1;
                 screen_init(&c->status.screen, c->tty.sx, 1, 0);          screen_init(sl->active, c->tty.sx, lines, 0);
         } else  
                 screen_init(&c->status.screen, c->tty.sx, lines, 0);  
   
         if (c->prompt_mode == PROMPT_COMMAND)          if (c->prompt_mode == PROMPT_COMMAND)
                 style_apply(&gc, s->options, "message-command-style");                  style_apply(&gc, s->options, "message-command-style");
Line 863 
Line 863 
         if (start > c->tty.sx)          if (start > c->tty.sx)
                 start = c->tty.sx;                  start = c->tty.sx;
   
         screen_write_start(&ctx, NULL, &c->status.screen);          screen_write_start(&ctx, NULL, sl->active);
         screen_write_cursormove(&ctx, 0, 0, 0);          screen_write_cursormove(&ctx, 0, 0, 0);
         for (offset = 0; offset < lines * c->tty.sx; offset++)          for (offset = 0; offset < lines * c->tty.sx; offset++)
                 screen_write_putc(&ctx, &gc, ' ');                  screen_write_putc(&ctx, &gc, ' ');
Line 909 
Line 909 
                         screen_write_cell(&ctx, &cursorgc);                          screen_write_cell(&ctx, &cursorgc);
                 }                  }
         }          }
         if (c->status.screen.cx < screen_size_x(&c->status.screen) &&          if (sl->active->cx < screen_size_x(sl->active) && c->prompt_index >= i)
             c->prompt_index >= i)  
                 screen_write_putc(&ctx, &cursorgc, ' ');                  screen_write_putc(&ctx, &cursorgc, ' ');
   
 finished:  finished:
         screen_write_stop(&ctx);          screen_write_stop(&ctx);
   
         if (grid_compare(c->status.screen.grid, old_status.grid) == 0) {          if (grid_compare(sl->active->grid, old_screen.grid) == 0) {
                 screen_free(&old_status);                  screen_free(&old_screen);
                 return (0);                  return (0);
         }          }
         screen_free(&old_status);          screen_free(&old_screen);
         return (1);          return (1);
 }  }
   

Legend:
Removed from v.1.188  
changed lines
  Added in v.1.189