[BACK]Return to cmd-switch-client.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-switch-client.c between version 1.7 and 1.8

version 1.7, 2010/09/26 20:43:30 version 1.8, 2010/12/11 18:39:25
Line 36 
Line 36 
 struct cmd_switch_client_data {  struct cmd_switch_client_data {
         char    *name;          char    *name;
         char    *target;          char    *target;
           int      flag_last;
         int      flag_next;          int      flag_next;
         int      flag_previous;          int      flag_previous;
 };  };
   
 const struct cmd_entry cmd_switch_client_entry = {  const struct cmd_entry cmd_switch_client_entry = {
         "switch-client", "switchc",          "switch-client", "switchc",
         "[-np] [-c target-client] [-t target-session]",          "[-lnp] [-c target-client] [-t target-session]",
         0, "",          0, "",
         cmd_switch_client_init,          cmd_switch_client_init,
         cmd_switch_client_parse,          cmd_switch_client_parse,
Line 59 
Line 60 
         self->data = data = xmalloc(sizeof *data);          self->data = data = xmalloc(sizeof *data);
         data->name = NULL;          data->name = NULL;
         data->target = NULL;          data->target = NULL;
           data->flag_last = 0;
         data->flag_next = 0;          data->flag_next = 0;
         data->flag_previous = 0;          data->flag_previous = 0;
   
Line 69 
Line 71 
         case ')':          case ')':
                 data->flag_next = 1;                  data->flag_next = 1;
                 break;                  break;
           case 'L':
                   data->flag_last = 1;
                   break;
         }          }
 }  }
   
Line 81 
Line 86 
         self->entry->init(self, KEYC_NONE);          self->entry->init(self, KEYC_NONE);
         data = self->data;          data = self->data;
   
         while ((opt = getopt(argc, argv, "c:t:")) != -1) {          while ((opt = getopt(argc, argv, "c:lnpt:")) != -1) {
                 switch (opt) {                  switch (opt) {
                 case 'c':                  case 'c':
                         if (data->name == NULL)                          if (data->name == NULL)
                                 data->name = xstrdup(optarg);                                  data->name = xstrdup(optarg);
                         break;                          break;
                 case 't':                  case 'l':
                         if (data->flag_next || data->flag_previous)                          if (data->flag_next || data->flag_previous ||
                               data->target != NULL)
                                 goto usage;                                  goto usage;
                         if (data->target == NULL)                          data->flag_last = 1;
                                 data->target = xstrdup(optarg);  
                         break;                          break;
                 case 'n':                  case 'n':
                         if (data->flag_previous || data->target != NULL)                          if (data->flag_previous || data->flag_last ||
                               data->target != NULL)
                                 goto usage;                                  goto usage;
                         data->flag_next = 1;                          data->flag_next = 1;
                         break;                          break;
                 case 'p':                  case 'p':
                         if (data->flag_next || data->target != NULL)                          if (data->flag_next || data->flag_last ||
                               data->target != NULL)
                                 goto usage;                                  goto usage;
                         data->flag_next = 1;                          data->flag_next = 1;
                         break;                          break;
                   case 't':
                           if (data->flag_next || data->flag_previous)
                                   goto usage;
                           if (data->target == NULL)
                                   data->target = xstrdup(optarg);
                           break;
                 default:                  default:
                         goto usage;                          goto usage;
                 }                  }
Line 134 
Line 147 
         if ((c = cmd_find_client(ctx, data->name)) == NULL)          if ((c = cmd_find_client(ctx, data->name)) == NULL)
                 return (-1);                  return (-1);
   
           s = NULL;
         if (data->flag_next) {          if (data->flag_next) {
                 if ((s = session_next_session(c->session)) == NULL) {                  if ((s = session_next_session(c->session)) == NULL) {
                         ctx->error(ctx, "can't find next session");                          ctx->error(ctx, "can't find next session");
Line 144 
Line 158 
                         ctx->error(ctx, "can't find previous session");                          ctx->error(ctx, "can't find previous session");
                         return (-1);                          return (-1);
                 }                  }
           } else if (data->flag_last) {
                   if (c->last_session != UINT_MAX &&
                       c->last_session < ARRAY_LENGTH(&sessions))
                           s = ARRAY_ITEM(&sessions, c->last_session);
                   if (s == NULL) {
                           ctx->error(ctx, "can't find last session");
                           return (-1);
                   }
         } else          } else
                 s = cmd_find_session(ctx, data->target);                  s = cmd_find_session(ctx, data->target);
   
         if (s == NULL)          if (s == NULL)
                 return (-1);                  return (-1);
   
           if (c->session != NULL)
                   session_index(c->session, &c->last_session);
         c->session = s;          c->session = s;
   
         recalculate_sizes();          recalculate_sizes();
Line 179 
Line 203 
         off += xsnprintf(buf, len, "%s", self->entry->name);          off += xsnprintf(buf, len, "%s", self->entry->name);
         if (data == NULL)          if (data == NULL)
                 return (off);                  return (off);
           if (off < len && data->flag_last)
                   off += xsnprintf(buf + off, len - off, "%s", " -l");
         if (off < len && data->flag_next)          if (off < len && data->flag_next)
                 off += xsnprintf(buf + off, len - off, "%s", " -n");                  off += xsnprintf(buf + off, len - off, "%s", " -n");
         if (off < len && data->flag_previous)          if (off < len && data->flag_previous)

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8