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

Diff for /src/usr.bin/tmux/cmd-display-menu.c between version 1.13 and 1.14

version 1.13, 2020/04/13 08:26:27 version 1.14, 2020/04/13 10:59:58
Line 65 
Line 65 
 cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,  cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
     struct args *args, u_int *px, u_int *py, u_int w, u_int h)      struct args *args, u_int *px, u_int *py, u_int w, u_int h)
 {  {
           struct cmdq_shared      *shared = cmdq_get_shared(item);
           struct cmd_find_state   *target = cmdq_get_target(item);
         struct session          *s = c->session;          struct session          *s = c->session;
         struct winlink          *wl = item->target.wl;          struct winlink          *wl = target->wl;
         struct window_pane      *wp = item->target.wp;          struct window_pane      *wp = target->wp;
         struct style_ranges     *ranges;          struct style_ranges     *ranges;
         struct style_range      *sr;          struct style_range      *sr;
         const char              *xp, *yp;          const char              *xp, *yp;
Line 97 
Line 99 
                         *px = wp->xoff - ox;                          *px = wp->xoff - ox;
                 else                  else
                         *px = 0;                          *px = 0;
         } else if (strcmp(xp, "M") == 0 && item->shared->mouse.valid) {          } else if (strcmp(xp, "M") == 0 && shared->mouse.valid) {
                 if (item->shared->mouse.x > w / 2)                  if (shared->mouse.x > w / 2)
                         *px = item->shared->mouse.x - w / 2;                          *px = shared->mouse.x - w / 2;
                 else                  else
                         *px = 0;                          *px = 0;
         } else if (strcmp(xp, "W") == 0) {          } else if (strcmp(xp, "W") == 0) {
Line 131 
Line 133 
                         *py = wp->yoff + wp->sy - oy;                          *py = wp->yoff + wp->sy - oy;
                 else                  else
                         *py = 0;                          *py = 0;
         } else if (strcmp(yp, "M") == 0 && item->shared->mouse.valid)          } else if (strcmp(yp, "M") == 0 && shared->mouse.valid)
                 *py = item->shared->mouse.y + h;                  *py = shared->mouse.y + h;
         else if (strcmp(yp, "S") == 0) {          else if (strcmp(yp, "S") == 0) {
                 if (options_get_number(s->options, "status-position") == 0) {                  if (options_get_number(s->options, "status-position") == 0) {
                         if (lines != 0)                          if (lines != 0)
Line 172 
Line 174 
 cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)  cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args             *args = cmd_get_args(self);          struct args             *args = cmd_get_args(self);
           struct cmdq_shared      *shared = cmdq_get_shared(item);
           struct cmd_find_state   *target = cmdq_get_target(item);
         struct client           *c;          struct client           *c;
         struct session          *s = item->target.s;  
         struct winlink          *wl = item->target.wl;  
         struct window_pane      *wp = item->target.wp;  
         struct cmd_find_state   *fs = &item->target;  
         struct menu             *menu = NULL;          struct menu             *menu = NULL;
         struct menu_item         menu_item;          struct menu_item         menu_item;
         const char              *key;          const char              *key;
Line 190 
Line 190 
                 return (CMD_RETURN_NORMAL);                  return (CMD_RETURN_NORMAL);
   
         if (args_has(args, 'T'))          if (args_has(args, 'T'))
                 title = format_single(item, args_get(args, 'T'), c, s, wl, wp);                  title = format_single_from_target(item, args_get(args, 'T'), c);
         else          else
                 title = xstrdup("");                  title = xstrdup("");
   
         menu = menu_create(title);          menu = menu_create(title);
   
         for (i = 0; i != args->argc; /* nothing */) {          for (i = 0; i != args->argc; /* nothing */) {
                 name = args->argv[i++];                  name = args->argv[i++];
                 if (*name == '\0') {                  if (*name == '\0') {
                         menu_add_item(menu, NULL, item, c, fs);                          menu_add_item(menu, NULL, item, c, target);
                         continue;                          continue;
                 }                  }
   
Line 215 
Line 214 
                 menu_item.key = key_string_lookup_string(key);                  menu_item.key = key_string_lookup_string(key);
                 menu_item.command = args->argv[i++];                  menu_item.command = args->argv[i++];
   
                 menu_add_item(menu, &menu_item, item, c, fs);                  menu_add_item(menu, &menu_item, item, c, target);
         }          }
         free(title);          free(title);
         if (menu == NULL) {          if (menu == NULL) {
Line 229 
Line 228 
         cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4,          cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4,
             menu->count + 2);              menu->count + 2);
   
         if (!item->shared->mouse.valid)          if (!shared->mouse.valid)
                 flags |= MENU_NOMOUSE;                  flags |= MENU_NOMOUSE;
         if (menu_display(menu, flags, item, px, py, c, fs, NULL, NULL) != 0)          if (menu_display(menu, flags, item, px, py, c, target, NULL, NULL) != 0)
                 return (CMD_RETURN_NORMAL);                  return (CMD_RETURN_NORMAL);
         return (CMD_RETURN_WAIT);          return (CMD_RETURN_WAIT);
 }  }
Line 240 
Line 239 
 cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)  cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args             *args = cmd_get_args(self);          struct args             *args = cmd_get_args(self);
           struct cmd_find_state   *target = cmdq_get_target(item);
         struct client           *c;          struct client           *c;
         struct cmd_find_state   *fs = &item->target;  
         const char              *value, *cmd = NULL, **lines = NULL;          const char              *value, *cmd = NULL, **lines = NULL;
         const char              *shellcmd = NULL;          const char              *shellcmd = NULL;
         char                    *cwd, *cause;          char                    *cwd, *cause;
Line 278 
Line 277 
         }          }
   
         if (nlines != 0)          if (nlines != 0)
                 w = popup_width(item, nlines, lines, c, fs) + 2;                  w = popup_width(item, nlines, lines, c, target) + 2;
         else          else
                 w = c->tty.sx / 2;                  w = c->tty.sx / 2;
         if (args_has(args, 'w')) {          if (args_has(args, 'w')) {
Line 298 
Line 297 
   
         value = args_get(args, 'd');          value = args_get(args, 'd');
         if (value != NULL)          if (value != NULL)
                 cwd = format_single(item, value, c, fs->s, fs->wl, fs->wp);                  cwd = format_single_from_target(item, value, c);
         else          else
                 cwd = xstrdup(server_client_get_cwd(c, fs->s));                  cwd = xstrdup(server_client_get_cwd(c, target->s));
   
         value = args_get(args, 'R');          value = args_get(args, 'R');
         if (value != NULL)          if (value != NULL)
                 shellcmd = format_single(item, value, c, fs->s, fs->wl, fs->wp);                  shellcmd = format_single_from_target(item, value, c);
   
         if (args_has(args, 'K'))          if (args_has(args, 'K'))
                 flags |= POPUP_WRITEKEYS;                  flags |= POPUP_WRITEKEYS;
Line 313 
Line 312 
         else if (args_has(args, 'E'))          else if (args_has(args, 'E'))
                 flags |= POPUP_CLOSEEXIT;                  flags |= POPUP_CLOSEEXIT;
         if (popup_display(flags, item, px, py, w, h, nlines, lines, shellcmd,          if (popup_display(flags, item, px, py, w, h, nlines, lines, shellcmd,
             cmd, cwd, c, fs) != 0)              cmd, cwd, c, target) != 0)
                 return (CMD_RETURN_NORMAL);                  return (CMD_RETURN_NORMAL);
         return (CMD_RETURN_WAIT);          return (CMD_RETURN_WAIT);
 }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14