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

Diff for /src/usr.bin/tmux/menu.c between version 1.5 and 1.6

version 1.5, 2019/05/23 11:13:30 version 1.6, 2019/05/26 17:34:45
Line 41 
Line 41 
 };  };
   
 static void  static void
 menu_add_item(struct menu *menu, struct menu_item *item, struct client *c,  menu_add_item(struct menu *menu, struct menu_item *item,
     struct cmd_find_state *fs)      struct cmdq_item *qitem, struct client *c, struct cmd_find_state *fs)
 {  {
         struct menu_item        *new_item;          struct menu_item        *new_item;
         const char              *key;          const char              *key;
Line 57 
Line 57 
         if (item == NULL || *item->name == '\0') /* horizontal line */          if (item == NULL || *item->name == '\0') /* horizontal line */
                 return;                  return;
         if (fs != NULL) {          if (fs != NULL) {
                 name = format_single(NULL, item->name, c, fs->s, fs->wl,                  name = format_single(qitem, item->name, c, fs->s, fs->wl,
                     fs->wp);                      fs->wp);
         } else          } else
                 name = xstrdup(item->name);                  name = format_single(qitem, item->name, c, NULL, NULL, NULL);
         if (*name == '\0') { /* no item if empty after format expanded */          if (*name == '\0') { /* no item if empty after format expanded */
                 menu->count--;                  menu->count--;
                 return;                  return;
         }          }
         if (item->key != KEYC_UNKNOWN) {          if (item->key != KEYC_UNKNOWN) {
                 key = key_string_lookup_key(item->key);                  key = key_string_lookup_key(item->key);
                 xasprintf(&new_item->name, "%s #[align=right](%s)", name, key);                  xasprintf(&new_item->name, "%s#[default] #[align=right](%s)",
                       name, key);
         } else          } else
                 xasprintf(&new_item->name, "%s", name);                  xasprintf(&new_item->name, "%s", name);
         free(name);          free(name);
   
         if (item->command != NULL)          if (item->command != NULL) {
                 new_item->command = xstrdup(item->command);                  if (fs != NULL) {
         else                          new_item->command = format_single(qitem, item->command,
                               c, fs->s, fs->wl, fs->wp);
                   } else {
                           new_item->command = format_single(qitem, item->command,
                               c, NULL, NULL, NULL);
                   }
           } else
                 new_item->command = NULL;                  new_item->command = NULL;
         new_item->key = item->key;          new_item->key = item->key;
   
Line 84 
Line 91 
 }  }
   
 static void  static void
 menu_parse_item(struct menu *menu, const char *s, struct client *c,  menu_parse_item(struct menu *menu, const char *s, struct cmdq_item *qitem,
     struct cmd_find_state *fs)      struct client *c, struct cmd_find_state *fs)
 {  {
         char                    *copy, *first;          char                    *copy, *first;
         const char              *second, *third;          const char              *second, *third;
Line 100 
Line 107 
                         item.name = first;                          item.name = first;
                         item.command = (char *)third;                          item.command = (char *)third;
                         item.key = key_string_lookup_string(second);                          item.key = key_string_lookup_string(second);
                         menu_add_item(menu, &item, c, fs);                          menu_add_item(menu, &item, qitem, c, fs);
                 }                  }
         }          }
         free(copy);          free(copy);
 }  }
   
 struct menu *  struct menu *
 menu_create(const char *s, struct client *c, struct cmd_find_state *fs,  menu_create(const char *s, struct cmdq_item *qitem, struct client *c,
     const char *title)      struct cmd_find_state *fs, const char *title)
 {  {
         struct menu     *menu;          struct menu     *menu;
         char            *copy, *string, *next;          char            *copy, *string, *next;
Line 124 
Line 131 
                 next = (char *)format_skip(string, "|");                  next = (char *)format_skip(string, "|");
                 if (next != NULL)                  if (next != NULL)
                         *next++ = '\0';                          *next++ = '\0';
                 if (*string == '\0')                  if (*string == '\0') {
                         menu_add_item(menu, NULL, c, fs);                          if (menu->count != 0)
                 else                                  menu_add_item(menu, NULL, qitem, c, fs);
                         menu_parse_item(menu, string, c, fs);                  } else
                           menu_parse_item(menu, string, qitem, c, fs);
                 string = next;                  string = next;
         } while (next != NULL);          } while (next != NULL);
         free(copy);          free(copy);
Line 283 
Line 291 
                 cmdq_append(c, new_item);                  cmdq_append(c, new_item);
                 break;                  break;
         case CMD_PARSE_SUCCESS:          case CMD_PARSE_SUCCESS:
                 new_item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);                  if (md->item != NULL)
                           m = &md->item->shared->mouse;
                   else
                           m = NULL;
                   new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0);
                 cmd_list_free(pr->cmdlist);                  cmd_list_free(pr->cmdlist);
                 cmdq_append(c, new_item);                  cmdq_append(c, new_item);
                 break;                  break;

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