To: vim_dev@googlegroups.com Subject: Patch 9.0.0342 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0342 Problem: ":wincmd =" equalizes in two directions. Solution: Make ":vertical wincmd =" equalize vertically only and ":horizontal wincmd =" equalize horizontally only. Files: runtime/doc/windows.txt, src/vim.h, src/ex_docmd.c, src/ex_cmds.h, src/ex_cmdidxs.h, src/window.c, src/testdir/test_window_cmd.vim *** ../vim-9.0.0341/runtime/doc/windows.txt 2022-08-25 16:02:09.673816447 +0100 --- runtime/doc/windows.txt 2022-08-31 17:08:09.905325618 +0100 *************** *** 183,188 **** --- 183,190 ---- 3. 'eadirection' isn't "ver", and 4. one of the other windows is wider than the current or new window. + If N was given make the new window N columns wide, if + possible. Note: In other places CTRL-Q does the same as CTRL-V, but here it doesn't! *************** *** 254,262 **** *:vert* *:vertical* :vert[ical] {cmd} Execute {cmd}. If it contains a command that splits a window, ! it will be split vertically. Doesn't work for |:execute| and |:normal|. :lefta[bove] {cmd} *:lefta* *:leftabove* :abo[veleft] {cmd} *:abo* *:aboveleft* Execute {cmd}. If it contains a command that splits a window, --- 256,271 ---- *:vert* *:vertical* :vert[ical] {cmd} Execute {cmd}. If it contains a command that splits a window, ! it will be split vertically. For `vertical wincmd =` windows ! will be equialized only vertically. Doesn't work for |:execute| and |:normal|. + *:hor* *:horizontal* + :hor[izontal] {cmd} + Execute {cmd}. Currently only makes a difference for + `horizontal wincmd =`, which will equal windows only + horizontally. + :lefta[bove] {cmd} *:lefta* *:leftabove* :abo[veleft] {cmd} *:abo* *:aboveleft* Execute {cmd}. If it contains a command that splits a window, *************** *** 551,556 **** --- 560,569 ---- 'winheight' and 'winwidth' for the current window. Windows with 'winfixheight' set keep their height and windows with 'winfixwidth' set keep their width. + To equalize only vertically (make window equally high) use + `vertical wincmd =` + To equalize only horizontally (make window equally wide) use + `horizontal wincmd =` :res[ize] -N *:res* *:resize* *CTRL-W_-* CTRL-W - Decrease current window height by N (default 1). *** ../vim-9.0.0341/src/vim.h 2022-08-26 11:54:58.385177821 +0100 --- src/vim.h 2022-08-31 17:09:36.744957666 +0100 *************** *** 1209,1222 **** /* * arguments for win_split() */ ! #define WSP_ROOM 1 // require enough room ! #define WSP_VERT 2 // split vertically ! #define WSP_TOP 4 // window at top-left of shell ! #define WSP_BOT 8 // window at bottom-right of shell ! #define WSP_HELP 16 // creating the help window ! #define WSP_BELOW 32 // put new window below/right ! #define WSP_ABOVE 64 // put new window above/left ! #define WSP_NEWLOC 128 // don't copy location list /* * arguments for gui_set_shellsize() --- 1209,1223 ---- /* * arguments for win_split() */ ! #define WSP_ROOM 0x01 // require enough room ! #define WSP_VERT 0x02 // split/equalize vertically ! #define WSP_HOR 0x04 // equalize horizontally ! #define WSP_TOP 0x08 // window at top-left of shell ! #define WSP_BOT 0x10 // window at bottom-right of shell ! #define WSP_HELP 0x20 // creating the help window ! #define WSP_BELOW 0x40 // put new window below/right ! #define WSP_ABOVE 0x80 // put new window above/left ! #define WSP_NEWLOC 0x100 // don't copy location list /* * arguments for gui_set_shellsize() *** ../vim-9.0.0341/src/ex_docmd.c 2022-08-31 14:46:07.907016957 +0100 --- src/ex_docmd.c 2022-08-31 17:10:31.772736870 +0100 *************** *** 2987,2994 **** continue; } // ":hide" and ":hide | cmd" are not modifiers ! case 'h': if (p != eap->cmd || !checkforcmd_noparen(&p, "hide", 3) || *p == NUL || ends_excmd(*p)) break; eap->cmd = p; --- 2987,2999 ---- continue; } + case 'h': if (checkforcmd_noparen(&eap->cmd, "horizontal", 3)) + { + cmod->cmod_split |= WSP_HOR; + continue; + } // ":hide" and ":hide | cmd" are not modifiers ! if (p != eap->cmd || !checkforcmd_noparen(&p, "hide", 3) || *p == NUL || ends_excmd(*p)) break; eap->cmd = p; *** ../vim-9.0.0341/src/ex_cmds.h 2022-08-29 18:16:11.578636822 +0100 --- src/ex_cmds.h 2022-08-31 17:12:12.120355520 +0100 *************** *** 707,712 **** --- 707,715 ---- EXCMD(CMD_history, "history", ex_history, EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_NONE), + EXCMD(CMD_horizontal, "horizontal", ex_wrongmodifier, + EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM, + ADDR_NONE), EXCMD(CMD_insert, "insert", ex_append, EX_BANG|EX_RANGE|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_MODIFY, ADDR_LINES), *** ../vim-9.0.0341/src/ex_cmdidxs.h 2022-08-29 18:16:11.578636822 +0100 --- src/ex_cmdidxs.h 2022-08-31 17:13:16.808122299 +0100 *************** *** 13,36 **** /* f */ 166, /* g */ 183, /* h */ 189, ! /* i */ 198, ! /* j */ 218, ! /* k */ 220, ! /* l */ 225, ! /* m */ 288, ! /* n */ 306, ! /* o */ 326, ! /* p */ 338, ! /* q */ 377, ! /* r */ 380, ! /* s */ 400, ! /* t */ 470, ! /* u */ 516, ! /* v */ 527, ! /* w */ 548, ! /* x */ 562, ! /* y */ 572, ! /* z */ 573 }; /* --- 13,36 ---- /* f */ 166, /* g */ 183, /* h */ 189, ! /* i */ 199, ! /* j */ 219, ! /* k */ 221, ! /* l */ 226, ! /* m */ 289, ! /* n */ 307, ! /* o */ 327, ! /* p */ 339, ! /* q */ 378, ! /* r */ 381, ! /* s */ 401, ! /* t */ 471, ! /* u */ 517, ! /* v */ 528, ! /* w */ 549, ! /* x */ 563, ! /* y */ 573, ! /* z */ 574 }; /* *************** *** 48,54 **** /* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 12, 0, 0, 0, 0, 0, 0, 0, 23, 0, 24, 0, 0 }, /* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0 }, /* g */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; ! static const int command_count = 590; --- 69,72 ---- /* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; ! static const int command_count = 591; *** ../vim-9.0.0341/src/window.c 2022-08-31 14:46:07.911016920 +0100 --- src/window.c 2022-08-31 17:20:10.950792389 +0100 *************** *** 434,445 **** | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); break; ! // make all windows the same height case '=': #ifdef FEAT_GUI ! need_mouse_correct = TRUE; #endif ! win_equal(NULL, FALSE, 'b'); break; // increase current window height --- 434,449 ---- | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); break; ! // make all windows the same width and/or height case '=': + { + int mod = cmdmod.cmod_split & (WSP_VERT | WSP_HOR); #ifdef FEAT_GUI ! need_mouse_correct = TRUE; #endif ! win_equal(NULL, FALSE, ! mod == WSP_VERT ? 'v' : mod == WSP_HOR ? 'h' : 'b'); ! } break; // increase current window height *** ../vim-9.0.0341/src/testdir/test_window_cmd.vim 2022-08-31 14:46:07.915016883 +0100 --- src/testdir/test_window_cmd.vim 2022-08-31 17:45:10.891101232 +0100 *************** *** 367,372 **** --- 367,412 ---- bw Xa Xb Xc endfunc + func Test_wincmd_equal() + edit Xone + below split Xtwo + rightbelow vsplit Xthree + call assert_equal('Xone', bufname(winbufnr(1))) + call assert_equal('Xtwo', bufname(winbufnr(2))) + call assert_equal('Xthree', bufname(winbufnr(3))) + + " Xone and Xtwo should be about the same height + let [wh1, wh2] = [winheight(1), winheight(2)] + call assert_inrange(wh1 - 1, wh1 + 1, wh2) + " Xtwo and Xthree should be about the same width + let [ww2, ww3] = [winwidth(2), winwidth(3)] + call assert_inrange(ww2 - 1, ww2 + 1, ww3) + + 1wincmd w + 10wincmd _ + 2wincmd w + 20wincmd | + call assert_equal(10, winheight(1)) + call assert_equal(20, winwidth(2)) + + " equalizing horizontally doesn't change the heights + hor wincmd = + call assert_equal(10, winheight(1)) + let [ww2, ww3] = [winwidth(2), winwidth(3)] + call assert_inrange(ww2 - 1, ww2 + 1, ww3) + + 2wincmd w + 20wincmd | + call assert_equal(20, winwidth(2)) + " equalizing vertically doesn't change the widths + vert wincmd = + call assert_equal(20, winwidth(2)) + let [wh1, wh2] = [winheight(1), winheight(2)] + call assert_inrange(wh1 - 1, wh1 + 1, wh2) + + bwipe Xone Xtwo Xthree + endfunc + func Test_window_width() e Xa vsplit Xb *** ../vim-9.0.0341/src/version.c 2022-08-31 16:40:14.250932016 +0100 --- src/version.c 2022-08-31 17:47:06.403415780 +0100 *************** *** 709,710 **** --- 709,712 ---- { /* Add new patch number below this line */ + /**/ + 342, /**/ -- ARTHUR: I've said I'm sorry about the old woman, but from the behind you looked ... DENNIS: What I object to is that you automatically treat me like an inferior... ARTHUR: Well ... I AM king. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///