To: vim-dev@vim.org Subject: Patch 6.0.234 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.234 Problem: It's not easy to set the cursor position without modifying marks. Solution: Add the cursor() function. (Yegappan Lakshmanan) Files: runtime/doc/eval.txt, src/eval.c *** ../vim60.233/runtime/doc/eval.txt Sun Feb 3 12:42:13 2002 --- runtime/doc/eval.txt Mon Feb 18 12:52:51 2002 *************** *** 1,4 **** ! *eval.txt* For Vim version 6.0. Last change: 2001 Sep 16 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 6.0. Last change: 2002 Feb 18 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 743,752 **** char2nr( {expr}) Number ASCII value of first char in {expr} cindent( {lnum}) Number C indent for line {lnum} col( {expr}) Number column nr of cursor or mark ! confirm( {msg}, {choices} [, {default} [, {type}]]) Number number of choice picked by user cscope_connection( [{num} , {dbpath} [, {prepend}]]) Number checks existence of cscope connection delete( {fname}) Number delete file {fname} did_filetype() Number TRUE if FileType autocommand event used escape( {string}, {chars}) String escape {chars} in {string} with '\' --- 759,769 ---- char2nr( {expr}) Number ASCII value of first char in {expr} cindent( {lnum}) Number C indent for line {lnum} col( {expr}) Number column nr of cursor or mark ! confirm( {msg} [, {choices} [, {default} [, {type}]]]) Number number of choice picked by user cscope_connection( [{num} , {dbpath} [, {prepend}]]) Number checks existence of cscope connection + cursor( {lnum}, {col}) Number position cursor at {lnum}, {col} delete( {fname}) Number delete file {fname} did_filetype() Number TRUE if FileType autocommand event used escape( {string}, {chars}) String escape {chars} in {string} with '\' *************** *** 995,1010 **** col("'t") column of mark t col("'" . markname) column of mark markname < The first column is 1. 0 is returned for an error. ! ! *confirm()* ! confirm({msg}, {choices} [, {default} [, {type}]]) Confirm() offers the user a dialog, from which a choice can be made. It returns the number of the choice. For the first choice this is 1. Note: confirm() is only supported when compiled with dialog support, see |+dialog_con| and |+dialog_gui|. {msg} is displayed in a |dialog| with {choices} as the ! alternatives. {msg} is a String, use '\n' to include a newline. Only on some systems the string is wrapped when it doesn't fit. {choices} is a String, with the individual choices separated --- 1018,1041 ---- col("'t") column of mark t col("'" . markname) column of mark markname < The first column is 1. 0 is returned for an error. ! For the cursor position, when 'virtualedit' is active, the ! column is one higher if the cursor is after the end of the ! line. This can be used to obtain the column in Insert mode: > ! :imap :let save_ve = &ve ! \:set ve=all ! \:echo col(".") . "\n" ! \let &ve = save_ve ! < ! *confirm()* ! confirm({msg} [, {choices} [, {default} [, {type}]]]) Confirm() offers the user a dialog, from which a choice can be made. It returns the number of the choice. For the first choice this is 1. Note: confirm() is only supported when compiled with dialog support, see |+dialog_con| and |+dialog_gui|. {msg} is displayed in a |dialog| with {choices} as the ! alternatives. When {choices} is missing or empty, "&OK" is ! used (and translated). {msg} is a String, use '\n' to include a newline. Only on some systems the string is wrapped when it doesn't fit. {choices} is a String, with the individual choices separated *************** *** 1085,1090 **** --- 1116,1132 ---- cscope_connection(4, "out", "local") 0 cscope_connection(4, "cscope.out", "/usr/local") 1 < + cursor({lnum}, {col}) *cursor()* + Positions the cursor at the column {col} in the line {lnum}. + Does not change the jumplist. + If {lnum} is greater than the number of lines in the buffer, + the cursor will be positioned at the last line in the buffer. + If {lnum} is zero, the cursor will stay in the current line. + If {col} is greater than the number of characters in the line, + the cursor will be positioned at the last character in the + line. + If {col} is zero, the cursor will stay in the current column. + *delete()* delete({fname}) Deletes the file by the name {fname}. The result is a Number, which is 0 if the file was deleted successfully, and non-zero *** ../vim60.233/src/eval.c Mon Feb 11 14:04:44 2002 --- src/eval.c Mon Feb 18 12:49:34 2002 *************** *** 210,215 **** --- 210,216 ---- static void f_col __ARGS((VAR argvars, VAR retvar)); static void f_confirm __ARGS((VAR argvars, VAR retvar)); static void f_cscope_connection __ARGS((VAR argvars, VAR retvar)); + static void f_cursor __ARGS((VAR argsvars, VAR retvar)); static void f_delete __ARGS((VAR argvars, VAR retvar)); static void f_inputdialog __ARGS((VAR argvars, VAR retvar)); static void f_did_filetype __ARGS((VAR argvars, VAR retvar)); *************** *** 2350,2355 **** --- 2351,2357 ---- {"col", 1, 1, f_col}, {"confirm", 1, 4, f_confirm}, {"cscope_connection",0,3, f_cscope_connection}, + {"cursor", 2, 2, f_cursor}, {"delete", 1, 1, f_delete}, {"did_filetype", 0, 0, f_did_filetype}, {"escape", 2, 2, f_escape}, *************** *** 3199,3204 **** --- 3201,3235 ---- } /* + * "cursor(lnum, col)" function + * + * Moves the cursor to the specified line and column + */ + /*ARGSUSED*/ + static void + f_cursor(argvars, retvar) + VAR argvars; + VAR retvar; + { + long line, col; + + line = get_var_lnum(argvars); + if (line > 0) + curwin->w_cursor.lnum = line; + col = get_var_number(&argvars[1]); + if (col > 0) + curwin->w_cursor.col = col - 1; + + /* Make sure the cursor is in a valid position. */ + check_cursor(); + #ifdef FEAT_MBYTE + /* Correct cursor for multi-byte character. */ + if (has_mbyte) + mb_adjust_cursor(); + #endif + } + + /* * "libcall()" function */ static void *** ../vim60.233/src/version.c Mon Feb 18 12:38:04 2002 --- src/version.c Mon Feb 18 12:53:21 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 234, /**/ -- SUPERIMPOSE "England AD 787". After a few more seconds we hear hoofbeats in the distance. They come slowly closer. Then out of the mist comes KING ARTHUR followed by a SERVANT who is banging two half coconuts together. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///