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

Diff for /src/usr.bin/tmux/input.c between version 1.143 and 1.144

version 1.143, 2019/03/12 12:58:40 version 1.144, 2019/03/12 18:26:57
Line 801 
Line 801 
 input_reset(struct window_pane *wp, int clear)  input_reset(struct window_pane *wp, int clear)
 {  {
         struct input_ctx        *ictx = wp->ictx;          struct input_ctx        *ictx = wp->ictx;
           struct screen_write_ctx *sctx = &ictx->ctx;
   
         input_reset_cell(ictx);          input_reset_cell(ictx);
   
         if (clear) {          if (clear) {
                 if (TAILQ_EMPTY(&wp->modes))                  if (TAILQ_EMPTY(&wp->modes))
                         screen_write_start(&ictx->ctx, wp, &wp->base);                          screen_write_start(sctx, wp, &wp->base);
                 else                  else
                         screen_write_start(&ictx->ctx, NULL, &wp->base);                          screen_write_start(sctx, NULL, &wp->base);
                 screen_write_reset(&ictx->ctx);                  screen_write_reset(sctx);
                 screen_write_stop(&ictx->ctx);                  screen_write_stop(sctx);
         }          }
   
         input_clear(ictx);          input_clear(ictx);
Line 846 
Line 847 
 input_parse(struct window_pane *wp)  input_parse(struct window_pane *wp)
 {  {
         struct input_ctx                *ictx = wp->ictx;          struct input_ctx                *ictx = wp->ictx;
           struct screen_write_ctx         *sctx = &ictx->ctx;
         const struct input_transition   *itr;          const struct input_transition   *itr;
         struct evbuffer                 *evb = wp->event->input;          struct evbuffer                 *evb = wp->event->input;
         u_char                          *buf;          u_char                          *buf;
Line 862 
Line 864 
          * update the tty.           * update the tty.
          */           */
         if (TAILQ_EMPTY(&wp->modes))          if (TAILQ_EMPTY(&wp->modes))
                 screen_write_start(&ictx->ctx, wp, &wp->base);                  screen_write_start(sctx, wp, &wp->base);
         else          else
                 screen_write_start(&ictx->ctx, NULL, &wp->base);                  screen_write_start(sctx, NULL, &wp->base);
         ictx->wp = wp;          ictx->wp = wp;
   
         buf = EVBUFFER_DATA(evb);          buf = EVBUFFER_DATA(evb);
Line 900 
Line 902 
                  * be the minority.                   * be the minority.
                  */                   */
                 if (itr->handler != input_print)                  if (itr->handler != input_print)
                         screen_write_collect_end(&ictx->ctx);                          screen_write_collect_end(sctx);
   
                 /*                  /*
                  * Execute the handler, if any. Don't switch state if it                   * Execute the handler, if any. Don't switch state if it
Line 919 
Line 921 
         }          }
   
         /* Close the screen. */          /* Close the screen. */
         screen_write_stop(&ictx->ctx);          screen_write_stop(sctx);
   
         evbuffer_drain(evb, len);          evbuffer_drain(evb, len);
 }  }
Line 1048 
Line 1050 
 static int  static int
 input_print(struct input_ctx *ictx)  input_print(struct input_ctx *ictx)
 {  {
         int     set;          struct screen_write_ctx *sctx = &ictx->ctx;
           int                      set;
   
         ictx->utf8started = 0; /* can't be valid UTF-8 */          ictx->utf8started = 0; /* can't be valid UTF-8 */
   
Line 1059 
Line 1062 
                 ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;                  ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
   
         utf8_set(&ictx->cell.cell.data, ictx->ch);          utf8_set(&ictx->cell.cell.data, ictx->ch);
         screen_write_collect_add(&ictx->ctx, &ictx->cell.cell);          screen_write_collect_add(sctx, &ictx->cell.cell);
         ictx->last = ictx->ch;          ictx->last = ictx->ch;
   
         ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;          ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
Line 1533 
Line 1536 
 static void  static void
 input_csi_dispatch_rm(struct input_ctx *ictx)  input_csi_dispatch_rm(struct input_ctx *ictx)
 {  {
         u_int   i;          struct screen_write_ctx *sctx = &ictx->ctx;
           u_int                    i;
   
         for (i = 0; i < ictx->param_list_len; i++) {          for (i = 0; i < ictx->param_list_len; i++) {
                 switch (input_get(ictx, i, 0, -1)) {                  switch (input_get(ictx, i, 0, -1)) {
                 case -1:                  case -1:
                         break;                          break;
                 case 4:         /* IRM */                  case 4:         /* IRM */
                         screen_write_mode_clear(&ictx->ctx, MODE_INSERT);                          screen_write_mode_clear(sctx, MODE_INSERT);
                         break;                          break;
                 case 34:                  case 34:
                         screen_write_mode_set(&ictx->ctx, MODE_BLINKING);                          screen_write_mode_set(sctx, MODE_BLINKING);
                         break;                          break;
                 default:                  default:
                         log_debug("%s: unknown '%c'", __func__, ictx->ch);                          log_debug("%s: unknown '%c'", __func__, ictx->ch);
Line 1556 
Line 1560 
 static void  static void
 input_csi_dispatch_rm_private(struct input_ctx *ictx)  input_csi_dispatch_rm_private(struct input_ctx *ictx)
 {  {
           struct screen_write_ctx *sctx = &ictx->ctx;
         struct window_pane      *wp = ictx->wp;          struct window_pane      *wp = ictx->wp;
         u_int                    i;          u_int                    i;
   
Line 1564 
Line 1569 
                 case -1:                  case -1:
                         break;                          break;
                 case 1:         /* DECCKM */                  case 1:         /* DECCKM */
                         screen_write_mode_clear(&ictx->ctx, MODE_KCURSOR);                          screen_write_mode_clear(sctx, MODE_KCURSOR);
                         break;                          break;
                 case 3:         /* DECCOLM */                  case 3:         /* DECCOLM */
                         screen_write_cursormove(&ictx->ctx, 0, 0);                          screen_write_cursormove(sctx, 0, 0);
                         screen_write_clearscreen(&ictx->ctx,                          screen_write_clearscreen(sctx, ictx->cell.cell.bg);
                             ictx->cell.cell.bg);  
                         break;                          break;
                 case 6:         /* DECOM */                  case 6:         /* DECOM */
                         screen_write_mode_clear(&ictx->ctx, MODE_ORIGIN);                          screen_write_mode_clear(sctx, MODE_ORIGIN);
                         screen_write_cursormove(&ictx->ctx, 0, 0);                          screen_write_cursormove(sctx, 0, 0);
                         break;                          break;
                 case 7:         /* DECAWM */                  case 7:         /* DECAWM */
                         screen_write_mode_clear(&ictx->ctx, MODE_WRAP);                          screen_write_mode_clear(sctx, MODE_WRAP);
                         break;                          break;
                 case 12:                  case 12:
                         screen_write_mode_clear(&ictx->ctx, MODE_BLINKING);                          screen_write_mode_clear(sctx, MODE_BLINKING);
                         break;                          break;
                 case 25:        /* TCEM */                  case 25:        /* TCEM */
                         screen_write_mode_clear(&ictx->ctx, MODE_CURSOR);                          screen_write_mode_clear(sctx, MODE_CURSOR);
                         break;                          break;
                 case 1000:                  case 1000:
                 case 1001:                  case 1001:
                 case 1002:                  case 1002:
                 case 1003:                  case 1003:
                         screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES);                          screen_write_mode_clear(sctx, ALL_MOUSE_MODES);
                         break;                          break;
                 case 1004:                  case 1004:
                         screen_write_mode_clear(&ictx->ctx, MODE_FOCUSON);                          screen_write_mode_clear(sctx, MODE_FOCUSON);
                         break;                          break;
                 case 1005:                  case 1005:
                         screen_write_mode_clear(&ictx->ctx, MODE_MOUSE_UTF8);                          screen_write_mode_clear(sctx, MODE_MOUSE_UTF8);
                         break;                          break;
                 case 1006:                  case 1006:
                         screen_write_mode_clear(&ictx->ctx, MODE_MOUSE_SGR);                          screen_write_mode_clear(sctx, MODE_MOUSE_SGR);
                         break;                          break;
                 case 47:                  case 47:
                 case 1047:                  case 1047:
Line 1607 
Line 1611 
                         window_pane_alternate_off(wp, &ictx->cell.cell, 1);                          window_pane_alternate_off(wp, &ictx->cell.cell, 1);
                         break;                          break;
                 case 2004:                  case 2004:
                         screen_write_mode_clear(&ictx->ctx, MODE_BRACKETPASTE);                          screen_write_mode_clear(sctx, MODE_BRACKETPASTE);
                         break;                          break;
                 default:                  default:
                         log_debug("%s: unknown '%c'", __func__, ictx->ch);                          log_debug("%s: unknown '%c'", __func__, ictx->ch);
Line 1620 
Line 1624 
 static void  static void
 input_csi_dispatch_sm(struct input_ctx *ictx)  input_csi_dispatch_sm(struct input_ctx *ictx)
 {  {
         u_int   i;          struct screen_write_ctx *sctx = &ictx->ctx;
           u_int                    i;
   
         for (i = 0; i < ictx->param_list_len; i++) {          for (i = 0; i < ictx->param_list_len; i++) {
                 switch (input_get(ictx, i, 0, -1)) {                  switch (input_get(ictx, i, 0, -1)) {
                 case -1:                  case -1:
                         break;                          break;
                 case 4:         /* IRM */                  case 4:         /* IRM */
                         screen_write_mode_set(&ictx->ctx, MODE_INSERT);                          screen_write_mode_set(sctx, MODE_INSERT);
                         break;                          break;
                 case 34:                  case 34:
                         screen_write_mode_clear(&ictx->ctx, MODE_BLINKING);                          screen_write_mode_clear(sctx, MODE_BLINKING);
                         break;                          break;
                 default:                  default:
                         log_debug("%s: unknown '%c'", __func__, ictx->ch);                          log_debug("%s: unknown '%c'", __func__, ictx->ch);
Line 1643 
Line 1648 
 static void  static void
 input_csi_dispatch_sm_private(struct input_ctx *ictx)  input_csi_dispatch_sm_private(struct input_ctx *ictx)
 {  {
           struct screen_write_ctx *sctx = &ictx->ctx;
         struct window_pane      *wp = ictx->wp;          struct window_pane      *wp = ictx->wp;
         u_int                    i;          u_int                    i;
   
Line 1651 
Line 1657 
                 case -1:                  case -1:
                         break;                          break;
                 case 1:         /* DECCKM */                  case 1:         /* DECCKM */
                         screen_write_mode_set(&ictx->ctx, MODE_KCURSOR);                          screen_write_mode_set(sctx, MODE_KCURSOR);
                         break;                          break;
                 case 3:         /* DECCOLM */                  case 3:         /* DECCOLM */
                         screen_write_cursormove(&ictx->ctx, 0, 0);                          screen_write_cursormove(sctx, 0, 0);
                         screen_write_clearscreen(&ictx->ctx,                          screen_write_clearscreen(sctx, ictx->cell.cell.bg);
                             ictx->cell.cell.bg);  
                         break;                          break;
                 case 6:         /* DECOM */                  case 6:         /* DECOM */
                         screen_write_mode_set(&ictx->ctx, MODE_ORIGIN);                          screen_write_mode_set(sctx, MODE_ORIGIN);
                         screen_write_cursormove(&ictx->ctx, 0, 0);                          screen_write_cursormove(sctx, 0, 0);
                         break;                          break;
                 case 7:         /* DECAWM */                  case 7:         /* DECAWM */
                         screen_write_mode_set(&ictx->ctx, MODE_WRAP);                          screen_write_mode_set(sctx, MODE_WRAP);
                         break;                          break;
                 case 12:                  case 12:
                         screen_write_mode_set(&ictx->ctx, MODE_BLINKING);                          screen_write_mode_set(sctx, MODE_BLINKING);
                         break;                          break;
                 case 25:        /* TCEM */                  case 25:        /* TCEM */
                         screen_write_mode_set(&ictx->ctx, MODE_CURSOR);                          screen_write_mode_set(sctx, MODE_CURSOR);
                         break;                          break;
                 case 1000:                  case 1000:
                         screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES);                          screen_write_mode_clear(sctx, ALL_MOUSE_MODES);
                         screen_write_mode_set(&ictx->ctx, MODE_MOUSE_STANDARD);                          screen_write_mode_set(sctx, MODE_MOUSE_STANDARD);
                         break;                          break;
                 case 1002:                  case 1002:
                         screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES);                          screen_write_mode_clear(sctx, ALL_MOUSE_MODES);
                         screen_write_mode_set(&ictx->ctx, MODE_MOUSE_BUTTON);                          screen_write_mode_set(sctx, MODE_MOUSE_BUTTON);
                         break;                          break;
                 case 1003:                  case 1003:
                         screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES);                          screen_write_mode_clear(sctx, ALL_MOUSE_MODES);
                         screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ALL);                          screen_write_mode_set(sctx, MODE_MOUSE_ALL);
                         break;                          break;
                 case 1004:                  case 1004:
                         if (ictx->ctx.s->mode & MODE_FOCUSON)                          if (sctx->s->mode & MODE_FOCUSON)
                                 break;                                  break;
                         screen_write_mode_set(&ictx->ctx, MODE_FOCUSON);                          screen_write_mode_set(sctx, MODE_FOCUSON);
                         wp->flags |= PANE_FOCUSPUSH; /* force update */                          wp->flags |= PANE_FOCUSPUSH; /* force update */
                         break;                          break;
                 case 1005:                  case 1005:
                         screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8);                          screen_write_mode_set(sctx, MODE_MOUSE_UTF8);
                         break;                          break;
                 case 1006:                  case 1006:
                         screen_write_mode_set(&ictx->ctx, MODE_MOUSE_SGR);                          screen_write_mode_set(sctx, MODE_MOUSE_SGR);
                         break;                          break;
                 case 47:                  case 47:
                 case 1047:                  case 1047:
Line 1703 
Line 1708 
                         window_pane_alternate_on(wp, &ictx->cell.cell, 1);                          window_pane_alternate_on(wp, &ictx->cell.cell, 1);
                         break;                          break;
                 case 2004:                  case 2004:
                         screen_write_mode_set(&ictx->ctx, MODE_BRACKETPASTE);                          screen_write_mode_set(sctx, MODE_BRACKETPASTE);
                         break;                          break;
                 default:                  default:
                         log_debug("%s: unknown '%c'", __func__, ictx->ch);                          log_debug("%s: unknown '%c'", __func__, ictx->ch);
Line 1716 
Line 1721 
 static void  static void
 input_csi_dispatch_winops(struct input_ctx *ictx)  input_csi_dispatch_winops(struct input_ctx *ictx)
 {  {
           struct screen_write_ctx *sctx = &ictx->ctx;
         struct window_pane      *wp = ictx->wp;          struct window_pane      *wp = ictx->wp;
         int                      n, m;          int                      n, m;
   
Line 1755 
Line 1761 
                                 return;                                  return;
                         case 0:                          case 0:
                         case 2:                          case 2:
                                 screen_push_title(ictx->ctx.s);                                  screen_push_title(sctx->s);
                                 break;                                  break;
                         }                          }
                         break;                          break;
Line 1766 
Line 1772 
                                 return;                                  return;
                         case 0:                          case 0:
                         case 2:                          case 2:
                                 screen_pop_title(ictx->ctx.s);                                  screen_pop_title(sctx->s);
                                 server_status_window(ictx->wp->window);                                  server_status_window(ictx->wp->window);
                                 break;                                  break;
                         }                          }
Line 2089 
Line 2095 
 static int  static int
 input_dcs_dispatch(struct input_ctx *ictx)  input_dcs_dispatch(struct input_ctx *ictx)
 {  {
         const char      prefix[] = "tmux;";          struct screen_write_ctx *sctx = &ictx->ctx;
         const u_int     prefix_len = (sizeof prefix) - 1;          u_char                  *buf = ictx->input_buf;
           size_t                   len = ictx->input_len;
           const char               prefix[] = "tmux;";
           const u_int              prefixlen = (sizeof prefix) - 1;
   
         if (ictx->flags & INPUT_DISCARD)          if (ictx->flags & INPUT_DISCARD)
                 return (0);                  return (0);
   
         log_debug("%s: \"%s\"", __func__, ictx->input_buf);          log_debug("%s: \"%s\"", __func__, buf);
   
         /* Check for tmux prefix. */          if (len >= prefixlen && strncmp(buf, prefix, prefixlen) == 0)
         if (ictx->input_len >= prefix_len &&                  screen_write_rawstring(sctx, buf + prefixlen, len - prefixlen);
             strncmp(ictx->input_buf, prefix, prefix_len) == 0) {  
                 screen_write_rawstring(&ictx->ctx,  
                     ictx->input_buf + prefix_len, ictx->input_len - prefix_len);  
         }  
   
         return (0);          return (0);
 }  }
Line 2122 
Line 2127 
 static void  static void
 input_exit_osc(struct input_ctx *ictx)  input_exit_osc(struct input_ctx *ictx)
 {  {
         u_char  *p = ictx->input_buf;          struct screen_write_ctx *sctx = &ictx->ctx;
         u_int    option;          u_char                  *p = ictx->input_buf;
           u_int                    option;
   
         if (ictx->flags & INPUT_DISCARD)          if (ictx->flags & INPUT_DISCARD)
                 return;                  return;
Line 2143 
Line 2149 
         case 0:          case 0:
         case 2:          case 2:
                 if (utf8_isvalid(p)) {                  if (utf8_isvalid(p)) {
                         screen_set_title(ictx->ctx.s, p);                          screen_set_title(sctx->s, p);
                         server_status_window(ictx->wp->window);                          server_status_window(ictx->wp->window);
                 }                  }
                 break;                  break;
Line 2158 
Line 2164 
                 break;                  break;
         case 12:          case 12:
                 if (utf8_isvalid(p) && *p != '?') /* ? is colour request */                  if (utf8_isvalid(p) && *p != '?') /* ? is colour request */
                         screen_set_cursor_colour(ictx->ctx.s, p);                          screen_set_cursor_colour(sctx->s, p);
                 break;                  break;
         case 52:          case 52:
                 input_osc_52(ictx, p);                  input_osc_52(ictx, p);
Line 2168 
Line 2174 
                 break;                  break;
         case 112:          case 112:
                 if (*p == '\0') /* no arguments allowed */                  if (*p == '\0') /* no arguments allowed */
                         screen_set_cursor_colour(ictx->ctx.s, "");                          screen_set_cursor_colour(sctx->s, "");
                 break;                  break;
         default:          default:
                 log_debug("%s: unknown '%u'", __func__, option);                  log_debug("%s: unknown '%u'", __func__, option);
Line 2191 
Line 2197 
 static void  static void
 input_exit_apc(struct input_ctx *ictx)  input_exit_apc(struct input_ctx *ictx)
 {  {
           struct screen_write_ctx *sctx = &ictx->ctx;
   
         if (ictx->flags & INPUT_DISCARD)          if (ictx->flags & INPUT_DISCARD)
                 return;                  return;
         log_debug("%s: \"%s\"", __func__, ictx->input_buf);          log_debug("%s: \"%s\"", __func__, ictx->input_buf);
   
         if (!utf8_isvalid(ictx->input_buf))          if (!utf8_isvalid(ictx->input_buf))
                 return;                  return;
         screen_set_title(ictx->ctx.s, ictx->input_buf);          screen_set_title(sctx->s, ictx->input_buf);
         server_status_window(ictx->wp->window);          server_status_window(ictx->wp->window);
 }  }
   
Line 2233 
Line 2241 
 static int  static int
 input_top_bit_set(struct input_ctx *ictx)  input_top_bit_set(struct input_ctx *ictx)
 {  {
           struct screen_write_ctx *sctx = &ictx->ctx;
         struct utf8_data        *ud = &ictx->utf8data;          struct utf8_data        *ud = &ictx->utf8data;
   
         ictx->last = -1;          ictx->last = -1;
Line 2259 
Line 2268 
             (int)ud->size, ud->data, ud->width);              (int)ud->size, ud->data, ud->width);
   
         utf8_copy(&ictx->cell.cell.data, ud);          utf8_copy(&ictx->cell.cell.data, ud);
         screen_write_collect_add(&ictx->ctx, &ictx->cell.cell);          screen_write_collect_add(sctx, &ictx->cell.cell);
   
         return (0);          return (0);
 }  }
Line 2270 
Line 2279 
 {  {
         struct window_pane      *wp = ictx->wp;          struct window_pane      *wp = ictx->wp;
         char                    *copy, *s, *next = NULL;          char                    *copy, *s, *next = NULL;
         long                    idx;          long                     idx;
         u_int                    r, g, b;          u_int                    r, g, b;
   
         copy = s = xstrdup(p);          copy = s = xstrdup(p);
Line 2410 
Line 2419 
 {  {
         struct window_pane      *wp = ictx->wp;          struct window_pane      *wp = ictx->wp;
         char                    *copy, *s;          char                    *copy, *s;
         long                    idx;          long                     idx;
   
         if (*p == '\0') {          if (*p == '\0') {
                 window_pane_reset_palette(wp);                  window_pane_reset_palette(wp);

Legend:
Removed from v.1.143  
changed lines
  Added in v.1.144