[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.146 and 1.147

version 1.146, 2013/01/15 23:18:55 version 1.147, 2013/01/18 02:16:21
Line 48 
Line 48 
 void    tty_emulate_repeat(  void    tty_emulate_repeat(
             struct tty *, enum tty_code_code, enum tty_code_code, u_int);              struct tty *, enum tty_code_code, enum tty_code_code, u_int);
 void    tty_repeat_space(struct tty *, u_int);  void    tty_repeat_space(struct tty *, u_int);
 void    tty_cell(struct tty *,  void    tty_cell(struct tty *, const struct grid_cell *);
             const struct grid_cell *, const struct grid_utf8 *);  
   
 #define tty_use_acs(tty) \  #define tty_use_acs(tty) \
         (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8))          (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8))
Line 416 
Line 415 
 }  }
   
 void  void
 tty_pututf8(struct tty *tty, const struct grid_utf8 *gu)  tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
 {  {
         size_t  size;          bufferevent_write(tty->event, buf, len);
   
         size = grid_utf8_size(gu);  
         bufferevent_write(tty->event, gu->data, size);  
         if (tty->log_fd != -1)          if (tty->log_fd != -1)
                 write(tty->log_fd, gu->data, size);                  write(tty->log_fd, buf, len);
         tty->cx += gu->width;          tty->cx += width;
 }  }
   
 void  void
Line 582 
Line 578 
         const struct grid_cell  *gc;          const struct grid_cell  *gc;
         struct grid_line        *gl;          struct grid_line        *gl;
         struct grid_cell         tmpgc;          struct grid_cell         tmpgc;
         const struct grid_utf8  *gu;          struct utf8_data         ud;
         u_int                    i, sx;          u_int                    i, sx;
   
         tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s);          tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s);
Line 607 
Line 603 
   
         for (i = 0; i < sx; i++) {          for (i = 0; i < sx; i++) {
                 gc = grid_view_peek_cell(s->grid, i, py);                  gc = grid_view_peek_cell(s->grid, i, py);
   
                 gu = NULL;  
                 if (gc->flags & GRID_FLAG_UTF8)  
                         gu = grid_view_peek_utf8(s->grid, i, py);  
   
                 if (screen_check_selection(s, i, py)) {                  if (screen_check_selection(s, i, py)) {
                         memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc);                          memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc);
                         tmpgc.data = gc->data;                          grid_cell_get(gc, &ud);
                           grid_cell_set(&tmpgc, &ud);
                         tmpgc.flags = gc->flags &                          tmpgc.flags = gc->flags &
                             ~(GRID_FLAG_FG256|GRID_FLAG_BG256);                              ~(GRID_FLAG_FG256|GRID_FLAG_BG256);
                         tmpgc.flags |= s->sel.cell.flags &                          tmpgc.flags |= s->sel.cell.flags &
                             (GRID_FLAG_FG256|GRID_FLAG_BG256);                              (GRID_FLAG_FG256|GRID_FLAG_BG256);
                         tty_cell(tty, &tmpgc, gu);                          tty_cell(tty, &tmpgc);
                 } else                  } else
                         tty_cell(tty, gc, gu);                          tty_cell(tty, gc);
         }          }
   
         if (sx >= tty->sx) {          if (sx >= tty->sx) {
Line 984 
Line 976 
         struct screen           *s = wp->screen;          struct screen           *s = wp->screen;
         u_int                    cx;          u_int                    cx;
         u_int                    width;          u_int                    width;
         const struct grid_cell  *gc = ctx->cell;  
         const struct grid_utf8  *gu = ctx->utf8;  
   
         if (gc->flags & GRID_FLAG_UTF8)  
                 width = gu->width;  
         else  
                 width = 1;  
   
         tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);          tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
   
         /* Is the cursor in the very last position? */          /* Is the cursor in the very last position? */
           width = grid_cell_width(ctx->cell);
         if (ctx->ocx > wp->sx - width) {          if (ctx->ocx > wp->sx - width) {
                 if (ctx->xoff != 0 || wp->sx != tty->sx) {                  if (ctx->xoff != 0 || wp->sx != tty->sx) {
                         /*                          /*
Line 1011 
Line 997 
                          * move as far left as possible and redraw the last                           * move as far left as possible and redraw the last
                          * cell to move into the last position.                           * cell to move into the last position.
                          */                           */
                         if (ctx->last_cell.flags & GRID_FLAG_UTF8)                          cx = screen_size_x(s) - grid_cell_width(&ctx->last_cell);
                                 cx = screen_size_x(s) - ctx->last_utf8.width;  
                         else  
                                 cx = screen_size_x(s) - 1;  
                         tty_cursor_pane(tty, ctx, cx, ctx->ocy);                          tty_cursor_pane(tty, ctx, cx, ctx->ocy);
                         tty_cell(tty, &ctx->last_cell, &ctx->last_utf8);                          tty_cell(tty, &ctx->last_cell);
                 }                  }
         } else          } else
                 tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);                  tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
   
         tty_cell(tty, ctx->cell, ctx->utf8);          tty_cell(tty, ctx->cell);
 }  }
   
 void  void
Line 1071 
Line 1054 
 }  }
   
 void  void
 tty_cell(  tty_cell(struct tty *tty, const struct grid_cell *gc)
     struct tty *tty, const struct grid_cell *gc, const struct grid_utf8 *gu)  
 {  {
         u_int   i;          struct utf8_data        ud;
           u_int                   i;
   
         /* 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 1088 
Line 1071 
         /* Set the attributes. */          /* Set the attributes. */
         tty_attributes(tty, gc);          tty_attributes(tty, gc);
   
         /* If not UTF-8, write directly. */          /* Get the cell and if ASCII write with putc to do ACS translation. */
         if (!(gc->flags & GRID_FLAG_UTF8)) {          grid_cell_get(gc, &ud);
                 if (gc->data < 0x20 || gc->data == 0x7f)          if (ud.size == 1) {
                   if (*ud.data < 0x20 || *ud.data == 0x7f)
                         return;                          return;
                 tty_putc(tty, gc->data);                  tty_putc(tty, *ud.data);
                 return;                  return;
         }          }
   
         /* If the terminal doesn't support UTF-8, write underscores. */          /* If not UTF-8, write _. */
         if (!(tty->flags & TTY_UTF8)) {          if (!(tty->flags & TTY_UTF8)) {
                 for (i = 0; i < gu->width; i++)                  for (i = 0; i < ud.width; i++)
                         tty_putc(tty, '_');                          tty_putc(tty, '_');
                 return;                  return;
         }          }
   
         /* Otherwise, write UTF-8. */          /* Write the data. */
         tty_pututf8(tty, gu);          tty_putn(tty, ud.data, ud.size, ud.width);
 }  }
   
 void  void

Legend:
Removed from v.1.146  
changed lines
  Added in v.1.147