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

Diff for /src/usr.bin/tmux/screen-write.c between version 1.16 and 1.17

version 1.16, 2009/07/22 18:02:23 version 1.17, 2009/07/22 20:53:38
Line 22 
Line 22 
   
 #include "tmux.h"  #include "tmux.h"
   
 void    screen_write_save(struct screen_write_ctx *);  void    screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *);
 void    screen_write_overwrite(struct screen_write_ctx *);  void    screen_write_overwrite(struct screen_write_ctx *);
   
 /* Initialise writing with a window. */  /* Initialise writing with a window. */
Line 210 
Line 210 
         }          }
 }  }
   
 /* Save cursor and region positions. */  /* Set up context for TTY command. */
 void  void
 screen_write_save(struct screen_write_ctx *ctx)  screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
   
         s->old_cx = s->cx;          ttyctx->wp = ctx->wp;
         s->old_cy = s->cy;  
   
         s->old_rlower = s->rlower;          ttyctx->ocx = s->cx;
         s->old_rupper = s->rupper;          ttyctx->ocy = s->cy;
   
           ttyctx->orlower = s->rlower;
           ttyctx->orupper = s->rupper;
 }  }
   
 /* Cursor up by ny. */  /* Cursor up by ny. */
Line 310 
Line 312 
 screen_write_alignmenttest(struct screen_write_ctx *ctx)  screen_write_alignmenttest(struct screen_write_ctx *ctx)
 {  {
         struct screen           *s = ctx->s;          struct screen           *s = ctx->s;
           struct tty_ctx           ttyctx;
         struct grid_cell         gc;          struct grid_cell         gc;
         u_int                    xx, yy;          u_int                    xx, yy;
   
           screen_write_initctx(ctx, &ttyctx);
   
         memcpy(&gc, &grid_default_cell, sizeof gc);          memcpy(&gc, &grid_default_cell, sizeof gc);
         gc.data = 'E';          gc.data = 'E';
   
Line 327 
Line 332 
         s->rupper = 0;          s->rupper = 0;
         s->rlower = screen_size_y(s) - 1;          s->rlower = screen_size_y(s) - 1;
   
         tty_write0(ctx->wp, tty_cmd_alignmenttest);          tty_write(tty_cmd_alignmenttest, &ttyctx);
 }  }
   
 /* Insert nx characters. */  /* Insert nx characters. */
Line 335 
Line 340 
 screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)  screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         if (nx == 0)          if (nx == 0)
                 nx = 1;                  nx = 1;
Line 344 
Line 350 
         if (nx == 0)          if (nx == 0)
                 return;                  return;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         if (s->cx <= screen_size_x(s) - 1)          if (s->cx <= screen_size_x(s) - 1)
                 grid_view_insert_cells(s->grid, s->cx, s->cy, nx);                  grid_view_insert_cells(s->grid, s->cx, s->cy, nx);
   
         tty_writenum(ctx->wp, tty_cmd_insertcharacter, nx);          ttyctx.num = nx;
           tty_write(tty_cmd_insertcharacter, &ttyctx);
 }  }
   
 /* Delete nx characters. */  /* Delete nx characters. */
Line 357 
Line 364 
 screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)  screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         if (nx == 0)          if (nx == 0)
                 nx = 1;                  nx = 1;
Line 366 
Line 374 
         if (nx == 0)          if (nx == 0)
                 return;                  return;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         if (s->cx <= screen_size_x(s) - 1)          if (s->cx <= screen_size_x(s) - 1)
                 grid_view_delete_cells(s->grid, s->cx, s->cy, nx);                  grid_view_delete_cells(s->grid, s->cx, s->cy, nx);
   
         tty_writenum(ctx->wp, tty_cmd_deletecharacter, nx);          ttyctx.num = nx;
           tty_write(tty_cmd_deletecharacter, &ttyctx);
 }  }
   
 /* Insert ny lines. */  /* Insert ny lines. */
Line 379 
Line 388 
 screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)  screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         if (ny == 0)          if (ny == 0)
                 ny = 1;                  ny = 1;
Line 389 
Line 399 
                 if (ny == 0)                  if (ny == 0)
                         return;                          return;
   
                 screen_write_save(ctx);                  screen_write_initctx(ctx, &ttyctx);
   
                 grid_view_insert_lines(s->grid, s->cy, ny);                  grid_view_insert_lines(s->grid, s->cy, ny);
   
                 tty_writenum(ctx->wp, tty_cmd_insertline, ny);                  ttyctx.num = ny;
                   tty_write(tty_cmd_insertline, &ttyctx);
                 return;                  return;
         }          }
   
Line 402 
Line 413 
         if (ny == 0)          if (ny == 0)
                 return;                  return;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         if (s->cy < s->rupper || s->cy > s->rlower)          if (s->cy < s->rupper || s->cy > s->rlower)
                 grid_view_insert_lines(s->grid, s->cy, ny);                  grid_view_insert_lines(s->grid, s->cy, ny);
         else          else
                 grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny);                  grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny);
   
         tty_writenum(ctx->wp, tty_cmd_insertline, ny);          ttyctx.num = ny;
           tty_write(tty_cmd_insertline, &ttyctx);
 }  }
   
 /* Delete ny lines. */  /* Delete ny lines. */
Line 417 
Line 429 
 screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)  screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         if (ny == 0)          if (ny == 0)
                 ny = 1;                  ny = 1;
Line 427 
Line 440 
                 if (ny == 0)                  if (ny == 0)
                         return;                          return;
   
                 screen_write_save(ctx);                  screen_write_initctx(ctx, &ttyctx);
   
                 grid_view_delete_lines(s->grid, s->cy, ny);                  grid_view_delete_lines(s->grid, s->cy, ny);
   
                 tty_writenum(ctx->wp, tty_cmd_deleteline, ny);                  ttyctx.num = ny;
                   tty_write(tty_cmd_deleteline, &ttyctx);
                 return;                  return;
         }          }
   
Line 440 
Line 454 
         if (ny == 0)          if (ny == 0)
                 return;                  return;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         if (s->cy < s->rupper || s->cy > s->rlower)          if (s->cy < s->rupper || s->cy > s->rlower)
                 grid_view_delete_lines(s->grid, s->cy, ny);                  grid_view_delete_lines(s->grid, s->cy, ny);
         else          else
                 grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny);                  grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny);
   
         tty_writenum(ctx->wp, tty_cmd_deleteline, ny);          ttyctx.num = ny;
           tty_write(tty_cmd_deleteline, &ttyctx);
 }  }
   
 /* Clear line at cursor. */  /* Clear line at cursor. */
Line 455 
Line 470 
 screen_write_clearline(struct screen_write_ctx *ctx)  screen_write_clearline(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);          grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);
   
         tty_write0(ctx->wp, tty_cmd_clearline);          tty_write(tty_cmd_clearline, &ttyctx);
 }  }
   
 /* Clear to end of line from cursor. */  /* Clear to end of line from cursor. */
Line 468 
Line 484 
 screen_write_clearendofline(struct screen_write_ctx *ctx)  screen_write_clearendofline(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
         u_int            sx;          u_int            sx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         sx = screen_size_x(s);          sx = screen_size_x(s);
   
         if (s->cx <= sx - 1)          if (s->cx <= sx - 1)
                 grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);                  grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
   
         tty_write0(ctx->wp, tty_cmd_clearendofline);          tty_write(tty_cmd_clearendofline, &ttyctx);
 }  }
   
 /* Clear to start of line from cursor. */  /* Clear to start of line from cursor. */
Line 485 
Line 502 
 screen_write_clearstartofline(struct screen_write_ctx *ctx)  screen_write_clearstartofline(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
         u_int            sx;          u_int            sx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         sx = screen_size_x(s);          sx = screen_size_x(s);
   
Line 496 
Line 514 
         else          else
                 grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);                  grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
   
         tty_write0(ctx->wp, tty_cmd_clearstartofline);          tty_write(tty_cmd_clearstartofline, &ttyctx);
 }  }
   
 /* Move cursor to px,py.  */  /* Move cursor to px,py.  */
Line 531 
Line 549 
 screen_write_reverseindex(struct screen_write_ctx *ctx)  screen_write_reverseindex(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         if (s->cy == s->rupper)          if (s->cy == s->rupper)
                 grid_view_scroll_region_down(s->grid, s->rupper, s->rlower);                  grid_view_scroll_region_down(s->grid, s->rupper, s->rlower);
         else if (s->cy > 0)          else if (s->cy > 0)
                 s->cy--;                  s->cy--;
   
         tty_write0(ctx->wp, tty_cmd_reverseindex);          tty_write(tty_cmd_reverseindex, &ttyctx);
 }  }
   
 /* Set scroll region. */  /* Set scroll region. */
Line 593 
Line 612 
 screen_write_linefeed(struct screen_write_ctx *ctx)  screen_write_linefeed(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         if (s->cy == s->rlower)          if (s->cy == s->rlower)
                 grid_view_scroll_region_up(s->grid, s->rupper, s->rlower);                  grid_view_scroll_region_up(s->grid, s->rupper, s->rlower);
         else if (s->cy < screen_size_y(s) - 1)          else if (s->cy < screen_size_y(s) - 1)
                 s->cy++;                  s->cy++;
   
         tty_write0(ctx->wp, tty_cmd_linefeed);          tty_write(tty_cmd_linefeed, &ttyctx);
 }  }
   
 /* Carriage return (cursor to start of line). */  /* Carriage return (cursor to start of line). */
Line 642 
Line 662 
 screen_write_clearendofscreen(struct screen_write_ctx *ctx)  screen_write_clearendofscreen(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
         u_int            sx, sy;          u_int            sx, sy;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         sx = screen_size_x(s);          sx = screen_size_x(s);
         sy = screen_size_y(s);          sy = screen_size_y(s);
Line 653 
Line 674 
                 grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);                  grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
         grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));          grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
   
         tty_write0(ctx->wp, tty_cmd_clearendofscreen);          tty_write(tty_cmd_clearendofscreen, &ttyctx);
 }  }
   
 /* Clear to start of screen. */  /* Clear to start of screen. */
Line 661 
Line 682 
 screen_write_clearstartofscreen(struct screen_write_ctx *ctx)  screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
         u_int            sx;          u_int            sx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         sx = screen_size_x(s);          sx = screen_size_x(s);
   
Line 674 
Line 696 
         else          else
                 grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);                  grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
   
         tty_write0(ctx->wp, tty_cmd_clearstartofscreen);          tty_write(tty_cmd_clearstartofscreen, &ttyctx);
 }  }
   
 /* Clear entire screen. */  /* Clear entire screen. */
Line 682 
Line 704 
 screen_write_clearscreen(struct screen_write_ctx *ctx)  screen_write_clearscreen(struct screen_write_ctx *ctx)
 {  {
         struct screen   *s = ctx->s;          struct screen   *s = ctx->s;
           struct tty_ctx   ttyctx;
   
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
   
         grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));          grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
   
         tty_write0(ctx->wp, tty_cmd_clearscreen);          tty_write(tty_cmd_clearscreen, &ttyctx);
 }  }
   
 /* Write cell data. */  /* Write cell data. */
Line 737 
Line 760 
                 memcpy(tmp_gu->data + i, udata, UTF8_SIZE - i);                  memcpy(tmp_gu->data + i, udata, UTF8_SIZE - i);
   
                 /* Assume the previous character has just been input. */                  /* Assume the previous character has just been input. */
                 tty_writeptr(ctx->wp, tty_cmd_utf8character, udata);                  screen_write_initctx(ctx, &ttyctx);
                   ttyctx.ptr = udata;
                   tty_write(tty_cmd_utf8character, &ttyctx);
                 return;                  return;
         }          }
   
Line 785 
Line 810 
                 grid_view_set_utf8(gd, s->cx, s->cy, &gu);                  grid_view_set_utf8(gd, s->cx, s->cy, &gu);
   
         /* Move the cursor. */          /* Move the cursor. */
         screen_write_save(ctx);          screen_write_initctx(ctx, &ttyctx);
         s->cx += width;          s->cx += width;
   
         /* Draw to the screen if necessary. */          /* Draw to the screen if necessary. */
         if (insert)          if (insert) {
                 tty_writenum(ctx->wp, tty_cmd_insertcharacter, width);                  ttyctx.num = width;
         ttyctx.wp = ctx->wp;                  tty_write(tty_cmd_insertcharacter, &ttyctx);
           }
         ttyctx.utf8 = &gu;          ttyctx.utf8 = &gu;
         if (screen_check_selection(s, s->cx - width, s->cy)) {          if (screen_check_selection(s, s->cx - width, s->cy)) {
                 s->sel.cell.data = gc->data;                  s->sel.cell.data = gc->data;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17