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

Diff for /src/usr.bin/tmux/cmd-show-options.c between version 1.47 and 1.48

version 1.47, 2019/04/25 18:18:55 version 1.48, 2019/04/26 11:38:51
Line 39 
Line 39 
         .name = "show-options",          .name = "show-options",
         .alias = "show",          .alias = "show",
   
         .args = { "gqst:vw", 0, 1 },          .args = { "gHqst:vw", 0, 1 },
         .usage = "[-gqsvw] [-t target-session|target-window] [option]",          .usage = "[-gHqsvw] [-t target-session|target-window] [option]",
   
         .target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },          .target = { 't', CMD_FIND_WINDOW, CMD_FIND_CANFAIL },
   
Line 61 
Line 61 
         .exec = cmd_show_options_exec          .exec = cmd_show_options_exec
 };  };
   
   const struct cmd_entry cmd_show_hooks_entry = {
           .name = "show-hooks",
           .alias = NULL,
   
           .args = { "gt:", 0, 1 },
           .usage = "[-g] " CMD_TARGET_SESSION_USAGE,
   
           .target = { 't', CMD_FIND_SESSION, 0 },
   
           .flags = CMD_AFTERHOOK,
           .exec = cmd_show_options_exec
   };
   
 static enum cmd_retval  static enum cmd_retval
 cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)  cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
 {  {
Line 162 
Line 175 
     struct options_entry *o, int idx)      struct options_entry *o, int idx)
 {  {
         struct options_array_item       *a;          struct options_array_item       *a;
         const char                      *name;          const char                      *name = options_name(o);
         char                            *value, *tmp, *escaped;          char                            *value, *tmp = NULL, *escaped;
   
         if (idx != -1) {          if (idx != -1) {
                 xasprintf(&tmp, "%s[%d]", options_name(o), idx);                  xasprintf(&tmp, "%s[%d]", name, idx);
                 name = tmp;                  name = tmp;
         } else {          } else {
                 if (options_isarray(o)) {                  if (options_isarray(o)) {
                         a = options_array_first(o);                          a = options_array_first(o);
                           if (a == NULL) {
                                   if (!args_has(self->args, 'v'))
                                           cmdq_print(item, "%s", name);
                                   return;
                           }
                         while (a != NULL) {                          while (a != NULL) {
                                 idx = options_array_item_index(a);                                  idx = options_array_item_index(a);
                                 cmd_show_options_print(self, item, o, idx);                                  cmd_show_options_print(self, item, o, idx);
Line 178 
Line 196 
                         }                          }
                         return;                          return;
                 }                  }
                 tmp = NULL;  
                 name = options_name(o);  
         }          }
   
         value = options_tostring(o, idx, 0);          value = options_tostring(o, idx, 0);
Line 200 
Line 216 
 cmd_show_options_all(struct cmd *self, struct cmdq_item *item,  cmd_show_options_all(struct cmd *self, struct cmdq_item *item,
     struct options *oo)      struct options *oo)
 {  {
         struct options_entry                    *o;          struct options_entry            *o;
         struct options_array_item               *a;          struct options_array_item       *a;
         u_int                                    idx;          u_int                            idx;
           int                              flags;
   
         o = options_first(oo);          o = options_first(oo);
         while (o != NULL) {          while (o != NULL) {
                   flags = options_table_entry(o)->flags;
                   if ((self->entry != &cmd_show_hooks_entry &&
                       !args_has(self->args, 'H') &&
                       (flags & OPTIONS_TABLE_IS_HOOK)) ||
                       (self->entry == &cmd_show_hooks_entry &&
                       (~flags & OPTIONS_TABLE_IS_HOOK))) {
                           o = options_next(o);
                           continue;
                   }
                 if (!options_isarray(o))                  if (!options_isarray(o))
                         cmd_show_options_print(self, item, o, -1);                          cmd_show_options_print(self, item, o, -1);
                 else {                  else if ((a = options_array_first(o)) == NULL) {
                         a = options_array_first(o);                          if (!args_has(self->args, 'v'))
                                   cmdq_print(item, "%s", options_name(o));
                   } else {
                         while (a != NULL) {                          while (a != NULL) {
                                 idx = options_array_item_index(a);                                  idx = options_array_item_index(a);
                                 cmd_show_options_print(self, item, o, idx);                                  cmd_show_options_print(self, item, o, idx);

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48