To: vim-dev@vim.org Subject: Patch 6.1.308 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.308 Problem: Can't reset the Visual mode returned by visualmode(). Solution: Use an optional argument to visualmode(). (Charles Campbell) Files: runtime/doc/eval.txt, src/eval.c, src/normal.c, src/structs.h *** ../vim61.307/runtime/doc/eval.txt Sun Jan 5 22:14:46 2003 --- runtime/doc/eval.txt Tue Jan 28 21:57:36 2003 *************** *** 1,4 **** ! *eval.txt* For Vim version 6.1. Last change: 2003 Jan 05 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 6.1. Last change: 2003 Jan 28 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 865,871 **** toupper( {expr}) String the String {expr} switched to uppercase type( {name}) Number type of variable {name} virtcol( {expr}) Number screen column of cursor or mark ! visualmode() String last visual mode used winbufnr( {nr}) Number buffer number of window {nr} wincol() Number window column of the cursor winheight( {nr}) Number height of window {nr} --- 869,875 ---- toupper( {expr}) String the String {expr} switched to uppercase type( {name}) Number type of variable {name} virtcol( {expr}) Number screen column of cursor or mark ! visualmode( [expr]) String last visual mode used winbufnr( {nr}) Number buffer number of window {nr} wincol() Number window column of the cursor winheight( {nr}) Number height of window {nr} *************** *** 2391,2397 **** virtcol("'t") with text " there", with 't at 'h', returns 6 < The first column is 1. 0 is returned for an error. ! visualmode() *visualmode()* The result is a String, which describes the last Visual mode used. Initially it returns an empty string, but once Visual mode has been used, it returns "v", "V", or "" (a --- 2427,2433 ---- virtcol("'t") with text " there", with 't at 'h', returns 6 < The first column is 1. 0 is returned for an error. ! visualmode([expr]) *visualmode()* The result is a String, which describes the last Visual mode used. Initially it returns an empty string, but once Visual mode has been used, it returns "v", "V", or "" (a *************** *** 2403,2408 **** --- 2439,2449 ---- in scripts if you wish to act differently depending on the Visual mode that was used. + If an expression is supplied that results in a non-zero number + or a non-empty string, then the Visual mode will be cleared + and the old value is returned. Note that " " and "0" are also + non-empty strings, thus cause the mode to be cleared. + *winbufnr()* winbufnr({nr}) The result is a Number, which is the number of the buffer associated with window {nr}. When {nr} is zero, the number of *** ../vim61.307/src/eval.c Sun Jan 19 17:16:13 2003 --- src/eval.c Tue Jan 28 22:00:17 2003 *************** *** 2520,2526 **** {"toupper", 1, 1, f_toupper}, {"type", 1, 1, f_type}, {"virtcol", 1, 1, f_virtcol}, ! {"visualmode", 0, 0, f_visualmode}, {"winbufnr", 1, 1, f_winbufnr}, {"wincol", 0, 0, f_wincol}, {"winheight", 1, 1, f_winheight}, --- 2520,2526 ---- {"toupper", 1, 1, f_toupper}, {"type", 1, 1, f_type}, {"virtcol", 1, 1, f_virtcol}, ! {"visualmode", 0, 1, f_visualmode}, {"winbufnr", 1, 1, f_winbufnr}, {"wincol", 0, 0, f_wincol}, {"winheight", 1, 1, f_winheight}, *************** *** 6587,6595 **** char_u str[2]; retvar->var_type = VAR_STRING; ! str[0] = curbuf->b_visual_mode; str[1] = NUL; retvar->var_val.var_string = vim_strsave(str); } /* --- 6587,6602 ---- char_u str[2]; retvar->var_type = VAR_STRING; ! str[0] = curbuf->b_visual_mode_eval; str[1] = NUL; retvar->var_val.var_string = vim_strsave(str); + + /* A non-zero number or non-empty string argument: reset mode. */ + if ((argvars[0].var_type == VAR_NUMBER + && argvars[0].var_val.var_number != 0) + || (argvars[0].var_type == VAR_STRING + && *get_var_string(&argvars[0]) != NUL)) + curbuf->b_visual_mode_eval = NUL; } /* *** ../vim61.307/src/normal.c Sun Jan 26 22:42:25 2003 --- src/normal.c Tue Jan 28 22:03:43 2003 *************** *** 1360,1365 **** --- 1360,1368 ---- curbuf->b_visual_start = VIsual; curbuf->b_visual_end = curwin->w_cursor; curbuf->b_visual_mode = VIsual_mode; + # ifdef FEAT_EVAL + curbuf->b_visual_mode_eval = VIsual_mode; + # endif curbuf->b_visual_curswant = curwin->w_curswant; /* In Select mode, a linewise selection is operated upon like a *************** *** 2906,2911 **** --- 2909,2917 ---- /* Save the current VIsual area for '< and '> marks, and "gv" */ curbuf->b_visual_mode = VIsual_mode; + #ifdef FEAT_EVAL + curbuf->b_visual_mode_eval = VIsual_mode; + #endif curbuf->b_visual_start = VIsual; curbuf->b_visual_end = curwin->w_cursor; curbuf->b_visual_curswant = curwin->w_curswant; *************** *** 6697,6702 **** --- 6703,6711 ---- i = VIsual_mode; VIsual_mode = curbuf->b_visual_mode; curbuf->b_visual_mode = i; + # ifdef FEAT_EVAL + curbuf->b_visual_mode_eval = i; + # endif i = curwin->w_curswant; curwin->w_curswant = curbuf->b_visual_curswant; curbuf->b_visual_curswant = i; *** ../vim61.307/src/structs.h Sun Jan 5 22:14:46 2003 --- src/structs.h Tue Jan 28 22:02:54 2003 *************** *** 819,824 **** --- 821,829 ---- pos_T b_visual_start; /* start pos of last VIsual */ pos_T b_visual_end; /* end position of last VIsual */ int b_visual_mode; /* VIsual_mode of last VIsual */ + # ifdef FEAT_EVAL + int b_visual_mode_eval; /* b_visual_mode for visualmode() */ + # endif colnr_T b_visual_curswant; /* MAXCOL from w_curswant */ #endif *** ../vim61.307/src/version.c Tue Jan 28 21:51:20 2003 --- src/version.c Tue Jan 28 21:53:19 2003 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 308, /**/ -- hundred-and-one symptoms of being an internet addict: 70. ISDN lines are added to your house on a hourly basis /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///