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

Diff for /src/usr.bin/tmux/cmd.c between version 1.37 and 1.38

version 1.37, 2010/01/07 20:52:18 version 1.38, 2010/01/19 21:27:47
Line 702 
Line 702 
   
         /*          /*
          * Then work out the window. An empty string is the current window,           * Then work out the window. An empty string is the current window,
          * otherwise try to look it up in the session.           * otherwise try special cases then to look it up in the session.
          */           */
         if (*winptr == '\0')          if (*winptr == '\0')
                 wl = s->curw;                  wl = s->curw;
         else if ((wl = cmd_lookup_window(s, winptr, &ambiguous)) == NULL)          else if (winptr[0] == '!' && winptr[1] == '\0')
                   wl = TAILQ_FIRST(&s->lastw);
           else if (winptr[0] == '+' && winptr[1] == '\0')
                   wl = winlink_next(s->curw);
           else if (winptr[0] == '-' && winptr[1] == '\0')
                   wl = winlink_previous(s->curw);
           else
                   wl = cmd_lookup_window(s, winptr, &ambiguous);
           if (wl == NULL)
                 goto not_found;                  goto not_found;
   
         if (sessptr != NULL)          if (sessptr != NULL)
Line 714 
Line 722 
         return (wl);          return (wl);
   
 no_colon:  no_colon:
         /* No colon in the string, first try as a window then as a session. */          /*
         if ((wl = cmd_lookup_window(s, arg, &ambiguous)) == NULL) {           * No colon in the string, first try special cases, then as a window
            * and lastly as a session.
            */
           if (arg[0] == '!' && arg[1] == '\0') {
                   if ((wl = TAILQ_FIRST(&s->lastw)) == NULL)
                           goto not_found;
           } else if (arg[0] == '+' && arg[1] == '\0') {
                   if ((wl = winlink_next(s->curw)) == NULL)
                           goto not_found;
           } else if (arg[0] == '-' && arg[1] == '\0') {
                   if ((wl = winlink_previous(s->curw)) == NULL)
                           goto not_found;
           } else if ((wl = cmd_lookup_window(s, arg, &ambiguous)) == NULL) {
                 if (ambiguous)                  if (ambiguous)
                         goto not_found;                          goto not_found;
                 if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)                  if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)
Line 757 
Line 777 
 cmd_find_index(struct cmd_ctx *ctx, const char *arg, struct session **sp)  cmd_find_index(struct cmd_ctx *ctx, const char *arg, struct session **sp)
 {  {
         struct session  *s;          struct session  *s;
           struct winlink  *wl;
         const char      *winptr;          const char      *winptr;
         char            *sessptr = NULL;          char            *sessptr = NULL;
         int              idx, ambiguous = 0;          int              idx, ambiguous = 0;
Line 802 
Line 823 
          * try to look it up in the session.           * try to look it up in the session.
          */           */
         if (*winptr == '\0')          if (*winptr == '\0')
                  idx = -1;                  idx = -1;
         else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1) {          else if (winptr[0] == '!' && winptr[1] == '\0') {
                   if ((wl = TAILQ_FIRST(&s->lastw)) == NULL)
                           goto not_found;
                   idx = wl->idx;
           } else if (winptr[0] == '+' && winptr[1] == '\0') {
                   if (s->curw->idx == INT_MAX)
                           goto not_found;
                   idx = s->curw->idx + 1;
           } else if (winptr[0] == '-' && winptr[1] == '\0') {
                   if (s->curw->idx == 0)
                           goto not_found;
                   idx = s->curw->idx - 1;
           } else if ((idx = cmd_lookup_index(s, winptr, &ambiguous)) == -1) {
                 if (ambiguous)                  if (ambiguous)
                         goto not_found;                          goto not_found;
                 ctx->error(ctx, "invalid index: %s", arg);                  ctx->error(ctx, "invalid index: %s", arg);
Line 815 
Line 848 
         return (idx);          return (idx);
   
 no_colon:  no_colon:
         /* No colon in the string, first try as a window then as a session. */          /*
         if ((idx = cmd_lookup_index(s, arg, &ambiguous)) == -1) {           * No colon in the string, first try special cases, then as a window
            * and lastly as a session.
            */
           if (arg[0] == '!' && arg[1] == '\0') {
                   if ((wl = TAILQ_FIRST(&s->lastw)) == NULL)
                           goto not_found;
                   idx = wl->idx;
           } else if (arg[0] == '+' && arg[1] == '\0') {
                   if (s->curw->idx == INT_MAX)
                           goto not_found;
                   idx = s->curw->idx + 1;
           } else if (arg[0] == '-' && arg[1] == '\0') {
                   if (s->curw->idx == 0)
                           goto not_found;
                   idx = s->curw->idx - 1;
           } else if ((idx = cmd_lookup_index(s, arg, &ambiguous)) == -1) {
                 if (ambiguous)                  if (ambiguous)
                         goto not_found;                          goto not_found;
                 if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)                  if ((s = cmd_lookup_session(arg, &ambiguous)) == NULL)

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38