home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.2.185 < prev    next >
Encoding:
Internet Message Format  |  2004-01-17  |  15.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.185
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.185
  11. Problem:    Restoring a session with zero-height windows does not work
  12.         properly. (Charles Campbell)
  13. Solution:   Accept a zero argument to ":resize" as intended.  Add a window
  14.         number argument to ":resize" to be able to set the size of other
  15.         windows, because the current window cannot be zero-height.
  16.         Fix the explorer plugin to avoid changing the window sizes.  Add
  17.         the winrestcmd() function for this.
  18. Files:        runtime/doc/eval.txt, runtime/plugin/explorer.vim, src/eval.c,
  19.         src/ex_cmds.h, src/ex_docmd.c, src/proto/window.pro, src/window.c
  20.  
  21.  
  22. *** ../vim-6.2.184/runtime/doc/eval.txt    Sun Aug 10 22:31:29 2003
  23. --- runtime/doc/eval.txt    Sun Jan 18 20:38:41 2004
  24. ***************
  25. *** 1,4 ****
  26. ! *eval.txt*      For Vim version 6.2.  Last change: 2003 Aug 07
  27.   
  28.   
  29.             VIM REFERENCE MANUAL    by Bram Moolenaar
  30. --- 1,4 ----
  31. ! *eval.txt*      For Vim version 6.2.  Last change: 2004 Jan 18
  32.   
  33.   
  34.             VIM REFERENCE MANUAL    by Bram Moolenaar
  35. ***************
  36. *** 912,917 ****
  37. --- 919,925 ----
  38.   winheight( {nr})        Number    height of window {nr}
  39.   winline()            Number    window line of the cursor
  40.   winnr()                Number    number of current window
  41. + winrestcmd()            String  returns command to restore window sizes
  42.   winwidth( {nr})            Number    width of window {nr}
  43.   
  44.   append({lnum}, {string})                *append()*
  45. ***************
  46. *** 2594,2600 ****
  47.   
  48.                               *winnr()*
  49.   winnr()        The result is a Number, which is the number of the current
  50. !         window.  The top window has number 1.
  51.   
  52.   winwidth({nr})                        *winwidth()*
  53.           The result is a Number, which is the width of window {nr}.
  54. --- 2618,2634 ----
  55.   
  56.                               *winnr()*
  57.   winnr()        The result is a Number, which is the number of the current
  58. !         window.  The top window has number 1.  The number can be used
  59. !         with |CTRL-W_w| and ":wincmd w" |:wincmd|.
  60. !                             *winrestcmd()*
  61. ! winrestcmd()    Returns a sequence of |resize| commands that should restore
  62. !         the current window sizes.  Only works properly when no windows
  63. !         are opened or closed and the current window is unchanged.
  64. !         Example: >
  65. !             cmd = winrestcmd()
  66. !             call MessWithWindowSizes()
  67. !             exe cmd
  68.   
  69.   winwidth({nr})                        *winwidth()*
  70.           The result is a Number, which is the width of window {nr}.
  71. *** ../vim-6.2.184/runtime/plugin/explorer.vim    Fri May 16 19:25:21 2003
  72. --- runtime/plugin/explorer.vim    Fri Jan 16 20:23:31 2004
  73. ***************
  74. *** 1,14 ****
  75.   "=============================================================================
  76.   " File: explorer.vim
  77. ! " Author: M A Aziz Ahmed (aziz@acorn-networks.com)
  78. ! " Last Change:    2003 May 16
  79.   " Version: 2.5 + changes
  80.   " Additions by Mark Waggoner (waggoner@aracnet.com) et al.
  81.   "-----------------------------------------------------------------------------
  82. ! " This file implements a file explorer. Latest version available at:
  83. ! " http://www.freespeech.org/aziz/vim/
  84. ! " Updated version available at:
  85. ! " http://www.aracnet.com/~waggoner
  86.   "-----------------------------------------------------------------------------
  87.   " Normally, this file will reside in the plugins directory and be
  88.   " automatically sourced.  If not, you must manually source this file
  89. --- 1,11 ----
  90.   "=============================================================================
  91.   " File: explorer.vim
  92. ! " Author: M A Aziz Ahmed (aziz@acorn-networks.com - doesn't work)
  93. ! " Last Change:    2004 Jan 16
  94.   " Version: 2.5 + changes
  95.   " Additions by Mark Waggoner (waggoner@aracnet.com) et al.
  96.   "-----------------------------------------------------------------------------
  97. ! " This file implements a file explorer.
  98.   "-----------------------------------------------------------------------------
  99.   " Normally, this file will reside in the plugins directory and be
  100.   " automatically sourced.  If not, you must manually source this file
  101. ***************
  102. *** 1302,1315 ****
  103.     if winbufnr(2) == -1
  104.       return
  105.     endif
  106. !   let t = winnr()
  107.     while 1
  108.       wincmd w
  109. !     if winnr() == t
  110.         break
  111.       endif
  112.       call s:EditDir()
  113.     endwhile
  114.   endfunction
  115.   
  116.   "---
  117. --- 1299,1314 ----
  118.     if winbufnr(2) == -1
  119.       return
  120.     endif
  121. !   let cmd = winrestcmd()
  122. !   let curwin = winnr()
  123.     while 1
  124.       wincmd w
  125. !     if winnr() == curwin
  126.         break
  127.       endif
  128.       call s:EditDir()
  129.     endwhile
  130. +   exe cmd
  131.   endfunction
  132.   
  133.   "---
  134. *** ../vim-6.2.184/src/eval.c    Wed Nov 12 20:47:29 2003
  135. --- src/eval.c    Sun Jan 18 16:51:58 2004
  136. ***************
  137. *** 373,378 ****
  138. --- 373,379 ----
  139.   static void f_winheight __ARGS((VAR argvars, VAR retvar));
  140.   static void f_winline __ARGS((VAR argvars, VAR retvar));
  141.   static void f_winnr __ARGS((VAR argvars, VAR retvar));
  142. + static void f_winrestcmd __ARGS((VAR argvars, VAR retvar));
  143.   static void f_winwidth __ARGS((VAR argvars, VAR retvar));
  144.   static win_T *find_win_by_nr __ARGS((VAR vp));
  145.   static pos_T *var2fpos __ARGS((VAR varp, int lnum));
  146. ***************
  147. *** 2869,2874 ****
  148. --- 2870,2876 ----
  149.       {"winheight",    1, 1, f_winheight},
  150.       {"winline",        0, 0, f_winline},
  151.       {"winnr",        0, 0, f_winnr},
  152. +     {"winrestcmd",    0, 0, f_winrestcmd},
  153.       {"winwidth",    1, 1, f_winwidth},
  154.   };
  155.   
  156. ***************
  157. *** 7418,7423 ****
  158. --- 7420,7459 ----
  159.       ++nr;
  160.   #endif
  161.       retvar->var_val.var_number = nr;
  162. + }
  163. + /*
  164. +  * "winrestcmd()" function
  165. +  */
  166. + /* ARGSUSED */
  167. +     static void
  168. + f_winrestcmd(argvars, retvar)
  169. +     VAR        argvars;
  170. +     VAR        retvar;
  171. + {
  172. + #ifdef FEAT_WINDOWS
  173. +     win_T    *wp;
  174. +     int        winnr = 1;
  175. +     garray_T    ga;
  176. +     char_u    buf[50];
  177. +     ga_init2(&ga, (int)sizeof(char), 70);
  178. +     for (wp = firstwin; wp != NULL; wp = wp->w_next)
  179. +     {
  180. +     sprintf((char *)buf, "%dresize %d|", winnr, wp->w_height);
  181. +     ga_concat(&ga, buf);
  182. + # ifdef FEAT_VERTSPLIT
  183. +     sprintf((char *)buf, "vert %dresize %d|", winnr, wp->w_width);
  184. +     ga_concat(&ga, buf);
  185. + # endif
  186. +     ++winnr;
  187. +     }
  188. +     retvar->var_val.var_string = ga.ga_data;
  189. + #else
  190. +     retvar->var_val.var_string = NULL;
  191. + #endif
  192. +     retvar->var_type = VAR_STRING;
  193.   }
  194.   
  195.   /*
  196. *** ../vim-6.2.184/src/ex_cmds.h    Fri May 23 19:13:14 2003
  197. --- src/ex_cmds.h    Fri Jan 16 16:52:25 2004
  198. ***************
  199. *** 621,627 ****
  200.   EX(CMD_registers,    "registers",    ex_display,
  201.               EXTRA|NOTRLCOM|TRLBAR|CMDWIN),
  202.   EX(CMD_resize,        "resize",    ex_resize,
  203. !             TRLBAR|WORD1),
  204.   EX(CMD_retab,        "retab",    ex_retab,
  205.               TRLBAR|RANGE|WHOLEFOLD|DFLALL|BANG|WORD1|CMDWIN|MODIFY),
  206.   EX(CMD_return,        "return",    ex_return,
  207. --- 621,627 ----
  208.   EX(CMD_registers,    "registers",    ex_display,
  209.               EXTRA|NOTRLCOM|TRLBAR|CMDWIN),
  210.   EX(CMD_resize,        "resize",    ex_resize,
  211. !             RANGE|NOTADR|TRLBAR|WORD1),
  212.   EX(CMD_retab,        "retab",    ex_retab,
  213.               TRLBAR|RANGE|WHOLEFOLD|DFLALL|BANG|WORD1|CMDWIN|MODIFY),
  214.   EX(CMD_return,        "return",    ex_return,
  215. *** ../vim-6.2.184/src/ex_docmd.c    Mon Dec 29 20:39:18 2003
  216. --- src/ex_docmd.c    Fri Jan 16 17:20:17 2004
  217. ***************
  218. *** 6143,6148 ****
  219. --- 6188,6201 ----
  220.       exarg_T    *eap;
  221.   {
  222.       int        n;
  223. +     win_T    *wp = curwin;
  224. +     if (eap->addr_count > 0)
  225. +     {
  226. +     n = eap->line2;
  227. +     for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next)
  228. +         ;
  229. +     }
  230.   
  231.   #ifdef FEAT_GUI
  232.       need_mouse_correct = TRUE;
  233. ***************
  234. *** 6153,6170 ****
  235.       {
  236.       if (*eap->arg == '-' || *eap->arg == '+')
  237.           n += W_WIDTH(curwin);
  238. !     else if (n == 0)        /* default is very wide */
  239.           n = 9999;
  240. !     win_setwidth((int)n);
  241.       }
  242.       else
  243.   #endif
  244.       {
  245.       if (*eap->arg == '-' || *eap->arg == '+')
  246.           n += curwin->w_height;
  247. !     else if (n == 0)        /* default is very high */
  248.           n = 9999;
  249. !     win_setheight((int)n);
  250.       }
  251.   }
  252.   #endif
  253. --- 6206,6223 ----
  254.       {
  255.       if (*eap->arg == '-' || *eap->arg == '+')
  256.           n += W_WIDTH(curwin);
  257. !     else if (n == 0 && eap->arg[0] == NUL)    /* default is very wide */
  258.           n = 9999;
  259. !     win_setwidth_win((int)n, wp);
  260.       }
  261.       else
  262.   #endif
  263.       {
  264.       if (*eap->arg == '-' || *eap->arg == '+')
  265.           n += curwin->w_height;
  266. !     else if (n == 0 && eap->arg[0] == NUL)    /* default is very wide */
  267.           n = 9999;
  268. !     win_setheight_win((int)n, wp);
  269.       }
  270.   }
  271.   #endif
  272. ***************
  273. *** 8340,8371 ****
  274.        */
  275.       if (put_line(fd, "set winheight=1 winwidth=1") == FAIL)
  276.       return FAIL;
  277.       if (nr > 1)
  278.       {
  279.       if (restore_size && (ssop_flags & SSOP_WINSIZE))
  280.       {
  281.           for (wp = firstwin; wp != NULL; wp = wp->w_next)
  282.           {
  283.           if (!ses_do_win(wp))
  284.               continue;
  285.   
  286.           /* restore height when not full height */
  287.           if (wp->w_height + wp->w_status_height < topframe->fr_height
  288.               && (fprintf(fd,
  289. !                 "exe 'resize ' . ((&lines * %ld + %ld) / %ld)",
  290. !                 (long)wp->w_height, Rows / 2, Rows) < 0
  291.                                 || put_eol(fd) == FAIL))
  292.               return FAIL;
  293.   
  294.           /* restore width when not full width */
  295.           if (wp->w_width < Columns && (fprintf(fd,
  296. !             "exe 'vert resize ' . ((&columns * %ld + %ld) / %ld)",
  297. !                 (long)wp->w_width, Columns / 2, Columns) < 0
  298.                                 || put_eol(fd) == FAIL))
  299.               return FAIL;
  300. -         if (put_line(fd, "wincmd w") == FAIL)
  301. -             return FAIL;
  302.           }
  303.       }
  304.       else
  305. --- 8393,8448 ----
  306.        */
  307.       if (put_line(fd, "set winheight=1 winwidth=1") == FAIL)
  308.       return FAIL;
  309. +     /*
  310. +      * Restore the view of the window (options, file, cursor, etc.).
  311. +      */
  312. +     for (wp = firstwin; wp != NULL; wp = wp->w_next)
  313. +     {
  314. +     if (!ses_do_win(wp))
  315. +         continue;
  316. +     if (put_view(fd, wp, TRUE, &ssop_flags) == FAIL)
  317. +         return FAIL;
  318. +     if (nr > 1 && put_line(fd, "wincmd w") == FAIL)
  319. +         return FAIL;
  320. +     }
  321. +     /*
  322. +      * Restore cursor to the current window if it's not the first one.
  323. +      */
  324. +     if (cnr > 1 && (fprintf(fd, "%dwincmd w", cnr) < 0 || put_eol(fd) == FAIL))
  325. +     return FAIL;
  326. +     /*
  327. +      * Restore window sizes.  Do this after jumping around in windows, because
  328. +      * the current window has a minimum size while others may not.
  329. +      */
  330.       if (nr > 1)
  331.       {
  332.       if (restore_size && (ssop_flags & SSOP_WINSIZE))
  333.       {
  334. +         int        n = 0;
  335.           for (wp = firstwin; wp != NULL; wp = wp->w_next)
  336.           {
  337.           if (!ses_do_win(wp))
  338.               continue;
  339. +         ++n;
  340.   
  341.           /* restore height when not full height */
  342.           if (wp->w_height + wp->w_status_height < topframe->fr_height
  343.               && (fprintf(fd,
  344. !                   "exe '%dresize ' . ((&lines * %ld + %ld) / %ld)",
  345. !                 n, (long)wp->w_height, Rows / 2, Rows) < 0
  346.                                 || put_eol(fd) == FAIL))
  347.               return FAIL;
  348.   
  349.           /* restore width when not full width */
  350.           if (wp->w_width < Columns && (fprintf(fd,
  351. !                "exe 'vert %dresize ' . ((&columns * %ld + %ld) / %ld)",
  352. !                 n, (long)wp->w_width, Columns / 2, Columns) < 0
  353.                                 || put_eol(fd) == FAIL))
  354.               return FAIL;
  355.           }
  356.       }
  357.       else
  358. ***************
  359. *** 8375,8400 ****
  360.           return FAIL;
  361.       }
  362.       }
  363. -     /*
  364. -      * Restore the view of the window (options, file, cursor, etc.).
  365. -      */
  366. -     for (wp = firstwin; wp != NULL; wp = wp->w_next)
  367. -     {
  368. -     if (!ses_do_win(wp))
  369. -         continue;
  370. -     if (put_view(fd, wp, TRUE, &ssop_flags) == FAIL)
  371. -         return FAIL;
  372. -     if (nr > 1 && put_line(fd, "wincmd w") == FAIL)
  373. -         return FAIL;
  374. -     }
  375. -     /*
  376. -      * Restore cursor to the current window if it's not the first one.
  377. -      */
  378. -     if (cnr > 1 && (fprintf(fd, "%dwincmd w", cnr) < 0
  379. -                               || put_eol(fd) == FAIL))
  380. -     return FAIL;
  381.   
  382.       /* Re-apply 'winheight', 'winwidth' and 'shortmess'. */
  383.       if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s",
  384. --- 8452,8457 ----
  385. *** ../vim-6.2.184/src/proto/window.pro    Sun Jun  1 12:26:22 2003
  386. --- src/proto/window.pro    Fri Jan 16 17:06:35 2004
  387. ***************
  388. *** 22,28 ****
  389. --- 22,30 ----
  390.   void win_size_save __ARGS((garray_T *gap));
  391.   void win_size_restore __ARGS((garray_T *gap));
  392.   void win_setheight __ARGS((int height));
  393. + void win_setheight_win __ARGS((int height, win_T *win));
  394.   void win_setwidth __ARGS((int width));
  395. + void win_setwidth_win __ARGS((int width, win_T *wp));
  396.   void win_setminheight __ARGS((void));
  397.   void win_drag_status_line __ARGS((win_T *dragwin, int offset));
  398.   void win_drag_vsep_line __ARGS((win_T *dragwin, int offset));
  399. *** ../vim-6.2.184/src/window.c    Sat May 31 21:08:43 2003
  400. --- src/window.c    Fri Jan 16 17:06:31 2004
  401. ***************
  402. *** 66,72 ****
  403.   static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
  404.   
  405.   #endif /* FEAT_WINDOWS */
  406. - static void win_setheight_win __ARGS((int height, win_T *win));
  407.   static win_T *win_alloc __ARGS((win_T *after));
  408.   static void win_new_height __ARGS((win_T *, int));
  409.   
  410. --- 66,71 ----
  411. ***************
  412. *** 2875,2881 ****
  413.       /* Change directories when the acd option is set on and after
  414.        * switching windows. */
  415.       if (p_acd && curbuf->b_ffname != NULL
  416. !         && vim_chdirfile(curbuf->b_ffname) == OK)
  417.       shorten_fnames(TRUE);
  418.   #endif
  419.   }
  420. --- 2874,2880 ----
  421.       /* Change directories when the acd option is set on and after
  422.        * switching windows. */
  423.       if (p_acd && curbuf->b_ffname != NULL
  424. !                      && vim_chdirfile(curbuf->b_ffname) == OK)
  425.       shorten_fnames(TRUE);
  426.   #endif
  427.   }
  428. ***************
  429. *** 3454,3467 ****
  430.   win_setheight(height)
  431.       int        height;
  432.   {
  433. -     /* Always keep current window at least one line high, even when
  434. -      * 'winminheight' is zero. */
  435. - #ifdef FEAT_WINDOWS
  436. -     if (height < p_wmh)
  437. -     height = p_wmh;
  438. - #endif
  439. -     if (height == 0)
  440. -     height = 1;
  441.       win_setheight_win(height, curwin);
  442.   }
  443.   
  444. --- 3453,3458 ----
  445. ***************
  446. *** 3469,3481 ****
  447.    * Set the window height of window "win" and take care of repositioning other
  448.    * windows to fit around it.
  449.    */
  450. !     static void
  451.   win_setheight_win(height, win)
  452.       int        height;
  453.       win_T    *win;
  454.   {
  455.       int        row;
  456.   
  457.   #ifdef FEAT_WINDOWS
  458.       frame_setheight(win->w_frame, height + win->w_status_height);
  459.   
  460. --- 3460,3484 ----
  461.    * Set the window height of window "win" and take care of repositioning other
  462.    * windows to fit around it.
  463.    */
  464. !     void
  465.   win_setheight_win(height, win)
  466.       int        height;
  467.       win_T    *win;
  468.   {
  469.       int        row;
  470.   
  471. +     if (win == curwin)
  472. +     {
  473. +     /* Always keep current window at least one line high, even when
  474. +      * 'winminheight' is zero. */
  475. + #ifdef FEAT_WINDOWS
  476. +     if (height < p_wmh)
  477. +         height = p_wmh;
  478. + #endif
  479. +     if (height == 0)
  480. +         height = 1;
  481. +     }
  482.   #ifdef FEAT_WINDOWS
  483.       frame_setheight(win->w_frame, height + win->w_status_height);
  484.   
  485. ***************
  486. *** 3700,3713 ****
  487.   win_setwidth(width)
  488.       int        width;
  489.   {
  490.       /* Always keep current window at least one column wide, even when
  491.        * 'winminwidth' is zero. */
  492. !     if (width < p_wmw)
  493. !     width = p_wmw;
  494. !     if (width == 0)
  495. !     width = 1;
  496.   
  497. !     frame_setwidth(curwin->w_frame, width + curwin->w_vsep_width);
  498.   
  499.       /* recompute the window positions */
  500.       (void)win_comp_pos();
  501. --- 3703,3727 ----
  502.   win_setwidth(width)
  503.       int        width;
  504.   {
  505. +     win_setwidth_win(width, curwin);
  506. + }
  507. +     void
  508. + win_setwidth_win(width, wp)
  509. +     int        width;
  510. +     win_T    *wp;
  511. + {
  512.       /* Always keep current window at least one column wide, even when
  513.        * 'winminwidth' is zero. */
  514. !     if (wp == curwin)
  515. !     {
  516. !     if (width < p_wmw)
  517. !         width = p_wmw;
  518. !     if (width == 0)
  519. !         width = 1;
  520. !     }
  521.   
  522. !     frame_setwidth(wp->w_frame, width + wp->w_vsep_width);
  523.   
  524.       /* recompute the window positions */
  525.       (void)win_comp_pos();
  526. *** ../vim-6.2.184/src/version.c    Sun Jan 18 20:28:27 2004
  527. --- src/version.c    Sun Jan 18 20:33:05 2004
  528. ***************
  529. *** 639,640 ****
  530. --- 639,642 ----
  531.   {   /* Add new patch number below this line */
  532. + /**/
  533. +     185,
  534.   /**/
  535.  
  536. -- 
  537.     [clop clop]
  538. ARTHUR:  Old woman!
  539. DENNIS:  Man!
  540. ARTHUR:  Man, sorry.  What knight lives in that castle over there?
  541. DENNIS:  I'm thirty seven.
  542. ARTHUR:  What?
  543. DENNIS:  I'm thirty seven -- I'm not old!
  544.                                   The Quest for the Holy Grail (Monty Python)
  545.  
  546.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  547. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  548. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  549.  \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
  550.