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

Diff for /src/usr.bin/tmux/tty.c between version 1.297 and 1.298

version 1.297, 2017/11/15 19:18:57 version 1.298, 2018/01/12 16:41:00
Line 878 
Line 878 
         tty_draw_line(tty, wp, wp->screen, py, ox, oy);          tty_draw_line(tty, wp, wp->screen, py, ox, oy);
 }  }
   
   static const struct grid_cell *
   tty_check_codeset(struct tty *tty, const struct grid_cell *gc)
   {
           static struct grid_cell new;
           u_int                   n;
   
           /* Characters less than 0x7f are always fine, no matter what. */
           if (gc->data.size == 1 && *gc->data.data < 0x7f)
                   return (gc);
   
           /* UTF-8 terminal and a UTF-8 character - fine. */
           if (tty->flags & TTY_UTF8)
                   return (gc);
   
           /* Replace by the right number of underscores. */
           n = gc->data.width;
           if (n > UTF8_SIZE)
                   n = UTF8_SIZE;
           memcpy(&new, gc, sizeof new);
           new.data.size = n;
           memset(new.data.data, '_', n);
           return (&new);
   }
   
 void  void
 tty_draw_line(struct tty *tty, const struct window_pane *wp,  tty_draw_line(struct tty *tty, const struct window_pane *wp,
     struct screen *s, u_int py, u_int ox, u_int oy)      struct screen *s, u_int py, u_int ox, u_int oy)
 {  {
         struct grid             *gd = s->grid;          struct grid             *gd = s->grid;
         struct grid_cell         gc, last;          struct grid_cell         gc, last;
           const struct grid_cell  *gcp;
         u_int                    i, j, ux, sx, nx, width;          u_int                    i, j, ux, sx, nx, width;
         int                      flags, cleared = 0;          int                      flags, cleared = 0;
         char                     buf[512];          char                     buf[512];
Line 934 
Line 959 
   
         for (i = 0; i < sx; i++) {          for (i = 0; i < sx; i++) {
                 grid_view_get_cell(gd, i, py, &gc);                  grid_view_get_cell(gd, i, py, &gc);
                   gcp = tty_check_codeset(tty, &gc);
                 if (len != 0 &&                  if (len != 0 &&
                     (((~tty->flags & TTY_UTF8) &&                      ((gcp->attr & GRID_ATTR_CHARSET) ||
                     (gc.data.size != 1 ||                      gcp->flags != last.flags ||
                     *gc.data.data >= 0x7f ||                      gcp->attr != last.attr ||
                     gc.data.width != 1)) ||                      gcp->fg != last.fg ||
                     (gc.attr & GRID_ATTR_CHARSET) ||                      gcp->bg != last.bg ||
                     gc.flags != last.flags ||                      ux + width + gcp->data.width >= screen_size_x(s) ||
                     gc.attr != last.attr ||                      (sizeof buf) - len < gcp->data.size)) {
                     gc.fg != last.fg ||  
                     gc.bg != last.bg ||  
                     ux + width + gc.data.width >= screen_size_x(s) ||  
                     (sizeof buf) - len < gc.data.size)) {  
                         tty_attributes(tty, &last, wp);                          tty_attributes(tty, &last, wp);
                         tty_putn(tty, buf, len, width);                          tty_putn(tty, buf, len, width);
                         ux += width;                          ux += width;
Line 954 
Line 976 
                         width = 0;                          width = 0;
                 }                  }
   
                 if (gc.flags & GRID_FLAG_SELECTED)                  if (gcp->flags & GRID_FLAG_SELECTED)
                         screen_select_cell(s, &last, &gc);                          screen_select_cell(s, &last, &gc);
                 else                  else
                         memcpy(&last, &gc, sizeof last);                          memcpy(&last, &gc, sizeof last);
                 if (ux + gc.data.width > screen_size_x(s))                  if (ux + gcp->data.width > screen_size_x(s))
                         for (j = 0; j < gc.data.width; j++) {                          for (j = 0; j < gcp->data.width; j++) {
                                 if (ux + j > screen_size_x(s))                                  if (ux + j > screen_size_x(s))
                                         break;                                          break;
                                 tty_putc(tty, ' ');                                  tty_putc(tty, ' ');
                                 ux++;                                  ux++;
                         }                          }
                 else if (((~tty->flags & TTY_UTF8) &&                  else {
                     (gc.data.size != 1 ||                          memcpy(buf + len, gcp->data.data, gcp->data.size);
                     *gc.data.data >= 0x7f ||                          len += gcp->data.size;
                     gc.data.width != 1)) ||                          width += gcp->data.width;
                     (gc.attr & GRID_ATTR_CHARSET)) {  
                         tty_attributes(tty, &last, wp);  
                         if (~tty->flags & TTY_UTF8) {  
                                 for (j = 0; j < gc.data.width; j++)  
                                         tty_putc(tty, '_');  
                         } else {  
                                 for (j = 0; j < gc.data.size; j++)  
                                         tty_putc(tty, gc.data.data[j]);  
                         }  
                         ux += gc.data.width;  
                 } else {  
                         memcpy(buf + len, gc.data.data, gc.data.size);  
                         len += gc.data.size;  
                         width += gc.data.width;  
                 }                  }
         }          }
         if (len != 0) {          if (len != 0) {
Line 1409 
Line 1417 
 tty_cell(struct tty *tty, const struct grid_cell *gc,  tty_cell(struct tty *tty, const struct grid_cell *gc,
     const struct window_pane *wp)      const struct window_pane *wp)
 {  {
         u_int   i;          const struct grid_cell  *gcp;
   
         /* Skip last character if terminal is stupid. */          /* Skip last character if terminal is stupid. */
         if ((tty->term->flags & TERM_EARLYWRAP) &&          if ((tty->term->flags & TERM_EARLYWRAP) &&
Line 1425 
Line 1433 
         tty_attributes(tty, gc, wp);          tty_attributes(tty, gc, wp);
   
         /* Get the cell and if ASCII write with putc to do ACS translation. */          /* Get the cell and if ASCII write with putc to do ACS translation. */
         if (gc->data.size == 1) {          gcp = tty_check_codeset(tty, gc);
                 if (*gc->data.data < 0x20 || *gc->data.data == 0x7f)          if (gcp->data.size == 1) {
                   if (*gcp->data.data < 0x20 || *gcp->data.data == 0x7f)
                         return;                          return;
                 tty_putc(tty, *gc->data.data);                  tty_putc(tty, *gcp->data.data);
                 return;                  return;
         }          }
   
         /* If not UTF-8, write _. */  
         if (!(tty->flags & TTY_UTF8)) {  
                 for (i = 0; i < gc->data.width; i++)  
                         tty_putc(tty, '_');  
                 return;  
         }  
   
         /* Write the data. */          /* Write the data. */
         tty_putn(tty, gc->data.data, gc->data.size, gc->data.width);          tty_putn(tty, gcp->data.data, gcp->data.size, gcp->data.width);
 }  }
   
 void  void

Legend:
Removed from v.1.297  
changed lines
  Added in v.1.298