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

Diff for /src/usr.bin/tmux/cmd-split-window.c between version 1.112 and 1.113

version 1.112, 2022/03/08 22:14:25 version 1.113, 2022/06/07 10:02:19
Line 66 
Line 66 
         enum layout_type         type;          enum layout_type         type;
         struct layout_cell      *lc;          struct layout_cell      *lc;
         struct cmd_find_state    fs;          struct cmd_find_state    fs;
         int                      size, percentage, flags, input;          int                      size, flags, input;
         const char              *template, *errstr, *p;          const char              *template;
         char                    *cause, *cp, *copy;          char                    *cause = NULL, *cp;
         size_t                   plen;  
         struct args_value       *av;          struct args_value       *av;
         u_int                    count = args_count(args);          u_int                    count = args_count(args), curval = 0;
   
           type = LAYOUT_TOPBOTTOM;
         if (args_has(args, 'h'))          if (args_has(args, 'h'))
                 type = LAYOUT_LEFTRIGHT;                  type = LAYOUT_LEFTRIGHT;
         else  
                 type = LAYOUT_TOPBOTTOM;          /* If the 'p' flag is dropped then this bit can be moved into 'l'. */
         if ((p = args_get(args, 'l')) != NULL) {          if (args_has(args, 'l') || args_has(args, 'p')) {
                 plen = strlen(p);  
                 if (p[plen - 1] == '%') {  
                         copy = xstrdup(p);  
                         copy[plen - 1] = '\0';  
                         percentage = strtonum(copy, 0, INT_MAX, &errstr);  
                         free(copy);  
                         if (errstr != NULL) {  
                                 cmdq_error(item, "percentage %s", errstr);  
                                 return (CMD_RETURN_ERROR);  
                         }  
                         if (args_has(args, 'f')) {  
                                 if (type == LAYOUT_TOPBOTTOM)  
                                         size = (w->sy * percentage) / 100;  
                                 else  
                                         size = (w->sx * percentage) / 100;  
                         } else {  
                                 if (type == LAYOUT_TOPBOTTOM)  
                                         size = (wp->sy * percentage) / 100;  
                                 else  
                                         size = (wp->sx * percentage) / 100;  
                         }  
                 } else {  
                         size = args_strtonum(args, 'l', 0, INT_MAX, &cause);  
                         if (cause != NULL) {  
                                 cmdq_error(item, "lines %s", cause);  
                                 free(cause);  
                                 return (CMD_RETURN_ERROR);  
                         }  
                 }  
         } else if (args_has(args, 'p')) {  
                 percentage = args_strtonum(args, 'p', 0, INT_MAX, &cause);  
                 if (cause != NULL) {  
                         cmdq_error(item, "create pane failed: -p %s", cause);  
                         free(cause);  
                         return (CMD_RETURN_ERROR);  
                 }  
                 if (args_has(args, 'f')) {                  if (args_has(args, 'f')) {
                         if (type == LAYOUT_TOPBOTTOM)                          if (type == LAYOUT_TOPBOTTOM)
                                 size = (w->sy * percentage) / 100;                                  curval = w->sy;
                         else                          else
                                 size = (w->sx * percentage) / 100;                                  curval = w->sx;
                 } else {                  } else {
                         if (type == LAYOUT_TOPBOTTOM)                          if (type == LAYOUT_TOPBOTTOM)
                                 size = (wp->sy * percentage) / 100;                                  curval = wp->sy;
                         else                          else
                                 size = (wp->sx * percentage) / 100;                                  curval = wp->sx;
                 }                  }
         } else          }
                 size = -1;  
           size = -1;
           if (args_has(args, 'l')) {
                   size = args_percentage_and_expand(args, 'l', 0, INT_MAX, curval,
                              item, &cause);
           } else if (args_has(args, 'p')) {
                   size = args_strtonum_and_expand(args, 'l', 0, 100, item,
                               &cause);
                   if (cause == NULL)
                           size = curval * size / 100;
           }
           if (cause != NULL) {
                   cmdq_error(item, "size %s", cause);
                   free(cause);
                   return (CMD_RETURN_ERROR);
           }
   
         window_push_zoom(wp->window, 1, args_has(args, 'Z'));          window_push_zoom(wp->window, 1, args_has(args, 'Z'));
         input = (args_has(args, 'I') && count == 0);          input = (args_has(args, 'I') && count == 0);

Legend:
Removed from v.1.112  
changed lines
  Added in v.1.113