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

Diff for /src/usr.bin/tmux/Attic/cmd-choose-session.c between version 1.4 and 1.5

version 1.4, 2009/07/26 12:58:44 version 1.5, 2009/08/25 12:18:51
Line 27 
Line 27 
 int     cmd_choose_session_exec(struct cmd *, struct cmd_ctx *);  int     cmd_choose_session_exec(struct cmd *, struct cmd_ctx *);
   
 void    cmd_choose_session_callback(void *, int);  void    cmd_choose_session_callback(void *, int);
   void    cmd_choose_session_free(void *);
   
 const struct cmd_entry cmd_choose_session_entry = {  const struct cmd_entry cmd_choose_session_entry = {
         "choose-session", NULL,          "choose-session", NULL,
         CMD_TARGET_WINDOW_USAGE,          CMD_TARGET_WINDOW_USAGE " [template]",
         0, 0,          CMD_ARG01, 0,
         cmd_target_init,          cmd_target_init,
         cmd_target_parse,          cmd_target_parse,
         cmd_choose_session_exec,          cmd_choose_session_exec,
Line 40 
Line 41 
 };  };
   
 struct cmd_choose_session_data {  struct cmd_choose_session_data {
         u_int   client;          u_int            client;
           char            *template;
 };  };
   
 int  int
Line 79 
Line 81 
         }          }
   
         cdata = xmalloc(sizeof *cdata);          cdata = xmalloc(sizeof *cdata);
           if (data->arg != NULL)
                   cdata->template = xstrdup(data->arg);
           else
                   cdata->template = xstrdup("switch-client -t '%%'");
         cdata->client = server_client_index(ctx->curclient);          cdata->client = server_client_index(ctx->curclient);
   
         window_choose_ready(          window_choose_ready(wl->window->active,
             wl->window->active, cur, cmd_choose_session_callback, xfree, cdata);              cur, cmd_choose_session_callback, cmd_choose_session_free, cdata);
   
         return (0);          return (0);
 }  }
Line 92 
Line 98 
 {  {
         struct cmd_choose_session_data  *cdata = data;          struct cmd_choose_session_data  *cdata = data;
         struct client                   *c;          struct client                   *c;
           struct session                  *s;
           struct cmd_list                 *cmdlist;
           struct cmd_ctx                   ctx;
           char                            *template, *cause;
   
         if (idx != -1 && cdata->client <= ARRAY_LENGTH(&clients) - 1) {          if (idx == -1)
                 c = ARRAY_ITEM(&clients, cdata->client);                  return;
                 if (c != NULL && (u_int) idx <= ARRAY_LENGTH(&sessions) - 1) {          if (cdata->client > ARRAY_LENGTH(&clients) - 1)
                         c->session = ARRAY_ITEM(&sessions, idx);                  return;
                         recalculate_sizes();          c = ARRAY_ITEM(&clients, cdata->client);
                         server_redraw_client(c);  
           if ((u_int) idx > ARRAY_LENGTH(&sessions) - 1)
                   return;
           s = ARRAY_ITEM(&sessions, idx);
           if (s == NULL)
                   return;
           template = cmd_template_replace(cdata->template, s->name, 1);
   
           if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
                   if (cause != NULL) {
                           *cause = toupper((u_char) *cause);
                           status_message_set(c, "%s", cause);
                           xfree(cause);
                 }                  }
                   xfree(template);
                   return;
         }          }
           xfree(template);
   
           ctx.msgdata = NULL;
           ctx.curclient = c;
   
           ctx.error = key_bindings_error;
           ctx.print = key_bindings_print;
           ctx.info = key_bindings_info;
   
           ctx.cmdclient = NULL;
   
           cmd_list_exec(cmdlist, &ctx);
           cmd_list_free(cmdlist);
   }
   
   void
   cmd_choose_session_free(void *data)
   {
           struct cmd_choose_session_data  *cdata = data;
   
           xfree(cdata->template);
           xfree(cdata);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5